简体   繁体   English

iOS 4.3.5上静态库中未找到符号错误

[英]Symbol not found error from static library on iOS 4.3.5

I'm seeing this error on an iOS 4.3.5 handset where my app has been installed via an ad hoc deployment (downloaded over HTTP): 我在iOS 4.3.5手机上看到此错误,我的应用程序已通过临时部署(通过HTTP下载)安装:

Dyld Error Message: Dyld错误消息:

  Symbol not found: _OBJC_CLASS_$_NSJSONSerialization
  Expected in: /System/Library/Frameworks/Foundation.framework/Foundation

My code in the app doesn't call iOS 5 libraries unless a class has been shown to exist (ie if(NSClassFromString(@"NSJSONSerialization")!=nil ) so the issue isn't that calls are being made to iOS 5 libraries on an iOS 4 device. 应用程序中的代码不会调用iOS 5库,除非已经显示存在类(即if(NSClassFromString(@"NSJSONSerialization")!=nil )所以问题不在于调用iOS 5库在iOS 4设备上。

The app itself contains a static library which is my own code, and is where the NSJSONSerialization references exist. 应用程序本身包含一个静态库,它是我自己的代码,是存在NSJSONSerialization引用的地方。

The app works perfectly on the iOS 4.3 device if run directly from xcode (ie the iPhone attached to the development machine via USB cable). 如果直接从xcode(即通过USB线连接到开发机器的iPhone)运行,该应用程序在iOS 4.3设备上完美运行。 However, when run on the same device via the adhoc deployment, I see the crash. 但是,当通过adhoc部署在同一设备上运行时,我会看到崩溃。

The adhoc archive is built via Product->Archive in xcode 4 , and then I use the 'Distribute' button to create the Ad-Hoc deployment .ipa file. adhoc存档是通过xcode 4 Product->Archive构建的,然后我使用'Distribute'按钮创建Ad-Hoc部署.ipa文件。

The app crashes almost instantly, leaving me to think that perhaps none of my code is being called at all, and that it's my Archive build settings that may be incorrect here? 该应用程序几乎立即崩溃,让我觉得可能根本没有调用我的代码,这是我的存档构建设置可能在这里不正确?

Many thanks in advance for any time spent helping! 非常感谢您提供帮助的任何时间!

This sounds like the exact same issue I ran into in this answer . 这听起来像我在这个答案中遇到的完全相同的问题。 There's something slightly different about the way that weak linking is being handled when dealing with static libraries on building and archiving vs. direct installation via Xcode. 在构建和归档处理静态库与通过Xcode直接安装时处理弱链接的方式略有不同。 The latter seems to handle class- and function-level weak linking as it should (since Xcode 4.3). 后者似乎应该处理类和功能级弱链接(因为Xcode 4.3)。 However, when archiving a project containing a static library, that weak linking is not being used correctly. 但是,在归档包含静态库的项目时,未正确使用该弱链接。

In my case, I needed to manually weak link the problematic iOS framework in the application using my static library in order for it to work when building for ad hoc or App Store distribution. 在我的情况下,我需要使用我的静态库手动弱连接应用程序中有问题的iOS框架,以便在构建ad hoc或App Store分发时使用它。 To do this, go to your project's build settings, go to the Build Phases tab, and expand the Link Binary With Libraries grouping. 要执行此操作,请转到项目的构建设置,转到“构建阶段”选项卡,然后展开“使用库链接二进制”分组。 Find the offending framework (in my case it was CoreVideo.framework, but it sounds like you may need to do this for Foundation.framework) and change it from Required to Optional. 找到有问题的框架(在我的例子中是CoreVideo.framework,但听起来你可能需要为Foundation.framework执行此操作)并将其从Required更改为Optional。

This should clear up your weak-linking issue. 这应该清除你的弱连接问题。 I'm investigating this further to see if there's a build setting I'm missing or if this is a linker bug. 我正在进一步研究这个问题,看看是否存在我缺少的构建设置或者这是否是链接器错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM