iPhone 设备上的静态库
我有两个项目,一个 Cocoa iPhone 应用程序和一个它使用的静态库。
我已经在 iPhone 模拟器上成功测试了它,但是当我尝试将其部署到我的 iPhone 设备时,我收到(未找到符号)链接错误。
如果我删除了库的依赖性,则项目可以正常构建/运行。
我已确保所有构建设置都设置为 iPhoneOS 而不是模拟器。
我确信这很简单,但是有人在从 iPhone 模拟器转移到设备时遇到过类似的问题吗?
--编辑:我已经成功创建了新项目(一个用于应用程序,一个用于静态库),并成功让它们在 iPhone 或模拟器上运行。 但我有一个非常奇怪的问题...对于每个特定项目,我无法让它同时适用于设备和模拟器...我已经仔细检查了构建设置,确保引用的库适用于匹配的构建设置(我相信)但我无法解决这些链接错误。
我想我一定做错了什么......所有苹果文档都说“它超级简单 - 一键点击”,但这给我带来了很多问题。
这可能与 xCode 构建设置有关,但我似乎无法理解为什么选择不同的构建平台并重建库不起作用。
I have two projects, a Cocoa iPhone application and a static library which it uses.
I've tested it successfully on the iPhone simulator, but when I try to deploy it to my iPhone device I get (symbol not found) link errors.
If I remove the dependancy of the library the project builds/runs fine.
I have made sure all the build settings are set to iPhoneOS not the simulator.
Im sure its something simple, but has anyone run into similar problems moving from iPhone simulator to device?
--EDIT: I have managed to create new projects (one for the application and one for the static library), and successfully get them to run on the iPhone or simulator. But I have a very strange problem... for each specific project I cannot get it working for BOTH the device and the simulator... I have double checked the build settings, made sure the libraries that are being references are for the matching build settings (I believe) but I cannot resolve these linking errors.
I think I must be doing something very wrong... all the apple documentation says 'its super simple - one click' but this is giving me a lot of problems.
This is probably something to do with xCode build settings, but I cannot seem to understand why selecting the different build platforms and rebuilding the libraries does not work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看我对类似问题的回答链接到可能有帮助的文章。 有一个链接到一篇有趣的文章。
Check out my answer to a similar question for a link to an article that might help. There is a link to an interesting article.
最终我意识到问题是什么。
我将设备目标从模拟器更改为 iPhone 设备,然后删除旧的(模拟器)静态库并附加新的(设备)库。
一切都很好,除了库搜索路径(在构建配置中)仍然首先列出了模拟器目录,我认为这会导致找到并使用它而不是设备。
这也解释了为什么我能够使每个设置适用于新项目,但在设置之间进行更改时却遇到困难。
这是一个简单而愚蠢的问题,但却给我带来了一些悲伤和时间。 我仍然不确定如何正确设置目标相关的构建设置,但至少如果有人遇到类似的问题,则需要注意。
Eventually I realised what the problem was.
I changed my device target from simulator to iPhone device, then removed the old (simulator) static library and attached the new (device) library.
All fine, except the library search path (in the build configurations) still had the simulator directory listed first, which I assume cause it to be found and used rather than the device.
This also explains why I was able to make each setting work with a new project, but only had trouble changing between settings.
Its a simple and stupid problem, but one that caused me some grief and time. Im still not sure how to properly set target dependent build settings but at least if anyone is getting similar problems its something to look out for.
我已经创建了一个关于如何创建和使用静态库的完整教程,本教程涵盖了苹果也建议的方法,也许人们会发现它有用:
http://www.sodeso.nl/?p=822
这种方法的优点是它会根据你的项目设置自动重新编译库(所以不需要设备/模拟器构建出现问题)
I've created a complete tutorial on how to create and use static libraries, this tutorial covers the the method that is also advised by apple, maybe people will find it usefull:
http://www.sodeso.nl/?p=822
Advantages of this methods is that it automatically recompiles the library according to your project settings (so no trouble with device / simulator builds)