iOS 打包移除 i386 和 x86_64 平台动态库

4,113 阅读1分钟

由于 iOS 编译的特殊性,为了方便开发者在模拟器调试,很多 SDK 将i386x86_64armv7arm64几个平台都合并到了一起。在开发阶段都没有问题,但生产编译上传到 App Store 时,需要将i386x86_64两个平台的库删除,否则无法正常提交审核。

以环信Hyphenate.framework为例,具体操作如下:

  1. 先把Hyphenate.framework拷贝一份;

  2. Hyphenate.framework剥离出armv7arm64的库

    // armv7
    lipo Hyphenate.framework/Hyphenate -thin armv7 -output Hyphenate_armv7
    // arm64
    lipo Hyphenate.framework/Hyphenate -thin arm64 -output Hyphenate_arm64
    
  3. armv7arm64的库打包

    lipo -create Hyphenate_armv7 Hyphenate_arm64 -output Hyphenate
    
  4. 修改文件名

    mv Hyphenate Hyphenate.framework
    
  5. 以上操作后,使用新的Hyphenate.framework替换到项目中,然后重新编译就行了。

PS:注意最后得到的包必须真机编译运行,并且工程要设置编译二进制文件General->Embedded Bunaries