Cocoa Touch Framework Dependencies - ios

I'm trying to create a Cocoa Touch Framework. To create a framework is not a problem, I used this tutorial and it is good.
I need to use third party libraries inside: like openssl, XLForm, AFNetworking. I know that it is not correct to include them in my framework, I need to create a dependencies, but I can't find how to do this.
Moreover is it possible to use pods in my framework and just make dependencies to these libs. So user which will include my framework to his project will need just install these pods.

It seems that I found solution.
Thanks to #Droppy and thanks to this question.
What I did: I just installed pods to my Framework project but used this use_frameworks! key.
Then I dragged my Framework to my Project and installed pods there, also with same key, otherwise (when pod wasn't installed in my Project) I was getting error like:
dyld: Library not loaded: #rpath/XLForm.framework/XLForm...
I used XLForm inside my Framework.

Related

Can I add Pods in Custom framework?

I have the custom created framework.
I want to use CryptoSwift Pods in this framework.
First, I create a custom framework and I can use this framework(From Frameworks folder Example.framework) from another project.
Second, I installed CryptySwift Pods to these frameworks
How can I install Pods programmatically in custom frameworks and used it in other projects?
Not understanding you exact question but if you want to create your own framework and you are using any third party then you can create your framework with your own files and then when you will use your framework in another project then ask developer to install those third party pods or frameworks into their project. It will help to avoid conflict if developer also using same framework or pod in their project.

How to add a reference (instead of copy) of a custom iOS framework in a project

I try to add a custom made framework in a project of me but as a reference.
The reason for this is that I want making changes in the framework and see them in the project without need of delete old framework - copy new one.
But something i am missing since i got the below error
No such module
The way I add the framework as a reference is to "untick" the "copy if needed" when I drag and drop it.
I am adding the framework inside the "frameworks" folder of the project.
Any help would be appreciated, thanks!
You should be linking external libraries in the menu by going to the Target’s “Build Phases” and add the library with “link binary with libraries”. This should fix your problem.
An alternative suggestion is to use CocoaPods, which are very widely used in iOS development. If you aren't familiar with Cocoapods, its sort of like web development's npm. You turn your custom framework into a Pod and add a Podfile to your iOS app. The Podfile is just a list of external dependencies. If you push a change to your custom framework, all you have to do is run
pod update
in your command line it will automatically handle the update. This would solve your problem and also keeps your project neat and organized so you don't have to juggle drag and dropping new libraries. CocoaPods also can handle a lot of the other major external libraries you may be using. See the following very easy to follow tutorials:
creating a pod,
getting started with cocoapods

Framework target, App target and cocoaPods working together, how to maintain dependencies

I am creating a framework that uses third party frameworks like alamofire. I have created a App that uses this framework and also uses third party framework again like alamofire(both could use it). So now I have 2 targets, I added both in workspace, I did pod init but it could only link with only one .xcodeproj and create its own workspace.
I also tried
Can I use CocoaPods when creating a Cocoa Touch Framework?
but pod install didn't work as it was not able to find target and if dragged in same folder it ask to specify target path as it only want one .xcodeproj
Please if somebody could help me with this. How to access cocoa pods framework in both custom framework and app.
Ideally the Pod should be in your App.
Even though your Framework is also using the same third party framework the pod install should be done for that at App level and both App and framework should be able to read it.
Have said that, if you are developing Framework independently you can install POD at that time in framework but when your are using this framework in app then the third party framework can be installed at app level and frameworks should also be able to read it since they are now also part of same App target.

Embedded swift framework with cocoapods

I made a private framework that I want to use in different project. I use Cocoapods with this framework for third parties like AFNetworking, Facebook, or SDWebImage. I use an aggregate to build my framework for simulator and devices architectures.
I can build it, without any problem, but when I add my embedded framework to my new project (wrote in Objective-C), I have this error at the launch:
dyld: Library not loaded: #rpath/AFNetworking.framework/AFNetworking
Referenced from: /private/var/containers/Bundle/Application/2BE49976-94F8-43C3-BBFF-930F11642DDE/MyPhotoApp.app/Frameworks/PhotoLibrary.framework/PhotoLibrary
Reason: image not found
My new project has also Cocoapods with all the required pods of my framework.
The thing I would like, and I can't find how to do it, is to make a framework that depends of Cocoapods, but that does not contains the sources. I would like that the client add itself the necessary pods to its project.
Do you know how I can do that ?
Thank you :)
For Objective-c projects, DONOT uncomment the line use_frameworks!. It is meant only for swift projects. For future reference. :)

Xcode: create Framework with pod dependecies

I create a framework that use AFNetworking (installed with pod).
I can import this framework on my project and I can use all classes/methods that I exposed, so project compile.
When I try to run project on simulator, I obtain this error:
dyld: Library not loaded: #rpath/AFNetworking.framework/AFNetworking
Referenced from:
/Users/.../Library/Developer/CoreSimulator/Devices/F56F98F0-2AE0-4C87-AC9A-6E3B449762D1/data/Containers/Bundle/Application/BFA5359F-8FCE-4402-8487-CD9C002CB673/MyProject.app/Frameworks/MyFramework.framework/MyFramework
Reason: image not found
I already included 'MyFramework' under:
Build phases -> Embed Frameworks
I suppose I missing something on building Frameworks, but I can find out what! I already seen this unanswered question.
Who can I use MyFramework without installing Pod on MyProject again?
It is really delayed, for this issue but I have got my project working. It might not be the best way but it works. I am putting it here for future reference.
I wanted to do it without using Pods in the main project. The reasoning is, we are bundling our SDK into a framework.
So essentially, the first step I took was to get the framework project bundling without using the workspace. I just dragged the Pods project into the framework project.
Then I added the frameworks the the pods project creates and add them to my framework. I set them to optional and code sign. You can see them in the picture of where I added them under the build phases.
Then add them to your main project. not the framework the normal way by adding the project and or the framework. Then add it to the Embedded binaries and Linked Frameworks.
If it helps anyone, the solution mentioned by #ArtyomDevyatov does work. The trick is that you have to add 's.dependency' in podspec file.

Resources