Iphone 如何构建通用ios静态库
我正在尝试构建一个静态库,可以与ios3.x和ios4.x一起使用。我可以用ios3.0构建一个静态库,该库与ios3.0中的另一个项目一起工作,但不会在ios4中编译。从ios4到ios3也是如此 以下是如何重新创建:Iphone 如何构建通用ios静态库,iphone,xcode,ios,universal-binary,static-libraries,Iphone,Xcode,Ios,Universal Binary,Static Libraries,我正在尝试构建一个静态库,可以与ios3.x和ios4.x一起使用。我可以用ios3.0构建一个静态库,该库与ios3.0中的另一个项目一起工作,但不会在ios4中编译。从ios4到ios3也是如此 以下是如何重新创建: 打开XCode 3.2.4并启动一个新项目,即名为Library4的Cocoa Touch静态库 单击classes文件夹并创建一个名为“TestViewController”的新UIViewController 右键单击框架文件夹,添加现有框架,选择UIKit 在左侧面板中,
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
不太确定,但它看起来像是一个链接问题(所有那些.o的东西)。下面是我如何设置iOS静态库的。这是一件非常简单的事情,但它是有效的
部署后处理是(检查)
安装构建 产品定位/
cd ~
ln -s /usr/local/lib
现在打开要在其中使用库的Xcode项目。创建一个名为Libraries或类似的组,按住ctrl键并单击并使用“添加现有文件”添加库。它将被称为类似libYourLibrary的东西
运行项目时,将出现链接错误。因此,双击项目文件,转到Build>>All configurations并将以下值添加到“Library Search path”设置中:~/lib通过sdk创建一个目标的方式?我为iOS OSx创建了一个静态库,过程简单得多
#if TARGET_OS_IPHONE
...
#else
...
#endif
遵守守则。您可以添加自己的条件。编译器错误的发生是因为您没有链接到正确的系统框架。暗红色中的所有符号都是从基础框架、UIKIT.Frand和LIBOBJC.DyLIB
静态库不会自动引入它们需要链接的所需框架,因此当您使用它们时,您必须自己将它们添加到项目中。对于只想构建静态IOS库的人:我刚刚创建了一个问题,您可能会在这里回答,但我不确定。这是: