0

I just started working with xCode and Objective C.

I created a project with an storyboard and implemented my entire program into the view-Controller. I wanted to put some of this code now into a different m-file wich I simply include and call methods from my new m-file in the view controller.

My problem is that I get not linker-errors every time I try to build it.

The error code is

1 duplicate symbol for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What could cause this?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Nerethar
  • 327
  • 2
  • 16
  • 1
    possible duplicate of [xcode 5 ld: 11 duplicate symbols for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)](http://stackoverflow.com/questions/19553067/xcode-5-ld-11-duplicate-symbols-for-architecture-armv7-clang-error-linker-com) – Ricky May 08 '14 at 13:36

3 Answers3

0

You can't have multiple .m files for one .h file. You need to either:

  1. Keep all the code in the original .m file.
  2. Create a new class with it's own .h file.
  3. Create a category for the original class. (https://developer.apple.com/library/mac/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html)

Make sure you only have one @interface and one @implementation declaration for each class.

henryeverett
  • 813
  • 5
  • 21
  • I made an entirely new m-file with its own h-file ;) I never though people would even create multiple m-files for one h-file^^ – Nerethar May 08 '14 at 13:38
  • Make sure then that you haven't accidentally copied over the name of the cold class in your @interface/@implementation declarations. – henryeverett May 08 '14 at 13:41
0

I found my problem.

I happened to implement the same variable as global in two m-files.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Nerethar
  • 327
  • 2
  • 16
0

This error is due to you have a duplicate symbol somewhere. Check this link this will helpful for you

http://iphonedevsdk.com/forum/iphone-sdk-development/115858-apple-mach-o-linker-error.html

Simpalm
  • 1
  • 5