小编Jul*_*lie的帖子

如何构建通用的ios静态库

我正在尝试构建一个可以与ios3.x和ios4.x一起使用的静态库.我可以使用ios3.0构建一个静态库,它可以在ios3.0中与另一个项目一起使用,但不能在ios4中编译.从ios4到ios3也是如此.

以下是重新创建的方法:

  1. 打开XCode 3.2.4并启动一个名为Library4的Cocoa Touch静态库的新项目
  2. 单击classes文件夹并创建一个名为"TestViewController"的新UIViewController
  3. 右键单击Frameworks文件夹,添加现有框架,选择UIKit
  4. 在左侧面板中,展开目标,右键单击我的库目标,然后单击获取信息.更改为所有配置,将基本sdk更改为iphone模拟器4.0,将ios部署目标更改为ios3.0
  5. 单击带有二进制文件的链接库文件夹.在右侧窗格中,将两者的角色更改为"Weak"
  6. 建立图书馆
  7. 打开Xcode 3.2.2并启动一个名为Library4Test的基于View的新应用程序
  8. 将TestViewController.h复制到classes文件夹
  9. 将libLibrary4.a文件复制到frameworks文件夹.它会自动添加到目标的链接器阶段
  10. 右键单击Library4Test Target并单击获取信息.在其他链接器标志中,添加"-ObjC"和"-all_load"
  11. 在app delegate header中添加Import"TestViewController.h"
  12. 在app delegate header的应用程序的didFinishLaunchingWithOptions方法中添加

    TestViewController*test = [TestViewController alloc] init;

  13. 使用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 …
Run Code Online (Sandbox Code Playgroud)

iphone xcode static-libraries universal-binary ios

8
推荐指数
1
解决办法
7489
查看次数

标签 统计

ios ×1

iphone ×1

static-libraries ×1

universal-binary ×1

xcode ×1