记录一些Framework
开发时用到的命令,便于后续查看
一. lipo
- 查看包含的架构
lipo -info XMCommon.framework/XMCommon
// 输出: Architectures in the fat file: XMCommon are: arm64 armv7
lipo -info ./XMComm*
// 输出: Non-fat file: ./XMCommArm64 is architecture: arm64
// Non-fat file: ./XMCommArmv7 is architecture: armv7
- 合并架构
lipo -create ./XMCommArm64 ./XMCommArmv7 -output ./FatXMCommon
- 拆分架构
lipo ./FatXMCommon -thin arm64 -output ./XMCommArm64
lipo ./FatXMCommon -thin armv7 -output ./XMCommArmv7
二. ar
- 删除指定的.o文件
遇到duplicate symbol _OBJC_XXX
编译错误时,在确保安全时可以使用此命令删除重复的符号表所在的.o
// 需要先拆分Fat二进制
见上面的lipo命令
// 然后在逐一删除
ar -d ./XMCommArm64 XXX.o
ar -d ./XMCommArmv7 XXX.o
// 在合并起来
见上面的lipo命令
三. xcodebuild
- 编译
#build之前clean一下
xcodebuild clean\
-workspace $workspace_Name\
-scheme $scheme_Name\
-configuration Release\
-sdk iphonesimulator
xcodebuild clean\
-workspace $workspace_Name\
-scheme $scheme_Name\
-configuration Release\
-sdk iphoneos
#模拟器build
xcodebuild build\
-workspace $workspace_Name\
-scheme $scheme_Name\
-configuration Release\
-sdk iphonesimulator\
-derivedDataPath $build_DIR\ # 可选 指定编译后文件存储目录
-quiet # 只输出error warning log
#真机build
xcodebuild build\
-workspace $workspace_Name\
-scheme $scheme_Name\
-configuration Release\
-sdk iphoneos\
-derivedDataPath $build_DIR\ # 可选 指定编译后文件存储目录
-quiet # 只输出error warning log
- 合并架构生成
xcframework
xcodebuild -create-xcframework \
-framework ./iphonesimulator.framework \
-framework ./iphone.framework \
-output ./XMCommon.xcframework"
网友评论