我的应用程序在10.7上运行并经过测试,但后来意识到我需要它才能在早期版本上运行。不幸的是,我从一开始就用ARC开始了这个项目。
现在我的构建设置是debug base sdk:10.7,并且release base sdk:10.6。当我尝试存档我的应用时,我收到以下错误:
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)
这看起来像ARC的一个问题,但我不知道从哪里开始修复它。有什么建议?感谢。
答案 0 :(得分:10)
您需要将SDK设置为10.7 - 但您可以将部署目标设置为10.6。虽然在这个问题中详细说明了一些注意事项:How to deploy to Snow Leopard with ARC enabled
答案 1 :(得分:3)
我今天遇到同样的信息时遇到了这个问题。我将SDK设置为10.7,部署目标设置为10.6,但仍然看到此消息。
我的项目主要是使用现有的手动保留释放代码,只有几个使用ARC的新文件。因此,我在主目标设置中禁用了ARC ,并通过将-fobjc-arc
添加到每个文件的构建设置(在构建阶段下),为这两个文件选择性地启用了它。
在预感中,我在目标中启用了ARC,然后在每个文件设置中失败(删除了两个文件的标志,并将-fno-objc-arc
添加到所有其他文件中)并且不再获得动态链接错误10.6。