我对iOS开发比较陌生,我正在尝试实现CocoaLumberjack日志记录。
我从https://github.com/robbiehanson/CocoaLumberjack下载了最新的源代码,在我的项目中包含了所需的文件,进行了必要的代码更改,并且得到了下面的运行时链接器错误。
环境是Xcode 4.2 Build 4C199,项目Target设置为Device = iPad,DeploymentTarget = 4.3。该项目最初使用retain / release编写,因此我按原样保留原始源代码,为我正在使用的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文件?
答案 0 :(得分:8)
为了将来参考,这似乎是当前Xcode工具链的一个缺点,当前构建的目标关闭ARC支持时(当时使用启用ARC的静态库),似乎忘记包含ARC库。您可以使用-fobjc-arc
标志轻松强制链接器包含库,有关完整说明,请参阅此related question。
答案 1 :(得分:4)
我刚从一位CocoaLumberjack开发者那里听到回复,这就是他所说的:
似乎在(可能)LLVM编译器中存在错误。这就是我的意思 发现:
如果你有一个没有打开ARC的Xcode项目,那么你和 有一个文件使用ARC(通过-fobjc-arc),该文件尝试 在'+(void)初始化'中的alloc / init内容,然后它会爆炸 运行时。
但是,如果将项目转换为ARC ......似乎可行。
编辑:开发人员提供的其他信息:
1.2.3标签可以在没有ARC的情况下使用。
您可以从此处获取存档: