Skip to content

Instantly share code, notes, and snippets.

@xdream86
Created April 20, 2020 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdream86/605c6cf28957753931615568340a330f to your computer and use it in GitHub Desktop.
Save xdream86/605c6cf28957753931615568340a330f to your computer and use it in GitHub Desktop.
# 如果Framework中还需要使用资源文件,请将资源文件单独复制到一个bundle中,使用一个文件夹包含.framework和.bundle
Target_Name="YourTargetName"
# 在build/Release-iphoneos/${Target_Name}.framework下创建真机framework
xcodebuild -configuration Release -target "${Target_Name}" -sdk iphoneos clean build
# 在build/Release-iphonesimulator/${Target_Name}.framework下创建模拟器framework
xcodebuild -configuration Release -target "${Target_Name}" -sdk iphonesimulator
Device_Dir=build/Release-iphoneos/${Target_Name}.framework
Simulator_Dir=build/Release-iphonesimulator/${Target_Name}.framework
Device_Simulator_Dir=Framework/${Target_Name}.framework
# 将真机的framework里的内容全部复制到合并的framework文件夹内,主要是一些头文件,真机的编译的代码最终会被真机与模拟器合并后的代码覆盖
test -d "${Device_Simulator_Dir}" || mkdir -p "${Device_Simulator_Dir}" && cp -R "${Device_Dir}/" "${Device_Simulator_Dir}"
# 合并模拟器和真机的代码
lipo -create "${Device_Dir}/${Target_Name}" "${Simulator_Dir}/${Target_Name}" -output "${Device_Simulator_Dir}/${Target_Name}"
# 移除build目录
rm -r build
open $Device_Simulator_Dir/..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment