您的位置:首页 > 移动开发 > IOS开发

ios 静态库创建

2014-03-27 15:56 232 查看
新建工程







这里注意一下 需要编译两次 1.IOS Device 状态编译 2.iphone 模拟器编译









终端命令:

1。进入指定路径

~ xiegongquan$ cd /Users/xiegongquan/Library/Developer/Xcode/DerivedData/MyLib-cdtlqeaxjwlelteszvrmecwobgfd/Build/Products/
Products xiegongquan$ pwd
/Users/xiegongquan/Library/Developer/Xcode/DerivedData/MyLib-cdtlqeaxjwlelteszvrmecwobgfd/Build/Products

2.查看路径包含的内容
Products xiegongquan$ ls
Release-iphoneos
Release-iphonesimulator

3.查看文件信息 Release-iphoneos
Products xiegongquan$ lipo -info Release-iphoneos/libMyLib.a
Architectures
in the fat file: Release-iphoneos/libMyLib.a are:
armv7 (cputype (12) cpusubtype (11)) (cputype (16777228) cpusubtype (0))

3.查看文件信息 Release-iphonesimulator

Products xiegongquan$ lipo -info Release-iphonesimulator/libMyLib.a
Architectures
in the fat file: Release-iphonesimulator/libMyLib.a are:
i386 x86_64

注意红色部分 ,在模拟器中使用的是 i386 x86_64 而在真机 中使用的是 armv7
;所以需要下面把这两个合并,这样就可以在模拟器和真机中都可以使用

4.合并libMyLib.a
Products xiegongquan$ lipo -create Release-iphoneos/libMyLib.a Release-iphonesimulator/libMyLib.a -output libMyLib.a

5.查看路径
xiegongzenmatoiMac:Products xiegongquan$ pwd
/Users/xiegongquan/Library/Developer/Xcode/DerivedData/MyLib-cdtlqeaxjwlelteszvrmecwobgfd/Build/Products

6.查看路径中的内容
xiegongzenmatoiMac:Products xiegongquan$ ls
Release-iphoneos
Release-iphonesimulator libMyLib.a

7.查看信息
xiegongzenmatoiMac:Products xiegongquan$ lipo -info libMyLib.a
Architectures
in the fat file: libMyLib.a are:
armv7 (cputype (12) cpusubtype (11)) (cputype (16777228) cpusubtype (0))
i386 x86_64

自此静态创建完成

下面是测试:注意 libMyLib.a 文件 确保没问题最好先查看下该库的信息

确保信息如下:(蓝色部分)
rchitectures in the fat file: libMyLib.a are:
armv7 (cputype (12) cpusubtype (11)) (cputype (16777228) cpusubtype (0))
i386 x86_64

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: