这个问题快把我逼疯了,我不知道怎么解决它。

    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并没有帮助,有人有什么想法吗?


当前回答

如果你正在处理iOS5升级,我发现要编译一个目标4.3的项目,我可以将libz.1.2.3重命名。dynlib的项目导航到libz.1.2.5。Dynlib和它编译。

我的iPhoneOS50SDK/usr/lib文件夹没有libz.1.2.3。Dynlib——不知道它是测试版还是自然升级。

其他回答

如果您在释放模式下构建您的Flutter项目时遇到了这个问题-这对我有帮助:

Set your build system to New Build System in File > Project Settings… delete folders ios and build_ios from your project folder. create ios module by executing flutter create . from your project folder. open Xcode and: set the IOS Deployment Target to at least 9.0 in PROJECT > Runner check your Signing & Capabilities make sure your Build Configuration is set to Release in Edit Scheme... and build for Generic iOS Device execute pod install from your project folder execute flutter pub get from your project folder

现在打开你的Xcode并构建或存档它:Product > build(或archive)

另一个可能导致“未定义符号”链接错误的原因是试图从.mm文件调用C函数。在这种情况下,您需要使用extern“C”{…}当您导入头文件时。

从objective - c++调用C-Function链接器错误

我也有类似的问题。在_OBJC_CLASS_$_后面的类名实际上是我的类。原因是我没有勾选“添加到目标”,当我拖动源代码文件到导航列表。

我的解决方案是:

从导航列表中删除类,并选择“仅删除引用” 再次拖动源代码文件,并确保“添加到目标”复选框被勾选。复选框就在“需要时复制”和“创建组”下面。

在我的例子中,我添加了一个必须使用Objective c++的框架。我找到了这个帖子:

XCode .m vs. mm

这说明了主要的。M需要重命名为main。mm,这样objective - c++类也可以被编译。

这为我解决了问题。

尝试实现派生类的至少一个非内联函数。如果不这样做,链接器可能会避免为该类创建类型信息。