CocoaLumberjack 错误:找不到符号:_objc_storeStrong
我对 iOS 开发比较陌生,正在尝试实现 CocoaLumberjack 日志记录。
我从 https://github.com/robbiehanson/CocoaLumberjack 下载了最新的源代码,其中包含了所需的我的项目中的文件,进行了必要的代码更改,并收到下面的运行时链接器错误。
环境为 Xcode 4.2 Build 4C199,项目 Target 设置为 Device=iPad,DeploymentTarget=4.3。该项目最初是使用保留/释放编写的,因此我按原样保留原始源代码,为我正在使用的 Lumberjack 文件添加编译器标志“-fobjc-arc”:DDFileLogger.m、DDLog.m 和 DDTTYLogger.m 。
控制台输出为:
GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Fri Sep 16 06:56:50 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys001
sharedlibrary apply-load-rules all
target remote-mobile /tmp/.XcodeGDBRemote-10996-56
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
[Switching to process 11779 thread 0x2e03]
[Switching to process 11779 thread 0x2e03]
dyld: lazy symbol binding failed: Symbol not found: _objc_storeStrong
Referenced from: /var/mobile/Applications/32E4EEB9-765E-4C72-83C8-F5707253AA99/Demo.app/Demo
Expected in: /usr/lib/libobjc.A.dylib
dyld: Symbol not found: _objc_storeStrong
Referenced from: /var/mobile/Applications/32E4EEB9-765E-4C72-83C8-F5707253AA99/Demo.app/Demo
Expected in: /usr/lib/libobjc.A.dylib
warning: Attempting to create USE_BLOCK_IN_FRAME variable with block that isn't in the frame.
(gdb)
我的项目初始化环境如下,其中 fileLogger 是相应 AppDelegate.h 文件中定义的实例变量:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
/*
* Configure the Lumberjack logging framework (we'll use it instead of NSLog)
*/
// the TTY logger is the Xcode console
[DDLog addLogger:[DDTTYLogger sharedInstance]];
// we'll also use a file logger
fileLogger = [[DDFileLogger alloc] init];
fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
[DDLog addLogger:fileLogger];
// Override point for customization after application launch.
DDLogInfo(@"didFinishLaunchingWithOptions: entered");
// create instance of the view controller
MainViewController *aViewController = [[MainViewController alloc]
initWithNibName:@"MainView" bundle:nil];
self.mainViewController = aViewController; // same as: [self setMainViewController:aViewController];
[aViewController release];
// Add the main view controller's view to the window and display.
self.window.rootViewController = self.mainViewController;
[self.window makeKeyAndVisible];
return YES;
}
有没有人遇到过这个问题,并知道解决方案或解决方法?我正在做的事情是否可能......在项目中混合 ARC 和非 ARC 文件?
I'm relatively new to iOS development, and am trying to implement CocoaLumberjack logging.
I downloaded the latest source from https://github.com/robbiehanson/CocoaLumberjack, have included the required files in my project, made the necessary code changes, and am getting the run-time linker error that follows below.
The environment is Xcode 4.2 Build 4C199, with the project Target set to Device=iPad and DeploymentTarget=4.3. The project was initially written using retain/release, so I left the original source as-is, adding the compiler flag "-fobjc-arc" for the Lumberjack files I'm using: DDFileLogger.m, DDLog.m and DDTTYLogger.m.
The console output is:
GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Fri Sep 16 06:56:50 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys001
sharedlibrary apply-load-rules all
target remote-mobile /tmp/.XcodeGDBRemote-10996-56
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
[Switching to process 11779 thread 0x2e03]
[Switching to process 11779 thread 0x2e03]
dyld: lazy symbol binding failed: Symbol not found: _objc_storeStrong
Referenced from: /var/mobile/Applications/32E4EEB9-765E-4C72-83C8-F5707253AA99/Demo.app/Demo
Expected in: /usr/lib/libobjc.A.dylib
dyld: Symbol not found: _objc_storeStrong
Referenced from: /var/mobile/Applications/32E4EEB9-765E-4C72-83C8-F5707253AA99/Demo.app/Demo
Expected in: /usr/lib/libobjc.A.dylib
warning: Attempting to create USE_BLOCK_IN_FRAME variable with block that isn't in the frame.
(gdb)
My project initializes the environment as follows, where fileLogger is an instance variable defined in the corresponding AppDelegate.h file:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
/*
* Configure the Lumberjack logging framework (we'll use it instead of NSLog)
*/
// the TTY logger is the Xcode console
[DDLog addLogger:[DDTTYLogger sharedInstance]];
// we'll also use a file logger
fileLogger = [[DDFileLogger alloc] init];
fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
[DDLog addLogger:fileLogger];
// Override point for customization after application launch.
DDLogInfo(@"didFinishLaunchingWithOptions: entered");
// create instance of the view controller
MainViewController *aViewController = [[MainViewController alloc]
initWithNibName:@"MainView" bundle:nil];
self.mainViewController = aViewController; // same as: [self setMainViewController:aViewController];
[aViewController release];
// Add the main view controller's view to the window and display.
self.window.rootViewController = self.mainViewController;
[self.window makeKeyAndVisible];
return YES;
}
Has anyone encountered this problem, and know of a solution or workaround? Is what I'm doing even possible... having mixed ARC and non-ARC files in a project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了将来的参考,这似乎是当前 Xcode 工具链的一个缺点,当当前构建的目标关闭了 ARC 支持(并使用启用 ARC 的静态库)时,它似乎忘记包含 ARC 库。您可以使用
-fobjc-arc
标志轻松强制链接器包含该库,请参阅此相关问题 以获得完整的描述。For future reference, this seems to be a shortcoming of the current Xcode toolchain that seems to forget to include the ARC library when the currently built target has the ARC support turned off (and uses ARC-enabled static libraries). You can easily force the linker to include the library using the
-fobjc-arc
flag, see this related question for a complete description.我刚刚收到一位 CocoaLumberjack 开发人员的回复,他是这样说的:
编辑:来自开发人员的其他信息:
I just heard back from one of the CocoaLumberjack developers, this is what he said:
EDIT: Additional information from the developer: