I am trying to use the PLDatabase framework in my iPhone app. I've added the framework to my Xcode project. However, when I run my app, it crashes with the following error:
我想在我的iPhone应用程序中使用PLDatabase框架。我已经将框架添加到我的Xcode项目中。但是,当我运行我的应用程序时,它崩溃并出现以下错误:
dyld: Library not loaded: @loader_path/../Frameworks/PlausibleDatabase.framework/Versions/A/PlausibleDatabase
Referenced from: /Users/todd/Library/Application Support/iPhone Simulator/User/Applications/BB3C66B2-A5BB-4329-B163-AB0072411AF1/Congress.app/Congress
Reason: image not found
I'm not sure exactly where the Framework needs to reside on disk to be found.
我不确定框架需要驻留在磁盘上的确切位置。
Thanks
3 个解决方案
#1
iPhone does not support dynamic linking of embedded frameworks. While you might be able to finagle the simulator to work, it will not work on the device. If you want to use the code you must build the static library for the framework (libpldatabase.a), and then link them to the app.
iPhone不支持嵌入式框架的动态链接。虽然您可能能够使模拟器工作,但它无法在设备上运行。如果要使用代码,则必须为框架(libpldatabase.a)构建静态库,然后将它们链接到应用程序。
The Xcode GUI does not provide a nice interface for static linking, you will need to add appropriate flags in your build prefs (-lpldatabase -L/whatever/dir/it/is/in).
Xcode GUI没有为静态链接提供良好的接口,您需要在构建首选项中添加适当的标志(-lpldatabase -L / whatever / dir / it / is / in)。
#2
It's not actually strictly true that the iPhone doesn't support dynamic linking. What is true is that applications installed by the App Store are unable to dynamically link.
iPhone不支持动态链接实际上并不完全正确。真实情况是App Store安装的应用程序无法动态链接。
The app store / ituned installs programs into the /private/var/mobile/... directory. Any program opened that lives in that subdirectory is chrooted and has certain rights stripped away when opened. The chrooted processes can't fork, they can't run in the background, they can't load dynamic libraries and they can't save files outside of their little protected areas of the disk (with the exception of photos to the photo directory).
app store / ituned将程序安装到/ private / var / mobile / ...目录中。生活在该子目录中的任何程序都是chrooted,并且在打开时会剥离某些权限。 chrooted进程不能fork,它们不能在后台运行,它们无法加载动态库,也无法将文件保存在磁盘的小保护区域之外(照片到照片目录除外) )。
That said, the iPhone runs a modern operating system that supports dynamic linking just fine. The act of 'jailbreaking' is actually installing a program outside the chroot jail that can then do things like fork and save files to other places on the disk and load dynamic code.
也就是说,iPhone运行一个现代操作系统,支持动态链接就好了。 “越狱”的行为实际上是在chroot jail之外安装一个程序,然后可以执行fork和将文件保存到磁盘上的其他位置并加载动态代码。
Apple (and the open iPhone community) has plenty of programs running on the phone (such as the MobilePhone, Mobile Safari and SpringBoard applications) that can run in the background and load libraries. They are placed in a different place on the disk (/private/var/stash/Applications often).
Apple(以及开放的iPhone社区)在手机上运行了大量程序(例如MobilePhone,Mobile Safari和SpringBoard应用程序),这些程序可以在后台运行并加载库。它们放在磁盘上的不同位置(/ private / var / stash / Applications经常)。
So... if you want to sell your app in the app store, you can't load a dynamic library. Which for most people means you can't load it at all. But if you want to distribute your app through cydia (a common jailbroken phone app installer), then you can get away with jailbreaking the phone and loading your dynaamic library. In fact, due to the itunes install process being the culprit, as you've learned, you cant even load a dylib from your own app that you write to you own phone... unless you jailbreak.
所以...如果您想在应用商店中销售您的应用,则无法加载动态库。对大多数人来说意味着你根本无法加载它。但是如果你想通过cydia(一个常见的越狱手机应用程序安装程序)分发你的应用程序,那么你可以通过越狱手机和加载你的动态图书馆来逃脱。事实上,由于itunes安装过程是罪魁祸首,正如您所了解的那样,您甚至无法从您自己的应用程序中加载一个dylib,您可以将其写入自己的手机......除非您越狱。
#3
RE @mipadi: ZeroLink was removed in Xcode 3.1 and does not exist for the iPhone SDK. The correct answer is Louis'; the iPhone does not support dynamically-loaded frameworks in developer-created applications.
RE @mipadi:在Xcode 3.1中删除了ZeroLink,而iPhone SDK则不存在。正确的答案是路易斯; iPhone不支持在开发人员创建的应用程序中动态加载框架。
Xcode does have a good user interface for static libraries; just drag them into the project and they're added to the link phase. No need to fuss with linker flags. The problem comes when you need to use the headers supplied with those static libs (then you need to add the header search paths manually) or when a static lib conflicts with an available dylib (that's when you have to add the -l flag manually).
Xcode确实有一个很好的静态库用户界面;只需将它们拖入项目中,它们就会被添加到链接阶段。不需要对链接器标志大惊小怪。当您需要使用随这些静态库提供的头文件(然后您需要手动添加头部搜索路径)或静态库与可用的dylib冲突时(当您必须手动添加-l标志时) 。
#1
iPhone does not support dynamic linking of embedded frameworks. While you might be able to finagle the simulator to work, it will not work on the device. If you want to use the code you must build the static library for the framework (libpldatabase.a), and then link them to the app.
iPhone不支持嵌入式框架的动态链接。虽然您可能能够使模拟器工作,但它无法在设备上运行。如果要使用代码,则必须为框架(libpldatabase.a)构建静态库,然后将它们链接到应用程序。
The Xcode GUI does not provide a nice interface for static linking, you will need to add appropriate flags in your build prefs (-lpldatabase -L/whatever/dir/it/is/in).
Xcode GUI没有为静态链接提供良好的接口,您需要在构建首选项中添加适当的标志(-lpldatabase -L / whatever / dir / it / is / in)。
#2
It's not actually strictly true that the iPhone doesn't support dynamic linking. What is true is that applications installed by the App Store are unable to dynamically link.
iPhone不支持动态链接实际上并不完全正确。真实情况是App Store安装的应用程序无法动态链接。
The app store / ituned installs programs into the /private/var/mobile/... directory. Any program opened that lives in that subdirectory is chrooted and has certain rights stripped away when opened. The chrooted processes can't fork, they can't run in the background, they can't load dynamic libraries and they can't save files outside of their little protected areas of the disk (with the exception of photos to the photo directory).
app store / ituned将程序安装到/ private / var / mobile / ...目录中。生活在该子目录中的任何程序都是chrooted,并且在打开时会剥离某些权限。 chrooted进程不能fork,它们不能在后台运行,它们无法加载动态库,也无法将文件保存在磁盘的小保护区域之外(照片到照片目录除外) )。
That said, the iPhone runs a modern operating system that supports dynamic linking just fine. The act of 'jailbreaking' is actually installing a program outside the chroot jail that can then do things like fork and save files to other places on the disk and load dynamic code.
也就是说,iPhone运行一个现代操作系统,支持动态链接就好了。 “越狱”的行为实际上是在chroot jail之外安装一个程序,然后可以执行fork和将文件保存到磁盘上的其他位置并加载动态代码。
Apple (and the open iPhone community) has plenty of programs running on the phone (such as the MobilePhone, Mobile Safari and SpringBoard applications) that can run in the background and load libraries. They are placed in a different place on the disk (/private/var/stash/Applications often).
Apple(以及开放的iPhone社区)在手机上运行了大量程序(例如MobilePhone,Mobile Safari和SpringBoard应用程序),这些程序可以在后台运行并加载库。它们放在磁盘上的不同位置(/ private / var / stash / Applications经常)。
So... if you want to sell your app in the app store, you can't load a dynamic library. Which for most people means you can't load it at all. But if you want to distribute your app through cydia (a common jailbroken phone app installer), then you can get away with jailbreaking the phone and loading your dynaamic library. In fact, due to the itunes install process being the culprit, as you've learned, you cant even load a dylib from your own app that you write to you own phone... unless you jailbreak.
所以...如果您想在应用商店中销售您的应用,则无法加载动态库。对大多数人来说意味着你根本无法加载它。但是如果你想通过cydia(一个常见的越狱手机应用程序安装程序)分发你的应用程序,那么你可以通过越狱手机和加载你的动态图书馆来逃脱。事实上,由于itunes安装过程是罪魁祸首,正如您所了解的那样,您甚至无法从您自己的应用程序中加载一个dylib,您可以将其写入自己的手机......除非您越狱。
#3
RE @mipadi: ZeroLink was removed in Xcode 3.1 and does not exist for the iPhone SDK. The correct answer is Louis'; the iPhone does not support dynamically-loaded frameworks in developer-created applications.
RE @mipadi:在Xcode 3.1中删除了ZeroLink,而iPhone SDK则不存在。正确的答案是路易斯; iPhone不支持在开发人员创建的应用程序中动态加载框架。
Xcode does have a good user interface for static libraries; just drag them into the project and they're added to the link phase. No need to fuss with linker flags. The problem comes when you need to use the headers supplied with those static libs (then you need to add the header search paths manually) or when a static lib conflicts with an available dylib (that's when you have to add the -l flag manually).
Xcode确实有一个很好的静态库用户界面;只需将它们拖入项目中,它们就会被添加到链接阶段。不需要对链接器标志大惊小怪。当您需要使用随这些静态库提供的头文件(然后您需要手动添加头部搜索路径)或静态库与可用的dylib冲突时(当您必须手动添加-l标志时) 。