Duplicate Symbol Error in Objective-C build?

前端 未结 17 1849
礼貌的吻别
礼貌的吻别 2020-11-27 14:12

I got this error when I press build+debug:

ld: duplicate symbol .objc_class_name_BlogTableItemCell in /Users/fabian/Development/Workspaces/iphone_experiments         


        
相关标签:
17条回答
  • 2020-11-27 14:52

    In may case, I followed some instructions to build a newer version of Subversion which directed me to create this symbolic link:

    ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain
    

    Now I'm really a Windows guy so it wasn't immediately obvious to me - but removing the link fixed it for me (after restarting XCode):

    rm /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain
    

    Phew.

    (The actual error I got was the one described here: build error duplicate symbols arclite.o)

    0 讨论(0)
  • 2020-11-27 14:53

    By mistake the source file was included twice in the Project -> Build Phase -> Compile Sources. Removing one of them solved the problem.

    0 讨论(0)
  • 2020-11-27 14:54

    Make sure that you didn't import .m File . For me this happen I added #import "SchoolCommuterHome.m" instead of #import "SchoolCommuterHome.h"

    0 讨论(0)
  • 2020-11-27 14:56

    The most common reason for this error is importing an xyz.m file instead of the xyz.h file. Check if your imports contain something like #import "----.m"

    0 讨论(0)
  • 2020-11-27 15:01

    For me, changing 'No Common Blocks' from Yes to No ( under Targets->Build Settings->Apple LLVM - Code Generation ) enter image description here

    0 讨论(0)
  • 2020-11-27 15:07

    Just to add; Using Xcode to generate subclassed managed objects (Core Data) can sometimes duplicate the generated files. For me the fix was to delete the generated files and re-generate them.

    0 讨论(0)
提交回复
热议问题