Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dyld: Library not loaded - When app run from the command line

Tags:

iphone

dyld

I face some difficulties when adding a framework to my project when i run an iPhone app from the command line. My final goal is to run applications tests from an automated build process.

When i run my app from xCode :

I add a "Copy File" build phase to my target and everything goes fine. The copy is set to $(BUILT_PRODUCTS_DIR) as "Absolute path"

When i run my app from the terminal (using iphonesim project) i get this error :

 dyld: Library not loaded: @rpath/OCMock.framework/Versions/A/OCMock

 UIKitApplication:indemnisation[0xb894][26380]     Referenced from: /Users/Admin/Library/Application Support/iPhone Simulator/User/Applications/CD5729B5-A674-49B2-91F6-AD398094B6F8/indemINT.app/indemINT

What i dont understand is that the copy build phase just copies the framework files in the same directory as the app.

When i run the app from the command line the framework files are already in the same directory. Does anyone knows why it doesn't work ?

I've also tried to add the OCMock.framework in the following directories (without success) :

 /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library

 /Library/Frameworks

 /Users/Admin/Library/Application Support/iPhone Simulator/User/Applications/CD5729B5-A674-49B2-91F6-AD398094B6F8

Thanks in advance, Vincent.

like image 964
user142764 Avatar asked Mar 18 '10 17:03

user142764


People also ask

Where is the library in xcode?

To open the library pane in newer versions of Xcode, select the square within a circle icon in the top right hand corner. This will bring up the library pane and you can search for any object. The keyboard shortcut to open this library pane is Shift + Cmd + L.


1 Answers

I just had this same exact error in Xcode 4.2 (4D199) on Lion. I dragged/dropped the OCMock.framework folder into my project and selected the "copy files" checkbox. I saw the above answers and realized I neglected to add a "Copy Files" build phase to move the framework into place. I added one and dragged it right after the compile files build phase and tried to run my tests again. I couldn't get it to work until I had changed the destination in the "Copy Files" phase to the "Products Directory". Using "Frameworks" or "Shared Frameworks" did not work.

like image 59
Cliff Avatar answered Sep 18 '22 01:09

Cliff