Brian
Brian

Reputation: 31282

iOS - Use 3rd party library in my custom framework

I was building my own framework, and I installed a 3rd party lib BadgeSwift via CocoaPods in my framework. Everything was good before I integrated my framework into a test project.

In my test project, I got this run time error every time I ran it on the simulator:

dyld: Library not loaded: @rpath/BadgeSwift.framework/BadgeSwift
Referenced from: /Users/brian/Library/Developer/CoreSimulator/Devices/4D2C8A32-ADD7-4D3C-8C3A-0AD696B8B147/data/Containers/Bundle/Application/F0B059EB-E004-49B7-92A1-7798CE17B12A/TestIMKit.app/Frameworks/IMKit.framework/IMKit
Reason: image not found

I got this error even when I actually didn't use BadgeSwift at all. (I tried to remove all my code using BadgeSwift while leaving the lib installed)

Also, I am sure BadgeSwift is irrelevant. Every 3rd party lib will trigger this run time crash.

How to install 3rd party libraries in my custom framework via CocoaPods correctly?

Upvotes: 1

Views: 1955

Answers (2)

sanyam jain
sanyam jain

Reputation: 202

After pulling off my brain for almost 2 days i finally figured out the solution. 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.

Upvotes: 1

Wolverine
Wolverine

Reputation: 4329

Try this

Go To :

Your Project -> Target -> General -> Embedded Binaries 
  • Add your library in this section.
  • Clean Derived Data Folder
  • Clean and Run

If you are facing this error in every 3rd party library, Then try using add their framework by following above steps.

Normally it is not required for every 3rd party library.

When we install cocoa-pod, libPods-"Project name".a file of cocoa pod is added in

Your Project -> Target -> General -> Linked Frameworks and Libraries

So normally it is not required.

Yet if you are facing this issue, If you fix this issue by adding above steps then it will be good, or try to Re-install CocoaPods.

Upvotes: 0

Related Questions