Jul*_*lie 8 iphone xcode static-libraries universal-binary ios
我正在尝试构建一个可以与ios3.x和ios4.x一起使用的静态库.我可以使用ios3.0构建一个静态库,它可以在ios3.0中与另一个项目一起使用,但不能在ios4中编译.从ios4到ios3也是如此.
以下是重新创建的方法:
在app delegate header的应用程序的didFinishLaunchingWithOptions方法中添加
TestViewController*test = [TestViewController alloc] init;
使用ios3.0模拟器进行编译
当我编译时,我得到:
Ld build/Debug-iphonesimulator/library4Test.app/library4Test normal i386
cd /Users/test/Documents/Testing/library4Test
setenv MACOSX_DEPLOYMENT_TARGET 10.5
setenv PATH "/Developer/GrandpaIPhone/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/GrandpaIPhone/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/GrandpaIPhone/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/GrandpaIPhone/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk -L/Users/test/Documents/Testing/library4Test/build/Debug-iphonesimulator -L/Users/test/Documents/Testing/library4Test -F/Users/test/Documents/Testing/library4Test/build/Debug-iphonesimulator -filelist /Users/test/Documents/Testing/library4Test/build/library4Test.build/Debug-iphonesimulator/library4Test.build/Objects-normal/i386/library4Test.LinkFileList -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -llibrary4_1 -o /Users/test/Documents/Testing/library4Test/build/Debug-iphonesimulator/library4Test.app/library4Test
Undefined symbols:
"_objc_msgSendSuper2", referenced from:
-TestViewController didReceiveMemoryWarning in liblibrary4_1.a(TestViewController.o)
-TestViewController viewDidUnload in liblibrary4_1.a(TestViewController.o)
-TestViewController dealloc in liblibrary4_1.a(TestViewController.o)
"__objc_empty_vtable", referenced from:
_OBJC_METACLASS_$_TestViewController in liblibrary4_1.a(TestViewController.o)
_OBJC_CLASS_$_TestViewController in liblibrary4_1.a(TestViewController.o)
"_OBJC_CLASS_$_UIViewController", referenced from:
_OBJC_CLASS_$_TestViewController in liblibrary4_1.a(TestViewController.o)
"_OBJC_METACLASS_$_UIViewController", referenced from:
_OBJC_METACLASS_$_TestViewController in liblibrary4_1.a(TestViewController.o)
".objc_class_name_TestViewController", referenced from:
literal-pointer@__OBJC@__cls_refs@TestViewController in library4_1os3TestAppDelegate.o
"_OBJC_METACLASS_$_NSObject", referenced from:
_OBJC_METACLASS_$_TestViewController in liblibrary4_1.a(TestViewController.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
不太确定,但它看起来像是一个链接问题(所有这些 .o 的东西)。以下是我设置 iOS 静态库的方法。这是一个非常简单的事情,但是很有效。
构建您的静态库。默认情况下它将构建在 /usr/local/lib 中
现在创建一个符号链接以便轻松访问您的新库。一个简单的方法是打开终端并运行以下命令:
cd ~
ln -s /usr/local/lib
Run Code Online (Sandbox Code Playgroud)
现在打开您要在其中使用库的 Xcode 项目。创建一个名为“库”或类似名称的组,按住 Ctrl 键单击并使用“添加现有文件”来添加库。它将被称为 libYourLibrary.a 之类的名称。当您运行项目时,您将收到链接错误。因此,双击项目文件,转到“构建>>所有配置”,并将以下值添加到“库搜索路径”设置中:~/lib
归档时间: |
|
查看次数: |
7489 次 |
最近记录: |