tags:

views:

2480

answers:

4

I have tried to integrate the Picasa API on iphone, compiles fine, but I am seeing the following error in launch.

dyld: Library not loaded: @loader_path/../Frameworks/GData.framework/Versions/A/GData Referenced from: /Users/jacksu/Library/Application Support/iPhone Simulator/User/Applications/9A7E3F54-022F-4771-BD6A-E458F5545144/PicasaTest.app/PicasaTest Reason: image not found

I am not sure what could be the problem.

I imported the GDataFramework from Source/build/Debug/GData.framework. I have built the project under Source directory.

+2  A: 

You cannot use dynamic libraries on iPhone (outside of Apple's frameworks, of course). All libraries must be statically linked.

Ben Gottlieb
+3  A: 

IPhone does not allow loading dynamic libraries. The external library/framework you are using must be build as a static library and compiled into your app during build time.

In order to make that happen first you need to create a static library version of GDATA:

  • Add a new target to the GData project (say GDataIPhoneLibrary)

    • You do this by right-clicking Target and selecting "Add New Target". In the Dialog select the static library template from the IPhoneOS - Cocoa Touch section.
  • Then you need to drag the source .m files to the Compile Sources section of the target. (Make sure not to drag the .h files, otherwise you will get warnings.) Also if you are just building for the Picasa then the file under Command and Photos groups should be sufficient. Also do not add the unit tests and the test tool groups.

  • Next go to the Frameworks and Libraries group under the project and add the Foundation framework which is the necessary framework for Cocoa Touch. When you are adding this make sure to only check your newly created target for this to be used. (You don't want to mess up the Mac version of GData)

  • Now under the Targets, select the GDataIPhoneLibrary you created and click on the (i) button (or just double click it)

  • Under the Build tab search for "header" and once you locate the "Header Search Paths" add the following (for libxml2) as the header path

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/usr/include/libxml2

  • Now you close the dialog.

  • Select your Active Target to be GDataIPhoneLibrary

  • Set your ActiveSDK to Project-> SetActiveSDK -> Simulator - IPhone OS 2.1

  • Now you are ready to go -> just hit build and you will have the default libGDataIPhoneLibrary.a file.

Now you can add this static library to your IPhone application:

  • Go to your own application project and select the target (you probably have one) and double click it to open the dialog.

  • In the Build tab search for "library" and once you find "Library Search Paths" add the path to that library that you just built in the previous step.

  • Then add "-lGDataIPhoneLibrary" (omitting lib prefix and .a extension) to the "Other Linker Flags" option (which you can find by searching linker in the search box.

Now this should hopefully build. Hope this works for you.

Cheers, Kerem

keremk
A: 

It appears the problem still there. I am still seeing the message: dyld: Library not loaded: @loader_path/../Frameworks/GData.framework/Versions/A/GData Referenced from: /Users/jacksu/Library/Application Support/iPhone Simulator/User/Applications/92876150-CB3E-407D-8346-C2A04A90E815/PicasaTest.app/PicasaTest Reason: image not found

If I remove GData.framework, I got compilation error. I added it, but seems it don't know how to link the framework to the static libary.

My static library at /Users/jacksu/Downloads/gdata-objectivec-client/Source/build/Debug-iphonesimulator/libGDataStatic.a

and I set LibrarySearchPaths to: /Users/jacksu/Downloads/gdata-objectivec-client/Source/build/Debug-iphonesimulator/

In Other Linker Flag

I have "-lGDataStatic -lxml2"

The error message in console: dyld: Library not loaded: @loader_path/../Frameworks/GData.framework/Versions/A/GData Referenced from: /Users/jacksu/Library/Application Support/iPhone Simulator/User/Applications/169625A1-8AAB-46E7-9652-C129F182FD43/PicasaTest.app/PicasaTest Reason: image not found

Thanks

BlueDolphin
+1  A: 

If you keep the GData.framework, then you need to make sure that it is not a required framework but rather a weak framework. A weak framework means, the app will not require it when first launched and only try to load it when a function call to the framework is referenced, but in your case since the library is statically compiled functions that are called will be resolved without a need to load the framework. (Note objective C messages are function calls in runtime...)

To do that try the below:

  • Double click your application target (as before)

  • Look at the General tab this time

  • Find the GData.framework and change it from "Required" to "Weak"

You are probably getting compile errors without adding the framework because the GDATA header files are not being resolved. You could have also put a link to the "header files" in "Header Search Path" Than you won't need to add the framework at all.

Unrelated to the above, I forgot one more thing previously. Add -ObjC to your "Other Linker Flag".

keremk