I have tried to integrate the Picasa API on iphone, compiles fine, but I am seeing the following error in launch.
我试图在iphone上集成Picasa API,编译得很好,但我发现启动时出现以下错误。
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
dyld:未加载库:@loader_path /../ Frameworks / GData.framework / Versions / A / GData参考自:/ Users / jacksu / Library / Application Support / iPhone Simulator / User / Applications / 9A7E3F54-022F-4771-BD6A -E458F5545144 / PicasaTest.app / PicasaTest原因:找不到图像
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.
我从Source / build / Debug / GData.framework导入了GDataFramework。我在Source目录下构建了项目。
3 个解决方案
#1
3
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...)
如果你保留GData.framework,那么你需要确保它不是一个必需的框架,而是一个弱框架。弱框架意味着,应用程序在首次启动时不需要它,并且仅在引用对框架的函数调用时尝试加载它,但在您的情况下,因为库是静态编译的,所以调用的函数将在不需要的情况下解析加载框架。 (注意目标C消息是运行时的函数调用...)
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"
找到GData.framework并将其从“Required”更改为“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.
您可能在没有添加框架的情况下收到编译错误,因为GDATA头文件未被解析。您也可以在“标题搜索路径”中添加“头文件”链接,而不需要添加框架。
Unrelated to the above, I forgot one more thing previously. Add -ObjC to your "Other Linker Flag".
与上述无关,我之前忘记了一件事。将-ObjC添加到“其他链接器标志”。
#2
3
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.
IPhone不允许加载动态库。您正在使用的外部库/框架必须构建为静态库,并在构建期间编译到您的应用程序中。
In order to make that happen first you need to create a static library version of GDATA:
为了首先实现这一点,您需要创建GDATA的静态库版本:
-
Add a new target to the GData project (say GDataIPhoneLibrary)
向GData项目添加新目标(比如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.
您可以通过右键单击“目标”并选择“添加新目标”来执行此操作。在对话框中,从IPhoneOS - Cocoa Touch部分选择静态库模板。
-
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.
然后,您需要将源.m文件拖到目标的Compile Sources部分。 (确保不要拖动.h文件,否则会收到警告。)此外,如果您只是为Picasa构建,那么命令和照片组下的文件就足够了。也不要添加单元测试和测试工具组。
-
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)
接下来转到项目下的Frameworks and Libraries组,并添加Foundation框架,这是Cocoa Touch的必要框架。当您添加此项时,请确保仅检查新创建的目标以供使用。 (你不想弄乱Mac版的GData)
-
Now under the Targets, select the GDataIPhoneLibrary you created and click on the (i) button (or just double click it)
现在在Targets下,选择您创建的GDataIPhoneLibrary并单击(i)按钮(或只需双击它)
-
Under the Build tab search for "header" and once you locate the "Header Search Paths" add the following (for libxml2) as the header path
在Build选项卡下搜索“header”,找到“Header Search Paths”后,添加以下内容(对于libxml2)作为标题路径
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/usr/include/libxml2
-
Now you close the dialog.
现在关闭对话框。
-
Select your Active Target to be GDataIPhoneLibrary
选择您的活动目标为GDataIPhoneLibrary
-
Set your ActiveSDK to Project-> SetActiveSDK -> Simulator - IPhone OS 2.1
将ActiveSDK设置为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.
现在你准备好了 - >只需点击构建,你将拥有默认的libGDataIPhoneLibrary.a文件。
Now you can add this static library to your IPhone application:
现在您可以将此静态库添加到您的IPhone应用程序:
-
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.
然后将“-lGDataIPhoneLibrary”(省略lib前缀和.a扩展名)添加到“Other Linker Flags”选项(您可以通过在搜索框中搜索链接器找到该选项)。
Now this should hopefully build. Hope this works for you.
现在这应该有希望建立。希望这对你有用。
Cheers, Kerem
#3
2
You cannot use dynamic libraries on iPhone (outside of Apple's frameworks, of course). All libraries must be statically linked.
您无法在iPhone上使用动态库(当然,在Apple的框架之外)。所有库必须静态链接。
#1
3
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...)
如果你保留GData.framework,那么你需要确保它不是一个必需的框架,而是一个弱框架。弱框架意味着,应用程序在首次启动时不需要它,并且仅在引用对框架的函数调用时尝试加载它,但在您的情况下,因为库是静态编译的,所以调用的函数将在不需要的情况下解析加载框架。 (注意目标C消息是运行时的函数调用...)
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"
找到GData.framework并将其从“Required”更改为“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.
您可能在没有添加框架的情况下收到编译错误,因为GDATA头文件未被解析。您也可以在“标题搜索路径”中添加“头文件”链接,而不需要添加框架。
Unrelated to the above, I forgot one more thing previously. Add -ObjC to your "Other Linker Flag".
与上述无关,我之前忘记了一件事。将-ObjC添加到“其他链接器标志”。
#2
3
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.
IPhone不允许加载动态库。您正在使用的外部库/框架必须构建为静态库,并在构建期间编译到您的应用程序中。
In order to make that happen first you need to create a static library version of GDATA:
为了首先实现这一点,您需要创建GDATA的静态库版本:
-
Add a new target to the GData project (say GDataIPhoneLibrary)
向GData项目添加新目标(比如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.
您可以通过右键单击“目标”并选择“添加新目标”来执行此操作。在对话框中,从IPhoneOS - Cocoa Touch部分选择静态库模板。
-
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.
然后,您需要将源.m文件拖到目标的Compile Sources部分。 (确保不要拖动.h文件,否则会收到警告。)此外,如果您只是为Picasa构建,那么命令和照片组下的文件就足够了。也不要添加单元测试和测试工具组。
-
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)
接下来转到项目下的Frameworks and Libraries组,并添加Foundation框架,这是Cocoa Touch的必要框架。当您添加此项时,请确保仅检查新创建的目标以供使用。 (你不想弄乱Mac版的GData)
-
Now under the Targets, select the GDataIPhoneLibrary you created and click on the (i) button (or just double click it)
现在在Targets下,选择您创建的GDataIPhoneLibrary并单击(i)按钮(或只需双击它)
-
Under the Build tab search for "header" and once you locate the "Header Search Paths" add the following (for libxml2) as the header path
在Build选项卡下搜索“header”,找到“Header Search Paths”后,添加以下内容(对于libxml2)作为标题路径
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/usr/include/libxml2
-
Now you close the dialog.
现在关闭对话框。
-
Select your Active Target to be GDataIPhoneLibrary
选择您的活动目标为GDataIPhoneLibrary
-
Set your ActiveSDK to Project-> SetActiveSDK -> Simulator - IPhone OS 2.1
将ActiveSDK设置为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.
现在你准备好了 - >只需点击构建,你将拥有默认的libGDataIPhoneLibrary.a文件。
Now you can add this static library to your IPhone application:
现在您可以将此静态库添加到您的IPhone应用程序:
-
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.
然后将“-lGDataIPhoneLibrary”(省略lib前缀和.a扩展名)添加到“Other Linker Flags”选项(您可以通过在搜索框中搜索链接器找到该选项)。
Now this should hopefully build. Hope this works for you.
现在这应该有希望建立。希望这对你有用。
Cheers, Kerem
#3
2
You cannot use dynamic libraries on iPhone (outside of Apple's frameworks, of course). All libraries must be statically linked.
您无法在iPhone上使用动态库(当然,在Apple的框架之外)。所有库必须静态链接。