2011-11-11 31 views
7

Tôi tương đối mới đối với việc phát triển iOS và đang cố gắng triển khai ghi nhật ký CocoaLumberjack.CocoaLumberjack Lỗi: Biểu tượng không tìm thấy: _objc_storeStrong

Tôi đã tải xuống nguồn mới nhất từ ​​https://github.com/robbiehanson/CocoaLumberjack, đã bao gồm các tệp cần thiết trong dự án của tôi, thực hiện các thay đổi mã cần thiết và đang nhận được lỗi trình liên kết thời gian chạy sau đây.

Môi trường là Xcode 4.2 Build 4C199, với dự án Target được đặt thành Device = iPad và DeploymentTarget = 4.3. Dự án ban đầu được viết bằng cách giữ lại/giải phóng, vì vậy tôi đã để nguyên nguồn gốc là, thêm cờ biên dịch "-fobjc-arc" cho các tệp Lumberjack tôi đang sử dụng: DDFileLogger.m, DDLog.m và DDTTYLogger.m .

Giao diện điều khiển đầu ra là:

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) 

Dự án của tôi khởi môi trường như sau, trong đó fileLogger là một biến Ví dụ định nghĩa trong file AppDelegate.h tương ứng:

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

Có ai gặp phải này vấn đề và biết giải pháp hay giải pháp khác? Là những gì tôi đang làm thậm chí có thể ... có hỗn hợp các tập tin ARC và không ARC trong một dự án?

+0

Tìm thấy một hướng dẫn tốt về việc di chuyển sang ARC (Tính tham chiếu tự động): http://www.raywenderlich.com/5677/beginning-arc-in-ios-5-part-1. Rõ ràng là việc trộn các tệp ARC và không phải ARC được hỗ trợ, tuy nhiên không phải tất cả các tính năng của ARC đều tương thích ngược với iOS 4 - có ghi chú từ tác giả trong phần bình luận "Nếu bạn sử dụng các thuộc tính 'yếu' hoặc '__weak' thì ứng dụng của bạn sẽ không hoạt động trên iOS 4. " Không thấy bất kỳ việc sử dụng các vars yếu trong các tập tin của Lumberjack, và lỗi là về "_objc_storeStrong", vì vậy tôi vẫn không chắc chắn về nguyên nhân. – Alan

Trả lời

4

Tôi vừa nghe phản hồi từ một trong những nhà phát triển CocoaLumberjack, đây là những gì ông nói:

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: Thông tin thêm từ nhà phát triển:

The 1.2.3 tag can be used without ARC.

You can grab an archive from here:

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

8

Để tham khảo trong tương lai, điều này dường như là một thiếu sót của chuỗi công cụ Xcode hiện tại mà dường như quên bao gồm thư viện ARC khi mục tiêu hiện được xây dựng có hỗ trợ ARC bị tắt (và sử dụng các thư viện tĩnh có hỗ trợ ARC). Bạn có thể dễ dàng buộc trình liên kết đưa vào thư viện bằng cách sử dụng cờ -fobjc-arc, xem phần này related question để biết mô tả đầy đủ.

Các vấn đề liên quan