【问题标题】:Duplicate symbols Apple Mach-O Linker Error重复符号 Apple Mach-O 链接器错误
【发布时间】:2015-06-04 22:44:45
【问题描述】:

我正在尝试在 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 步。为方便起见,我在这里重新输入:

您的项目需要包含 foo.h 和 foo_Sources.m 文件 从之前运行的 ServiceGenerator 生成,其中 foo 是您的 API 名称。这些文件不需要禁用 ARC。

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

当我尝试构建时,我收到此错误:

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。

-隆美尔。

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2014-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-06
      • 2023-03-30
      • 1970-01-01
      相关资源
      最近更新 更多