2011-11-11 17 views
7

私はiOS開発には比較的新しいので、CocoaLumberjackロギングを実装しようとしています。CocoaLumberjackエラー:シンボルが見つかりません:_objc_storeStrong

https://github.com/robbiehanson/CocoaLumberjackから最新のソースをダウンロードし、プロジェクトに必要なファイルを含め、必要なコードを変更して、以下のランタイムエラーが発生しています。

環境はXcode 4.2 Build 4C199で、プロジェクトのターゲットはDevice = iPad、DeploymentTarget = 4.3に設定されています。プロジェクトは最初はretain/releaseを使って書かれていたので、元のソースをそのまま残して、私が使用しているLumberjackファイルのコンパイラフラグ "-fobjc-arc"を追加しました:DDFileLogger.m、DDLog.m、DDTTYLogger.m 。

コンソール出力は次のようにfileLoggerが対応AppDelegate.hファイルで定義されたインスタンス変数です

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) 

私のプロジェクトは、環境を初期化:

- (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

ARC(Automatic Reference Counting)への移行に関するチュートリアルが見つかりました。http://www.raywenderlich.com/5677/beginning-arc-in-ios-5-part-1 ARCと非ARCファイルの混合がサポートされていることは明らかですが、ARCのすべての機能がiOS 4と下位互換性があるわけではありません - チュートリアルのコメントに「弱い」または「__weak」変数あなたのアプリはiOS 4では動作しません。 Lumberjackのファイルに弱いバールを使用していなかったのですが、エラーは "_objc_storeStrong"です。原因についてはまだ分かりません。 – Alan

答えて

4

私はちょうどバックCocoaLumberjackの開発者の一人から聞いた、これは彼が言ったことである。

There seems to be a bug in (maybe) the LLVM compiler. Here's what I've discovered:

If you have an Xcode project without ARC turned on by default, and you have a file that uses ARC (via -fobjc-arc), and that file attempts to alloc/init stuff within '+ (void)initialize', then it will blow up at runtime.

It seems to work, however, if you convert the project to ARC...

はEDIT:開発者からの追加情報:今後の参考のため

The 1.2.3 tag can be used without ARC.

You can grab an archive from here:

https://github.com/robbiehanson/CocoaLumberjack/tags

8

、これはいるようです現在構築されているターゲットでARCサポートが無効になっている場合(ARC対応の静的ライブラリを使用している場合)、ARCライブラリを含むことを忘れているような、現在のXcodeツールチェーンの欠点になります。 -fobjc-arcフラグを使用してリンカーにライブラリを簡単に組み込むことができます。詳しくはrelated questionを参照してください。

関連する問題