I have created a framework project in Xcode -that has dependency on some pods- to be able to use in different Xcode projects.
How can Xcode be informed to get that framework the dependency it needs?
You have to declare the dependencies on frameworks or on other pods in the podspec file. This file will explain to cocoapods how to correctly bind the pod in your XCode project.
You have an example at the end of the second sample in this page.
I want to share framework in another app. I am facing issues when I have some libraries/pods like Alamofire in my framework. what is the solution of this problem? how can i use that library in framework? Also i tried to install Alamofire pod in to the other app in which i have added framework, and tried to access in my framework class but this was not accessible. please guide me how to do it. Thank you
You can use Cocoapods to achieve that. Basically, cocoapods will create a framework for you from the source files that you define and will also install the appropriate dependencies that you define in the target project when the target project does pod install.
Apart from cocoapods, you can also use Carthage which is also a dependency management tool.
You can read more about cocoapods here and how to create a new pod here
I'm creating a custom framework which uses Cocoa Pod internally. After installing POD I cannot make use of framework using agreegate target.
I added framework project with my application project just by trag and drop it inside Application project and linked it using Aggregate Target. After installing POD with custom framework, I can not make use the above mentioned way to link framework with my aggregate project.
Thanks
If you are developping a standalone librairy, something that users will have to add manually in their project, you CANNOT use cocoapod in your librairy project. No way! You'll have to provide your users with an install procedure indicating all extra step (framework install, project settings modification, pods to install) they'll have to follow to get your framework up and running.
This is why nowaday people use dependency manager like cocoapods. It makes it easier for users to install their product and install automaticly the dependencies.
If you are planning to distribute your framework thru pod, then follow the recommanded step to create your project architecture and reference in the example project (that uses pods) your dependencies.
How can I add opencv2 correctly to Xcode?
I just download from the website the opencv2.framework.zip,
and then I unzip the opencv2 ,finally appears opencv2.framework.
and then I build an xcode project, choose ios single view.
then I try to add opencv2.framework to the project
then I compile the project, It shows that:
what's happening here?I'm new here and I just can't figure out a solution. Thank you very much for your help!
I've put together a guide to use OpenCV using the .framework file (if you prefer it over cocoa pods as suggested above) you may have a look here. It works for both OpenCV2 iOS and the newer OpenCV3 iOS.
http://kurtjacobs.weebly.com/computer-vision/up-and-running-with-opencv-30-for-ios
Good luck!
You can download the opencv2 .framework, then in Xcode project, click the targets selected build phases. Click link Binary with libraries, click add other and select the .framework, clang.
Try and use Cocoapods to install it. If you haven't used Cocoapods before, it is a "CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects." More information is available on its website HERE.
To install OpenCV using Cocoapods, add pod 'OpenCV' to your pod file, and use the command pod install. Please refer to the OpenCV for iOS Cocoapods Readme page (https://cocoapods.org/pods/OpenCV) for more details.
I follow the instructions to the T. Fresh install of all, yet getting the error:
"No Such module Alamofire"
Directions here:
In the meantime, you can simply add Alamofire as a git submodule, drag the Alamofire.xcodeproj file into your Xcode project, and add the framework product as a dependency for your application target.
And my screenshots
Make sure you haven't added any files from Alamofire to your project except for the Alamofire.xcodeproj
Here is step by step instruction:
Download and unarchive Alamofire
Copy the root folder of Alamofire to any subfolder of your project. Libs, for example.
Drag and drop Alamofire.xcodeproj to your Xcode project
Open project settings of your project, Build Phases pane, expand Target Dependencies section, and add Alamofire as new dependency
Open General pane, expand Embedded Binaries section, and add Alamofire.framework
import Alamofire // in your source file
Alamofire.request(.GET, "http://httpbin.org/get") // use Alamofire
You need to add the lib to 'the Link Binary With Libraries' section also.
The target Dependencies makes sure your lib is (re)-build before your target (useful when you makes changes to the lib) and the Link section makes sure the lib is available doing the link phase.
EDIT
The above description works for most projects. However alarmofire just updated the process needed for this particular project here https://github.com/Alamofire/Alamofire
Banged my head against this for a couple days and figured I would throw this in here, our team project had this issue when bringing Alamofire in as a submodule. If you have your own scheme configurations, you need to duplicate them in the Alamofire.xcodeproj too. Which also likely means you need to fork Alamofire to keep these changes synced up.
This order of the Build Phases has worked for me.
Target Dependencies
Link Binary With Libraries.
Check Pods Manifest.lock
Embed Pods Frameworks
Compile Sources
You can rearrange Build Phases by dragging them.
After following NAlexN steps, it still didn't work for me
I also had to change the order of Build Phases.
It was
- Target Dependencies
- Compile Sources
- Link Binary With Libraries.
After I modified to:
- Target Dependencies
- Link Binary With Libraries.
- Compile Sources
It built and ran fine!
I resolved the error "No such module" for a fresh project, not for Alamofire but for another library called "RATreeView"
I had to add
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
pod "RATreeView", "~> 2.1.0"
to the Podfile
and ran
pod update
The key is to add use_frameworks! It might help someone
Similar errors when I used cocoapods..
I solved the problem by the following steps:
Update to Ruby 2.2.0+. (https://stackoverflow.com/a/14182172/1453505)
Update cocoapods 0.36.0+ (sudo gem install cocoapods --pre)
Again pod install
Open your project's .workspace file
Open "Manage Schemes" of your project in Xcode
Select "Alamofire" in scheme list
Clean your project
What worked for me: Including "Pods.framework" in "Linked Frameworks and Libraries" of your target if it not there already. (This applies in case you are are using cocoapods and are using frameworks as modules)
I had same issue,doing that Command+B (Build project) and disappear error.
Go to your project folder to be sure you are opening the .xcworkspace instead of the .xcodeproj file