2012-08-23 33 views
5

Tôi xây dựng một thư viện tĩnh liên kết với các khung công tác khác, đặc biệt là CoreLocation. Tôi muốn sử dụng các tính năng được cung cấp bởi iOS 5 nhưng phải tương thích với 4.3.Thư viện tĩnh và -weak-lSystem

vụ tai nạn của tôi ứng dụng lúc khởi động khi tôi bắt đầu nó trên các thiết bị iOS trong 4.3 với lỗi này:

Date/Time:  2012-08-22 16:44:53.900 +0200 
OS Version:  iPhone OS 4.3.3 (8J3) 
Report Version: 104 

Exception Type: EXC_BREAKPOINT (SIGTRAP) 
Exception Codes: 0x00000001, 0xe7ffdefe 
Crashed Thread: 0 

Dyld Error Message: 
    Symbol not found: _UIKeyboardDidChangeFrameNotification 

Vấn đề tôi gặp được mô tả trong bài viết này: iOS 4 app crashes at startup on iOS 3.1.3: Symbol not found: __NSConcreteStackBlock.

Nhưng làm thế nào để bạn giải quyết vấn đề đó khi xây dựng một thư viện tĩnh ?? Tôi không thể biên dịch khi tôi đặt cờ -weak-lSystem. Dưới đây là một dấu vết:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: -dynamic not specified, -all_load invalid 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: -dynamic not specified the following flags are invalid: -ObjC 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -weak-lSystem 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -weak-lSystem is not an object file (not allowed in a library) 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/libxml2.2.dylib is a dynamic library, not added to the static library 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/libxml2.2.dylib is a dynamic library, not added to the static library 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/libz.dylib is a dynamic library, not added to the static library 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/libz.dylib is a dynamic library, not added to the static library 
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool failed with exit code 1 

Resolved

Xem câu trả lời chấp nhận bên dưới và đừng quên để đánh dấu các thư viện sử dụng trong các phiên bản khác nhau như bắt buộc trong Xcode. Ví dụ: Tôi sử dụng UIKit thông báo mới cho iOS 5 nhưng mục tiêu triển khai của tôi là 4.3 nên tôi cần đánh dấu thư viện này là Tùy chọn để làm cho mọi thứ hoạt động. Điều này cũng tương tự đối với lớp Core 5 của CoreLocation CLGeocoder mới.

+0

Tôi đã cố gắng liên kết yếu với các lib động, không thành công. Tôi cũng đã cố gắng thêm cờ động nhưng nó thậm chí còn tồi tệ nhất! – nverinaud

Trả lời

1

Sự cố là UIKeyboardDidChangeFrameNotification không khả dụng trên iOS 4 và do đó trình tải động (Dyld) không thành công.

Từ quan điểm của nhà phát triển thư viện tĩnh, bạn không phải làm gì cả. Cờ -weak-lSystem nên được đặt trong dự án Xcode sử dụng thư viện tĩnh cho một ứng dụng (xem bài viết được đề cập trong câu hỏi) - không phải trong dự án cho thư viện tĩnh.

+0

Yay! Nhưng bạn cũng cần đánh dấu các thư viện được sử dụng trong nhiều phiên bản (ví dụ: UIKit hoặc CoreLocation) là Tùy chọn! – nverinaud

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