42

All of a sudden Xcode threw me this error at compilation time:

Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_Format", referenced from:
 objc-class-ref in WOExerciseListViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

After doing some research, I may understand that a library I'm using is not compatible with 64 bit version. But this is very strange since I've been working with the same libraries for at least a week without having a single compilation problem during that time. The two libraries are just composed of a bunch of classes, and when I removed them from my project I got the same issue. Since I have never created libraries myself, I have no idea how I can find wether the ones I'm using are compatible with 64 bit (?) I also tried the following changes for architectures under the target panel :

  • added $(ARCHS_STANDARD_INCLUDING_64_BIT) to the Architectures
  • build active architecture only -> set to 'NO'
  • for 'valid architectures' -> set to arm64, armv7 and armv7s
  • deleted the DerivedData folder and its contents, cleaned and built again

But none of these changes work. Please, does someone have a clue on this? Thanks

batistomorrow
  • 674
  • 1
  • 6
  • 13
  • you changed or moved the file "WOExerciseListViewController" in your xcode – Anbu.Karthik Oct 25 '14 at 08:16
  • Ultimately if you want to know the architecture and contents of the library then you'll need to use `file`, `lipo`, `nm` and `ar` to investigate. – Droppy Oct 25 '14 at 09:02
  • I removed all references to these 3rd party classes from my code, but I still get the same issue: "undefined symbols for architecture i386" and same thing for architecture x86_64. @Droppy I'm a newbie, when I say 'library' I mean a folder with some classes (.m and .h) files that I imported from CocoaPods. Is there any .a file related to these classes, or am I totally misunderstanding the meaning of library here? I also tried to simply drag the classes without using cocoaPods, same issue. – batistomorrow Oct 25 '14 at 09:53

13 Answers13

46

Apparently, your class "Format" is involved in the problem. Check your declaration of this class, especially if you did it inside another class you probably forgot the @implementation or something similar.

Community
  • 1
  • 1
Banane
  • 755
  • 9
  • 10
  • 2
    Indeed, I had forgotten to declare an @ implementation just below my @ interface Format in WOExerciseListViewController.m I was so focused on this library compatibility topic that I would never have thought about this! Thanks – batistomorrow Oct 25 '14 at 12:52
  • I was following Apple's Cocoa Tutorial here: https://developer.apple.com/library/mac/referencelibrary/GettingStarted/RoadMapOSX/books/RM_YourFirstApp_Mac/Articles/GettingStarted.html, where you develop an app called TrackMix, and I was getting the same error as the op after adding the files for a Track class. The tutorial says, *The files should now be located in your project’s TrackMix group folder. If you look at the files, you’ll see that stub class interface and implementation declarations are provided for you.* But that was not the case for me... – 7stud Apr 11 '15 at 19:00
  • I had to create both files by hand, and Track.m did not have a *stub implementation*. After reading your answer, I added `@implementation Track` and on the next line `@end ` to Track.m, and the error went away. Thanks! – 7stud Apr 11 '15 at 19:04
  • It looks like the problem can be avoided at the outset by choosing: File>New>File, then selecting OS X, then `Cocoa Class` (rather than Objective-C file). That will create both Track.m and Track.h and provide the stubs inside those files. – 7stud Apr 11 '15 at 19:24
  • I am facing the same problem and i have checked for @implementation stuff but i can see that all are fine, not able to figure out that how can i fix it? any help will be appreciated. – Satish Mavani Mar 16 '17 at 18:19
  • I had a little bit different root cause for the similar issue. Somebody messed up the project file and for some architectures, file references were broken. I had to remove the file from the project and add it again. – Sergey Dryganets Jan 12 '18 at 21:58
  • Thanks "especially if you did it inside another class you probably forgot the @implementation or something similar." worked for me. I forget to enter the implementation. – Saleh Enam Shohag Dec 15 '18 at 18:13
44

Check if that file is included in Build Phases -> Compiled Sources

user3894518
  • 677
  • 5
  • 10
  • This is what did it for me when I got this error in a today extension, trying to use code files that were in the main bundle. – SolidSnake4444 Mar 20 '15 at 03:25
  • Yep, you may had "lost" the file during a merge. In my case it turned out, that the file known throughout the project file by id 2BA85A8D...48CD was referenced while building as 2BA85A8E...48CD. Therefore, the file was visible and navigatable in Xcode, but unavailable when compiling/linking. – Andrey Solovyov Jan 11 '19 at 09:24
20

Make sure the WOExerciseListViewController is a Target Member; that worked for me!

enter image description here

Youssef Gamil
  • 256
  • 2
  • 12
  • Oddly this seemed to have worked for me. But first I had to uncheck and then recheck the Target Membership checkbox. – vhs May 09 '15 at 04:43
  • The file was not checked for a target. It helped. Thanks! – Oleh H Aug 03 '20 at 10:24
4

Yes, I think the library you are using is not compatible with 64 bit version but you can solve the problem -

Just navigate to Build Settings>Architectures & replace $(ARCHS_STANDARD) to $(ARCHS_STANDARD_32_BIT)

So that your xcode build your project with 32 bit supported version.

Nishant Mahajan
  • 264
  • 4
  • 9
4

I just had this error when I opened a (quite) old project, created in Xcode 4~ish, in Xcode 6.4. While the linked Frameworks were visible in the Project sidebar, I overlooked that there were no linked libraries in the Target Build Phases tab. Once I fixed that, it compiled fine.

ricardopereira
  • 11,118
  • 5
  • 63
  • 81
auco
  • 9,329
  • 4
  • 47
  • 54
  • This did it for me, was trying to include 'libTimeSquare.a', from [Square's TimesSquare calendar component](https://github.com/puls/objc-TimesSquare). For the record, I was trying to integrate it from a Cocoapod entry. – Big Rich Nov 03 '15 at 01:49
3

It turned out I forgot to write my @implementation part.

chengbo
  • 5,789
  • 4
  • 27
  • 41
2

I simply wasn't linking the libraries in the "Link Binary with Libraries" section.

Alberto M
  • 1,608
  • 1
  • 18
  • 42
1

I solved the same issue by going to Xcode Build Settings and in Architectures, I changed the Xcode 6.1.1 standard architecture to:-

$(ARCHS_STANDARD_32_BIT)

Hemanshu Liya
  • 611
  • 6
  • 10
  • 3
    This is not a valid fix since apple has forced developer to use $ARCHS_STANDARD architecture for 64 bit. Also, $(ARCHS_STANDARD_32_BIT) is longer available. – Jayprakash Dubey Jun 04 '15 at 07:47
  • 2
    Agreed! But when you are testing and you don't understand that the bug is actually with 32-bit/64-bit architecture. Using my above answer can save a lot of time in debugging. – Hemanshu Liya Jun 06 '15 at 17:11
1

I just had the exact same error, and solved it by restarting xcode.

For me the issue occurred after an svn update, the file in question was added to the projects folder, but it never appeared in xcode(9.3.1) – until I restarted it.

Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188
Seif Meddeb
  • 112
  • 2
  • 9
0

Same error when I copied/pasted a class and forgot to rename it in .m file.

zeeawan
  • 6,667
  • 2
  • 50
  • 56
0

I solved the problem by deleting reference to the file and adding it again in project. In my case it works.

-2

this setting worked for me:

  • Architectures=$(ARCHS_STANDARD_32_BIT)
  • Build Active Architecture Only:YES
  • Valid Architectures armv6 armv7 armv7s arm64
Shilpi Agrawal
  • 595
  • 3
  • 11
  • 26
issam
  • 697
  • 1
  • 9
  • 15
-3

Delete the $(ARCHS_STANDARD) and add the $(ARCHS_STANDARD_32_BIT).

enter image description here

Enamul Hassan
  • 5,266
  • 23
  • 39
  • 56
Koppi
  • 37
  • 7