Xcode 9 undefined symbols for architecture x86_64

Viewed 13733

after switching to Xcode 9 I am getting errors, it looks like this.

enter image description here

I blanked the project and classes names, but there is a list of classess ending with .o suffix. In Xcode 8.3.2 everything works. I got 2 projects, one is library that is building without problems. Another project is test app, that is pointing to the library by :path directive in Podfile. In both projects build settings -> architectures is set to standard arichitectures, build active architectures only is set to DEBUG: Yes, RELEASE: No. Have you come across this problem? Thanks upfront for the help.

4 Answers

Ran into similar problem. Just post it here in case it can help anyone.

Was using class AbcService from a framework (written in Swift 3 and by ourselves) in our app's Objective-c class B. After upgrading from Xcode8/Swift3 to Xcode9/Swift4 it failed to build an archive for the release config, due to Undefined symbols error of this class during linking:

Undefined symbols for architecture arm64:
   "_OBJC_CLASS_$__TtC15XxxabcServices17AbcService", referenced from:

The weird thing is, it worked fine to archive the debug config, and for running in emulator.

Spent almost 1 day to find out the root cause: the Swift class AbcService in the framework was missing a public modifier.

Simple trick here: Go -> Go To Folder "/Library/Developer/Xcode" delete Derived data next clean your project then Run .

Since you are using Cocoapods you most likely need to update those.

That means you need to do a pod update on the command line inside your project's directory and then rebuild your project in Xcode.

In general when using a new major version of Xcode it is necessary to rebuild all components. Your error message is telling you that the object files you already have (the *.o files are basically what the compiler produces out of your source files) are not compatible with newly compiled object files (the linker which is complaining in your case has the purpose of combining or 'linking' together all the object files).

It might sometimes be necessary to clean your derived data (the stuff Xcode caches). You can do this by going to Xcode's Product menu and while holding down the Option/Alt key, pick the menu item 'clean build folder'.

When I ran build for profiling, it was working, but with classic build there were mentioned errors. After searching through logs it seems there is some weird behaviour with flags, particularly -fprofile-instr-generate. The solution was to set flag Enable Code Coverage to No in build settings of the library project. This was shooting into the dark but somehow got it working.

Related