Xcode 5.1 ld: 找不到-lGoogleAnalyticsServices库

9
今天我把Xcode升级到了Xcode 5.1版本,现在每次尝试在模拟器上编译并测试我的代码时,都会遇到关于体系结构86_64和Google Analytics Services Library的几个错误。
以下是我遇到的错误内容:
Ld /Users/prelite/Library/Developer/Xcode/DerivedData/iSanMarino-hkgasucjnyttlxcbtgqjjpcxutzx/Build/Products/Debug-iphonesimulator/iSanMarino.app/iSanMarino normal x86_64
    cd "/Users/prelite/Desktop/iSanMarino 3.0"
    export IPHONEOS_DEPLOYMENT_TARGET=7.0
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -L/Users/prelite/Library/Developer/Xcode/DerivedData/iSanMarino-hkgasucjnyttlxcbtgqjjpcxutzx/Build/Products/Debug-iphonesimulator -L/Users/prelite/Desktop/iSanMarino\ 3.0/iSanMarino/Analytics -F/Users/prelite/Library/Developer/Xcode/DerivedData/iSanMarino-hkgasucjnyttlxcbtgqjjpcxutzx/Build/Products/Debug-iphonesimulator -filelist /Users/prelite/Library/Developer/Xcode/DerivedData/iSanMarino-hkgasucjnyttlxcbtgqjjpcxutzx/Build/Intermediates/iSanMarino.build/Debug-iphonesimulator/iSanMarino.build/Objects-normal/x86_64/iSanMarino.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -lGoogleAnalyticsServices -framework AudioToolbox -framework CoreData -framework QuartzCore -framework SystemConfiguration -lsqlite3 -framework EventKitUI -framework EventKit -framework CoreLocation -framework MessageUI -framework MapKit -framework UIKit -framework Foundation -framework CoreGraphics -Xlinker -dependency_info -Xlinker /Users/prelite/Library/Developer/Xcode/DerivedData/iSanMarino-hkgasucjnyttlxcbtgqjjpcxutzx/Build/Intermediates/iSanMarino.build/Debug-iphonesimulator/iSanMarino.build/Objects-normal/x86_64/iSanMarino_dependency_info.dat -o /Users/prelite/Library/Developer/Xcode/DerivedData/iSanMarino-hkgasucjnyttlxcbtgqjjpcxutzx/Build/Products/Debug-iphonesimulator/iSanMarino.app/iSanMarino

Undefined symbols for architecture x86_64:
  "_deflate", referenced from:
      +[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
  "_deflateEnd", referenced from:
      +[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
  "_deflateInit2_", referenced from:
      +[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
  "_inflate", referenced from:
      +[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
  "_inflateEnd", referenced from:
      +[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
  "_inflateInit2_", referenced from:
      +[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我也更新了Google Analytics库,尝试删除并重新添加它,但没有效果。


我下载了一个新版本3.03c,进行了清理和构建,一切都恢复正常了。我猜你的旧库(就像我的一样)不支持这些架构。这是URL https://developers.google.com/analytics/devguides/collection/ios/resources - DBD
我已经尝试过了,我删除了所有的.m和.h以及框架文件...然后重新添加了3.03c的所有文件,进行了一次清理,但是什么也没有改变...也许问题出在“构建设置”上...你在“搜索路径”和“有效架构”上设置了什么? - prelite
将目标更改为ïOSDevice解决了我的问题。对于模拟器,它不起作用。奇怪。 - Nirav
2个回答

42

解决方案:我只需添加 libz.dylib 框架,一切都正常工作了!


1
谢谢。这节省了我很多时间。V3不向后兼容真的很烦人。而且新方法需要更多的编码才能完成与之前版本相同的事情。请接受您自己的答案作为正确答案。 - Ray

-1
如果您加载 .xcodeproj 文件并尝试构建,则会出现此错误。 相反,请打开包含的 .xcworkspace,然后一切都会很好。
要么选择“打开其他”并从您的项目目录中选择它,要么从项目目录中的命令提示符:
open <YourProjectName>.xcworkspace

不应该需要其他依赖项。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接