fastlane添加sh来给环信SDK瘦身

处理方法

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

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

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

Fastfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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/