2

I am having trouble with a set of mystery linker errors. My regular target and UITest targets build and execute fine, but the UnitTest target always fails with the error below. Seems to be some sort of issue with CoreData, but I can't figure out why it errors on the test target and not in the main target. I've tried: 1) clearing the derived data. 2) restarting xCode 3) clean install of pods

Any help about where to look for the problem would be much appreciated. I'm stumped. Thanks!

Undefined symbols for architecture x86_64:
  "direct field offset for playolaIphone.AppDelegate.(managedObjectModel.storage in _D550B33DB84959D9A74FD87E48EB7BC7) : __ObjC.NSManagedObjectModel?", referenced from:
      playolaIphone.AppDelegate.managedObjectModel.setter : __ObjC.NSManagedObjectModel in MockAppDelegate.o
      playolaIphone.AppDelegate.(managedObjectModel.materializeForSet : __ObjC.NSManagedObjectModel).(closure #1) in MockAppDelegate.o
  "direct field offset for playolaIphone.AppDelegate.(managedObjectContext.storage in _D550B33DB84959D9A74FD87E48EB7BC7) : __ObjC.NSManagedObjectContext?", referenced from:
      playolaIphone.AppDelegate.managedObjectContext.setter : __ObjC.NSManagedObjectContext in MockAppDelegate.o
      playolaIphone.AppDelegate.(managedObjectContext.materializeForSet : __ObjC.NSManagedObjectContext).(closure #1) in MockAppDelegate.o
  "direct field offset for playolaIphone.AppDelegate.(persistentStoreCoordinator.storage in _D550B33DB84959D9A74FD87E48EB7BC7) : __ObjC.NSPersistentStoreCoordinator?", referenced from:
      playolaIphone.AppDelegate.persistentStoreCoordinator.setter : __ObjC.NSPersistentStoreCoordinator in MockAppDelegate.o
      playolaIphone.AppDelegate.(persistentStoreCoordinator.materializeForSet : __ObjC.NSPersistentStoreCoordinator).(closure #1) in MockAppDelegate.o
  "direct field offset for playolaIphone.AppDelegate.(applicationDocumentsDirectory.storage in _D550B33DB84959D9A74FD87E48EB7BC7) : Foundation.URL?", referenced from:
      playolaIphone.AppDelegate.applicationDocumentsDirectory.setter : Foundation.URL in MockAppDelegate.o
      playolaIphone.AppDelegate.(applicationDocumentsDirectory.materializeForSet : Foundation.URL).(closure #1) in MockAppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
lonesomewhistle
  • 796
  • 1
  • 9
  • 20

1 Answers1

7

By going through my commit item-by-item, I tracked it down to a SWIFT_WHOLE_MODULE_OPTIMIZATION flag. Deleting this setting from the project fixed it. I have no idea why but I figure I'll leave this up in case it helps somebody.

lonesomewhistle
  • 796
  • 1
  • 9
  • 20
  • Because of the optimization there are more checks needed, which can detect issues that will not appear without it. So basically the code has bugs that can lead to unexpected behaviour for the release app – thibaut noah May 31 '17 at 12:36