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

时间:2015-06-04 22:44:45

标签: 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步的困境。为方便起见,我在这里重新输入:

  

您的项目需要包含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文件中的import语句会导致问题。我正在关注他们的SDK的Google的文档,所以我想知道这是否是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文件。这是个坏主意吗?
  5. 仅供参考:我正在使用从其Github存储库中克隆的Google代码,以排除代码中的任何问题。即使在一个干净的项目上我也会遇到同样的问题。我正在使用Xcode v.6.3.1。

    -Rommel。

1 个答案:

答案 0 :(得分:2)

我想出了我的问题。 Google API ServiceGenerator会生成一系列文件实现和头文件,Google文档声明这些文件将添加到您的项目中。不幸的是,它还会生成一个带有冲突的import语句的_Sources.m文件。我从iOS项目中删除了此文件,并且项目已成功构建。