这个问题快把我逼疯了,我想不出怎么解决它.

    Undefined symbols for architecture armv7:
  "_deflateEnd", referenced from:
      -[ASIDataCompressor closeStream] in ASIDataCompressor.o
  "_OBJC_CLASS_$_ASIDataDecompressor", referenced from:
      objc-class-ref in ASIHTTPRequest.o
  "_deflate", referenced from:
      -[ASIDataCompressor compressBytes:length:error:shouldFinish:] in ASIDataCompressor.o
  "_deflateInit2_", referenced from:
      -[ASIDataCompressor setupStream] in ASIDataCompressor.o
ld: symbol(s) not found for architecture armv7
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

我想这跟:

ld: symbol(s) not found for architecture armv7

但我补充说:libz.1.2.3.dylib,但这没有帮助,有人有什么 idea 吗?

推荐答案

常见原因

"架构ARMv7未定义符号"的常见原因是:

  1. import a header and do not link against the correct library岁.这是很常见的,尤其是像QuartzCore这样的库的标题,因为默认情况下它不包括在项目中.要解决:

    • 101.100部分添加正确的库

    • If you want to add a library outside of the default search path you can include the path in the Library Search Paths value in the Build Settings and add
      -l{library_name_without_lib_and_suffix} (eg. for libz.a use -lz) to the Other Linker Flags section of Build Settings.

  2. copy files into your project but forgot to check the target to add the files to块.要解决问题,请执行以下操作:

    • Open the Build Phases for the correct target, expand Compile Sources and add the missing .m files. If this is your issue please upvote Cortex's answer below as well.

  3. include a static library that is built for another architecture喜欢i386,它是您主机上的模拟器.要解决问题,请执行以下操作:

    • 如果您有多个库供应商提供的库文件要包含在项目中,则需要包含一个用于模拟器(i386)的文件和一个用于设备(例如armv7)的文件.

    • 或者,您可以创建包含这两种体系 struct 的fat static library.



原始答案:

您没有链接到正确的libz文件.如果您右键单击该文件并在Finder中显示其路径应该在IOS SDK文件夹中的某个位置.举个例子,这是我的

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib

我建议删除该引用,然后将其重新添加回目标的"将二进制文件与库链接"部分的构建阶段.

Ios相关问答推荐

如何使用参与者允许并行读取,但阻止对SWIFT中资源的并发读取和写入?

IOS-获取本地化系统映像

NSHashTable要求任何MyCustomProtocolAnyObject都是类类型

在 SwiftUI 中以编程方式插入内嵌图像

多协议和类继承混乱,Swift

如何在 SwiftUI 中通过通用 @ObservedObject 进行切换?

长按 SwiftUI 更改项目的顺序

ITMS-90725 无用的错误信息,因为它自相矛盾,苹果上传

在向我的 struct 添加属性后获取线程 10:EXC_BAD_ACCESS (code=EXC_I386_GPFLT)

如何判断 `NSManagedObject` 是否已被删除?

iOS 8 - 使用自定义演示关闭视图控制器后屏幕空白

UITableView 页脚,停止浮动内容

以编程方式获取故事板 ID?

如何比较两个 UIImage 对象

导航控制器自定义过渡动画

用 PC 调试 ipad safari

判断可选数组是否为空

如何在 UILabel 中找到文本子字符串的 CGRect?

Swift 中的日期到毫秒和回溯到日期

Xcode中的终端窗口?