fastlane 添加 sh 来给环信 SDK 瘦身

处理方法

由于环信将 i386 x86_64 armv7 arm64 几个平台都合并到了一起,所以使用动态库上传 appstore 时需要将 i386 x86_64 两个平台删除后,才能正常提交审核。

所以我们使用 fastlane sh 在打包 gym 时前后分别将 x86 的移除remove86framework 和添加add86framework 。这样就可以继续使用 fastlane 一键打包。

如果出错,使用 pod 删除并重新安装完整版的环信 SDK。

Fastfile

desc "Deploy a new version to the App Store"
lane :release do
remove86framework
gym
add86framework
deliver(force: true)
# frameit
end

desc "Remove x86 framework"
lane :remove86framework do
sh(%(
cd ../Pods/HyphenateLite/iOS_Pods_IMSDK*
pwd

if [! -d "./bak"]; then
mkdir ./bak
fi
if [-d "./bak/HyphenateLite.framework"]; then
rm -rf ./bak/HyphenateLite.framework
fi
cp -r HyphenateLite.framework ./bak
lipo HyphenateLite.framework/HyphenateLite -thin armv7 -output HyphenateLite_armv7
lipo HyphenateLite.framework/HyphenateLite -thin arm64 -output HyphenateLite_arm64
lipo -create HyphenateLite_armv7 HyphenateLite_arm64 -output HyphenateLite
mv HyphenateLite HyphenateLite.framework/

))
end

desc "Add x86 framework back"
lane :add86framework do
sh(%(
cd ../Pods/HyphenateLite/iOS_Pods_IMSDK*
pwd
if [-d "./HyphenateLite.framework"]; then
rm -rf ./HyphenateLite.framework
fi
cp -r ./bak/HyphenateLite.framework HyphenateLite.framework
))
end

参考文档

  1. 环信:http://docs.easemob.com/im/300iosclientintegration/20iossdkimport#%E9%9B%86%E6%88%90%E5%8A%A8%E6%80%81%E5%BA%93%E4%B8%8A%E4%BC%A0appstore
  2. fastlane sh 文档:https://docs.fastlane.tools/actions/sh/