ios - 重复符号 Apple Mach-O 链接器错误

标签 ios objective-c xcode swift google-app-engine

我正在尝试在 iOS Swift 项目中使用 Google Endpoints。

我在 Python 中创建了 Hello World Endpoints 项目,并根据 https://cloud.google.com/appengine/docs/python/endpoints/ 在 AppEngine 上对其进行了设置

我正在按照这些说明在我的项目中进行设置:https://cloud.google.com/appengine/docs/python/endpoints/consume_ios#Python_Adding_required_files_to_your_iOS_project 我也在使用 Google+ API。

我卡在了上面的第 3 步。为了方便起见,我在这里重新输入:

Your project needs to include the foo.h & foo_Sources.m files generated from ServiceGenerator, which you ran previously, where foo is your API name. Disabling ARC is not required for these files.

在 XCode 中,我转到添加文件并添加 .h 和 .m 文件。我还修改了桥接 header 文件,并编辑了build设置 header 搜索路径以包含正确的路径。

当我尝试构建时,出现此错误:

Ld /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/WISE normal armv7
    cd /Users/rommelrico/Documents/GitHub/github.sandiego.edu/Mobile/WISEMobile
    export IPHONEOS_DEPLOYMENT_TARGET=8.1
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.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 armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -L/Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Products/Debug-iphoneos -F/Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Products/Debug-iphoneos -F/Users/rommelrico/Documents/GitHub/github.sandiego.edu/Mobile/WISEMobile -filelist /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/WISE.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -dead_strip -ObjC -v -fobjc-arc -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -Xlinker -add_ast_path -Xlinker /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/WISE.swiftmodule -miphoneos-version-min=8.1 -framework QuartzCore -framework UIKit -framework SystemConfiguration -framework Security -framework MediaPlayer -framework CoreText -framework GooglePlus -framework CoreGraphics -framework CoreMotion -framework CoreLocation -framework Foundation -framework AssetsLibrary -framework GoogleOpenSource -framework AddressBook -Xlinker -dependency_info -Xlinker /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/WISE_dependency_info.dat -o /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/WISE

Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: arm-apple-darwin14.3.0
Thread model: posix
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch armv7 -dead_strip -iphoneos_version_min 8.1.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -ObjC -o /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/WISE -L/Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Products/Debug-iphoneos -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -filelist /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/WISE.LinkFileList -rpath @executable_path/Frameworks -add_ast_path /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/WISE.swiftmodule -framework QuartzCore -framework UIKit -framework SystemConfiguration -framework Security -framework MediaPlayer -framework CoreText -framework GooglePlus -framework CoreGraphics -framework CoreMotion -framework CoreLocation -framework Foundation -framework AssetsLibrary -framework GoogleOpenSource -framework AddressBook -dependency_info /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/WISE_dependency_info.dat -framework Foundation -lobjc -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0/lib/darwin/libclang_rt.ios.a -F/Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Products/Debug-iphoneos -F/Users/rommelrico/Documents/GitHub/github.sandiego.edu/Mobile/WISEMobile
duplicate symbol _OBJC_METACLASS_$_GTLHelloworldHelloGreeting in:
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLHelloworldHelloGreeting.o
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLHelloworld_Sources.o
duplicate symbol _OBJC_CLASS_$_GTLHelloworldHelloGreeting in:
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLHelloworldHelloGreeting.o
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLHelloworld_Sources.o
duplicate symbol _OBJC_CLASS_$_GTLServiceHelloworld in:
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLHelloworld_Sources.o
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLServiceHelloworld.o
duplicate symbol _OBJC_METACLASS_$_GTLServiceHelloworld in:
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLHelloworld_Sources.o
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLServiceHelloworld.o
duplicate symbol _OBJC_METACLASS_$_GTLQueryHelloworld in:
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLHelloworld_Sources.o
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLQueryHelloworld.o
duplicate symbol _OBJC_CLASS_$_GTLQueryHelloworld in:
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLHelloworld_Sources.o
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLQueryHelloworld.o
duplicate symbol _OBJC_METACLASS_$_GTLHelloworldHelloGreetingCollection in:
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLHelloworld_Sources.o
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLHelloworldHelloGreetingCollection.o
duplicate symbol _OBJC_CLASS_$_GTLHelloworldHelloGreetingCollection in:
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLHelloworld_Sources.o
    /Users/rommelrico/Library/Developer/Xcode/DerivedData/WISE-cscxdkqblzamtvezakprtiqcthrm/Build/Intermediates/WISE.build/Debug-iphoneos/WISE.build/Objects-normal/armv7/GTLHelloworldHelloGreetingCollection.o
ld: 9 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我的观察:

看起来 .m 文件中的导入语句导致了问题。我一直在关注 Google 的 SDK 文档,所以我想知道这是否是 Swift/Objective-C 的限制。不过,我确实看到有人能够在 Github 上进行设置:https://github.com/soundTricker/swift-cloud-endpoint-sample

这是我的问题:

  1. 为什么说“架构 armv7 的 9 个重复符号”?我正在数 8 个“重复符号”错误消息...
  2. 我在哪里添加“-v”以查看调用?
  3. 那些 .o 文件是什么?我需要修复的 9 个重复符号到底是什么?
  4. 我正在考虑一种解决此问题的方法,即根据我的 Google Endpoints API 文件创建一个框架。这样,我只能在我的项目中包含 .h 文件。这是个坏主意吗?

仅供引用:我使用的是完全从其 Github 存储库中克隆的 Google 代码,只是为了排除我的代码存在的任何问题。即使在一个干净的项目中,我也会遇到同样的问题。我正在使用 Xcode v.6.3.1。

-隆美尔。

最佳答案

我想出了我的问题。 Google API ServiceGenerator 生成一堆文件实现和头文件,Google 文档指出要将其添加到您的项目中。不幸的是,它还会生成一个包含冲突导入语句的 _Sources.m 文件。我从我的 iOS 项目中删除了这个文件,项目构建成功。

关于ios - 重复符号 Apple Mach-O 链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30655475/

相关文章:

ios - UISwitch 滞后

objective-c - iOS 初始化静态对象的成员失败

c++ - OpenCV从2D像素获取3D坐标

ios - 如何在 ios SWIFT 4.0 中使用 ttf/SVG 图标

ios - 根据一组有序字符串对 NSStrings 的 NSArray 进行排序

ios - iOS Swift 3 中来自对象的 JSON 存在数组问题

iOS 暗模式 - 图像 Assets 未重绘

iOS WKWebView - 无法添加 socket ,只能操作

iphone - iPhone 4 丢失后多久搜索一次数据服务?

ios - 如何在 UILabel 中点击单词