Cocoapods inside iOS framework not working - ios

I'm trying to create a framework with some features of my App, which depends on Cocoapods for its dependencies.
The framework is compiling OK, but when added into another project, it crashes with this trace
Library not loaded: #rpath/AFNetworking.framework/AFNetworking
Referenced from: /private/var/containers/Bundle/Application/BA3917FD-FCF1-491B-90AF-86AFDCD7FF80/BMNPoC.app/Frameworks/myframework.framework/myframework
Reason: image not found
When searching on product folder I see my framework and the pod framework with AFNetworking in this case (so 3 separated frameworks). I guess those frameworks aren't being embed into MyFramework. How can I achieve this? Here's a link to a demo project https://www.dropbox.com/s/p9dbx9xy61twcoa/MyFramework.zip?dl=0

Related

FrameWork + Embedded Binaries

I have this issue when I attach my custom framework to a Test project.
dyld: Library not loaded: #rpath/FrameworkName.framework/FrameworkName
Referenced from: /Users/Me/Library/Developer/CoreSimulator/Devices/9C4B0FD8-200B-4FF1-AFEC-7D2316698CDA/data/Containers/Bundle/Application/9BAA9518-2FD0-4AAC-ABD8-F3842FA77A9E/TestProject.app/TestProject
Reason: image not found
I need to attach the framework to the Embedded Binaries to fixe this issue.
My question is:
Why for the other framework is not mandatory to add it to Embedded Binaries ?
What is missing in my framework project, or what I need to change in the build settings of the framework project ?
Ok i found the issue, i need to change the Mach-O Type in the build settings to Static Library.

How to build Cocoa touch framework which use third party lib as cocoa pod?

I'm a iOS developer and want to build a distributed framework which use pods to integrate third party lib in framework project. Pods like SVProgressHUD and socket.io-client-swift.
I want to know what is the best way to build this kind of frameworks. Is there any tutorial given online which gives all the instructions.
I tried building a framework in above structure and it complies fine but when I'm importing this framework in other project getting errors:
dyld: Library not loaded: #rpath/Framework.framework/Framework
Referenced from:
/var/containers/Bundle/Application/73A8E170-4FE5-4CFF-B52E-C42099F32F9C/Framework.app/Framework
Reason: image not found
Can anyone help me. Thanks in Advance!
All you need to do is set the third party frameworks you are using for e.g:- socket.io-client-swift as Optional instead of Required under Link binary with Libraries in build Phases section. That's all. try it again and it will run as expected.

Cocoa touch framework embed other libraries

They asked me to create a cocoatouch framework that bundles all off our 3th party frameworks. So that we can use that framework all over the company.
Now I think it's better when you make the application responsible for adding the dependencies that your framework need but this not possible here.
So I created a framework added some frameworks like PureLayout.framework, etc.. and added them to the linked frameworks and libraries.
It compiles and delivers a .framework but when I add that framework to the project and run it, then I get this error:
dyld: Library not loaded
Reason: image not found
So I think they are only linked against and not embedded in the framework.
How can I really embed them?

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