Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARC error when deploying to 10.6

I have my app running and tested on 10.7 but later realized that I needed it to work on earlier versions as well. And unfortunately, I started this project with ARC on from the very beginning.

Now my build setup is debug base sdk: 10.7, and release base sdk: 10.6. And when I try to archive my app, I got the following error:

Undefined symbols for architecture x86_64:
"_objc_retain", referenced from:
  +[__ARCLite__ load] in libarclite_macosx.a(arclite.o)
  -[AppDelegate applicationDidFinishLaunching:] in AppDelegate.o
  -[AppDelegate managedObjectModel] in AppDelegate.o
  -[AppDelegate persistentStoreCoordinator] in AppDelegate.o
  -[AppDelegate managedObjectContext] in AppDelegate.o
  -[AppDelegate windowWillReturnUndoManager:] in AppDelegate.o
  -[AppDelegate saveAction:] in AppDelegate.o
  ...
 (maybe you meant: _objc_retainedObject)
"_objc_release", referenced from:
  -[AppDelegate applicationDidFinishLaunching:] in AppDelegate.o
  -[AppDelegate applicationFilesDirectory] in AppDelegate.o
  -[AppDelegate managedObjectModel] in AppDelegate.o
  -[AppDelegate persistentStoreCoordinator] in AppDelegate.o
  -[AppDelegate managedObjectContext] in AppDelegate.o
  -[AppDelegate windowWillReturnUndoManager:] in AppDelegate.o
  -[AppDelegate saveAction:] in AppDelegate.o
  ...
"_objc_retainAutoreleasedReturnValue", referenced from:
  -[AppDelegate applicationFilesDirectory] in AppDelegate.o
  -[AppDelegate managedObjectModel] in AppDelegate.o
  -[AppDelegate persistentStoreCoordinator] in AppDelegate.o
  -[AppDelegate managedObjectContext] in AppDelegate.o
  -[AppDelegate windowWillReturnUndoManager:] in AppDelegate.o
  -[AppDelegate saveAction:] in AppDelegate.o
  -[AppDelegate applicationShouldTerminate:] in AppDelegate.o
  ...
"_objc_autoreleaseReturnValue", referenced from:
  -[AppDelegate applicationFilesDirectory] in AppDelegate.o
  -[AppDelegate managedObjectModel] in AppDelegate.o
  -[AppDelegate persistentStoreCoordinator] in AppDelegate.o
  -[AppDelegate managedObjectContext] in AppDelegate.o
  -[AppDelegate windowWillReturnUndoManager:] in AppDelegate.o
  -[MainWindowController viewForTag:] in MainWindowController.o
  -[MainWindowController tableView:objectValueForTableColumn:row:] in MainWindowController.o
  ...
"_objc_storeStrong", referenced from:
  -[AppDelegate persistentStoreCoordinator] in AppDelegate.o
  -[AppDelegate saveAction:] in AppDelegate.o
  -[AppDelegate applicationShouldTerminate:] in AppDelegate.o
  -[AppDelegate .cxx_destruct] in AppDelegate.o
  -[MainWindowController init] in MainWindowController.o
  -[MainWindowController viewForTag:] in MainWindowController.o
  -[MainWindowController showUserFinderView:] in MainWindowController.o
  ...
"_objc_retainAutoreleaseReturnValue", referenced from:
  +[MainWindowController sharedInstance] in MainWindowController.o
  -[FileMetaData getFileName] in FileMetaData.o
  -[FileMetaData getLastHash] in FileMetaData.o
  -[FileMetaData getCreationDate] in FileMetaData.o
  -[FileMetaData getLastModified] in FileMetaData.oe
  -[FileMetaData getLocalPath] in FileMetaData.o
  ...
"_objc_autorelease", referenced from:
  -[SBJsonParser objectWithString:error:] in SBJsonParser.o
  -[SBJsonTokeniser getStringToken:] in SBJsonTokeniser.o
  -[SBJsonTokeniser getNumberToken:] in SBJsonTokeniser.o
  -[SBJsonUTF8Stream getRetainedStringFragment:] in SBJsonUTF8Stream.o
  -[SBJsonWriter stringWithObject:error:] in SBJsonWriter.o
"_objc_retainAutorelease", referenced from:
  -[SBJsonTokeniser getStringToken:] in SBJsonTokeniser.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It looks like an issue with ARC, but I have no clue where to start on fixing this. Any suggestions? Thanks.

like image 828
Robert Kang Avatar asked Jan 16 '12 15:01

Robert Kang


2 Answers

You need to set the SDK to 10.7 - but you can set the Deployment target to 10.6. There are some caveats though detailed in this question: How to deploy to Snow Leopard with ARC enabled

like image 199
dtuckernet Avatar answered Nov 15 '22 08:11

dtuckernet


I came across this question when I hit the same message today. I had the SDK set to 10.7 and the deployment target set to 10.6, but was still seeing this message.

My project was mostly using existing manual retain–release code, with only a couple of new files using ARC. Accordingly, I had ARC disabled in the main target settings, and had selectively enabled it for the two files by adding -fobjc-arc to the per-file build settings (under Build Phases).

On a hunch, I enabled ARC in the target, and then flopped the per-file settings (removing the flag for the two files, and adding -fno-objc-arc to all the others) and no longer got the dynamic link error on 10.6.

like image 38
jmah Avatar answered Nov 15 '22 08:11

jmah