使用lipo合并iPhone模拟器和真机的静态类库

在XCode开发中分为2种运行环境,一种是模拟器,一种是设备(devices),在这两种环境中静态库(.a文件)是不能混用的,混用的话会造成程序崩溃。

为了避免这种情况,一种做法是分别编译两种版本的静态库,当使用静态库的应用编译不同版本的时候手工切换静态库的版本,这样做很容易造成混乱,不方便管理。

下面就介绍一下lipo这个命令,lipo命令可以将两种版本的静态库合并成一个通用的动态库

lipo: Usage: lipo [input_file] ... [-arch  input_file] ... [-info] [-detailed_info] [-output output_file] [-create] [-arch_blank ] [-thin ] [-remove ] ... [-extract ] ... [-extract_family ] ... [-verify_arch  ...] [-replace  ] ...

lipo 命令使用示例:

# Set the target folders and the final framework product.
    INSTALL_DIR=${SYMROOT}/FI.framework
    DEVICE_DIR=${SYMROOT}/Release-iphoneos
    SIMULATOR_DIR=${SYMROOT}/Release-iphonesimulator

# Create and renews the final product folder.
    mkdir -p "${INSTALL_DIR}"
    rm -rf "${INSTALL_DIR}"
    rm -rf "${INSTALL_DIR}/FI"

# Copy the header files to the final product folder.
    ditto "${DEVICE_DIR}/FI.framework/Headers" "${INSTALL_DIR}/Headers"

# Use the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.
    lipo -create "${DEVICE_DIR}/FI.framework/FI" "${SIMULATOR_DIR}/FI.framework/FI" -output "${INSTALL_DIR}/FI"

如何创建通用的FrameWork请参考下面的文章
http://db-in.com/blog/2011/05/creating-universal-framework-to-iphone-ios/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值