0

I have created one custom library called 'Library.dylib',now I am trying to add that dylib file in another iOS project and it is giving following error,

dyld: Library not loaded: @executable_path/Library.dylib Referenced from: /Users/xxxx/Library/Developer/CoreSimulator/Devices/4CCFE5F7-494B-41DE-AEB9-5040418518B4/data/Containers/Bundle/Application/A97A1947-80B5-9AA0-B46F-C11E25A94553/DyLibTest.app/DyLibTest Reason: image not found

In Mac app if we copy it in /usr/lib/ path it is working, but not in iOS app.

Please let me know how to use custom dylib in iOS application?

FYI I want to use only dynamic linking not static linking(.a)

enter image description here

enter image description here

2
  • Make sure while adding that library you are ticking the option "copy items if needed" and also ticking your main target. Commented Aug 7, 2017 at 8:58
  • Hi @ParasGorasiya i am doing that already. Commented Aug 7, 2017 at 9:20

2 Answers 2

3

As far as I can see your app expects your library to be copied to @executable_path/Library.dylib. Yet, if you add your library to the Embed Frameworks build phase (which I assume you did) it will be copied to the Frameworks subfolder in your app bundle and therefore cannot be loaded by your app.

There are two solutions:

1) Change the destination of the Embed Frameworks build phase from Frameworks to Executables. In general, I wouldn't recommend to change that though.

2) Adjust the Runpath Search Paths in your build settings to include @executable_path/Frameworks.

Hope that helps.

Sign up to request clarification or add additional context in comments.

8 Comments

Hi @Jens Meder thanks for your answer,one thing I want to clarify is I am not using my .dylib inside any framework. I got my .dylib and placing it in app bundle. Instead of placing my dylib there, do I need to place some where else with any project settings?
Yepp, I didn't assume you have put your dylib in a framework. The thing is that dylibs a very similar to frameworks in the way the code is being loaded. Your executable needs to be able to load the code via the Runpath Search Paths so you need to make sure to copy the dylib to a location that your executable can find. Where do you copy the dylib at the moment?
Just now I have added images in the question, can you please look into those and help me where to copy that .dylib?
You just need to add it to the Copy Files build phase. The destination Frameworks is also correct for your Runpath Search Paths build setting.
Well, your dylib needs to be signed but Xcode takes care of everything as soon as you upload your app to the app store. There is no formal signing request or anything.
|
0

You must put *.dylib file in Embed Libraries.

Project -> Build Phases -> Embed Libraries

Click to "+" and choose your *.dylib file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.