0

I've come across an error in a project in Xcode. I've been making good progress, and everything has been working reasonably well up until now. After making a few subtle layout changes to one of the pages in my app, when trying to run it - I get a mach-o linker error stating multiple (266!) duplicate symbols.

So far, I have:

  • Been through the code multiple times to ensure I haven't imported any .m files (I haven't)
  • Ensured no declarations in header files (there aren't)
  • Checked for duplicated symbols in different classes within the app, even within .m files which shouldn't be shared (there aren't any)
  • Cleaned the project (no joy)
  • Restarted Xcode
  • Tried running on multiple simulators and real devices (same error persists)
  • Deleting the derived data (thanks for the tip Reinhard, as below in comments) - by opening the organiser (Window --> Organiser (shift-cmd-2) --> projects --> delete derived data). Unfortunately error recurs, even after cleaning and rebuilding.
  • Checked the .pch (precompiled header) file, which is in the supporting files folder in the project navigator - still no joy!

I've looked at a number of similar posts, on this and other sites, and by far the majority of errors seem to be when people import a implementation file. When I've had similar errors in the past, they've been fairly easy to solve with going through the code - usually it's been duplicated variables in differing classes. This time, I've done my best to encapsulate things as well as possible, and I haven't had this issue on this project so far.

I'll post the error message here for now. The code is now posted on GitHub at https://github.com/bentaylor42/iRSI, as it's too long to fit on this page.

    Ld /Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Products/Debug-iphonesimulator/irsi.app/irsi normal i386
cd "/Users/bentaylor/Dropbox/iRSI v2/irsi"
export IPHONEOS_DEPLOYMENT_TARGET=7.1
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 i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -L/Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Products/Debug-iphonesimulator -F/Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Products/Debug-iphonesimulator -filelist /Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Intermediates/irsi.build/Debug-iphonesimulator/irsi.build/Objects-normal/i386/irsi.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.1 -framework AudioToolbox -framework AVFoundation -framework QuartzCore -framework CoreGraphics -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker /Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Intermediates/irsi.build/Debug-iphonesimulator/irsi.build/Objects-normal/i386/irsi_dependency_info.dat -o /Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Products/Debug-iphonesimulator/irsi.app/irsi

duplicate symbol _OBJC_IVAR_$_MainMenuViewController._labelVersion in:
/Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Intermediates/irsi.build/Debug-iphonesimulator/irsi.build/Objects-normal/i386/MainMenuViewController-9C9455DB49A1DC98.o
duplicate symbol _OBJC_IVAR_$_MainMenuViewController._labelCopyright in:
/Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Intermediates/irsi.build/Debug-iphonesimulator/irsi.build/Objects-normal/i386/MainMenuViewController-9C9455DB49A1DC98.o
duplicate symbol _OBJC_IVAR_$_MainMenuViewController._switchPHEM in:
/Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Intermediates/irsi.build/Debug-iphonesimulator/irsi.build/Objects-normal/i386/MainMenuViewController-9C9455DB49A1DC98.o
duplicate symbol _OBJC_IVAR_$_MainMenuViewController._labelPHEM in:
/Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Intermediates/irsi.build/Debug-iphonesimulator/irsi.build/Objects-normal/i386/MainMenuViewController-9C9455DB49A1DC98.o

//... and so on, for 266 duplicated symbols, across multiple classes throughout the app)

ld: 266 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
docBen
  • 39
  • 7
  • If you're up for it, post your project on GitHub, and I'll try to identify the error. – michaelsnowden Aug 10 '14 at 19:58
  • 1
    Open the organizer window (Xcode -> Window -> Organizer) and choose Derived Data -> Delete. Then try to rebuild your project... – Reinhard Männer Aug 10 '14 at 20:17
  • Thanks for the feedback so far. the code is now posted on GitHub at https://github.com/bentaylor42/iRSI. I've tried deleting the derived data in organiser, unfortunately without success – docBen Aug 10 '14 at 20:31
  • 1
    did you check for precompiled header (.PCH) file in supporting files group? did you add anything extra to it? – Can Poyrazoğlu Aug 10 '14 at 20:39
  • also, can you also post the project file (xcodeproj) too to git? – Can Poyrazoğlu Aug 10 '14 at 20:41
  • Code should be back up on GitHub now - I realised I had created my repository in a child folder of the project, missing out some of the key files (including xcodeproj). When I tried to change it, I ended up being unable to reupload the repo, which I've finally sorted! The .pch file looks pretty boring on the whole. I haven't edited it and it only imports UIKit, Foundation and Availability – docBen Aug 10 '14 at 21:51

1 Answers1

1

You have many duplicate .m files in Compile Sources, remove them from your target named "irsi", after that, you should compile successfully. enter image description here

Btw I think you also should remove the duplicate references from your projects, I have listed some of them in the picture below.

enter image description here

KudoCC
  • 6,912
  • 1
  • 24
  • 53
  • Thank you! This has worked well. It looks like I 'added' the irsi folder containing all of the files when trying to add an image file - the minor layout issue which caused the crash! This duplicated all of the files, which were then compiled at build leading to the mach-o error. My reputation is too low to up-vote you, but thank you very very much! Simply removing the irsi file from images fixed the problem – docBen Aug 10 '14 at 22:24