iOS真机和模拟器framework合并
2019-01-11 本文已影响0人
刘明洋
一、设置Release模式
1、首先来选这里
image.png2、选择Run->将Debug改成Release,选择Close,关闭
image.png二、运行项目
1、真机环境下,编译工程
真机环境下编译2、模拟器环境下,编译工程
模拟器环境下编译3、选framework,Show in Finder
image.png4、找到,真机和模拟器生成的framework
image.png三、合成
1、lipo -info 命令,可以检测framework
lmydeMacBook-Pro:~ lmy$ lipo -info /Users/lmy/Library/Developer/Xcode/DerivedData/CloudLearning_OPDiscoveryDF-fyoydhuesnoytlbbbitgpbkgyzwh/Build/Products/Release-iphoneos/OPDiscoveryDF.framework/OPDiscoveryDF
Architectures in the fat file: /Users/lmy/Library/Developer/Xcode/DerivedData/CloudLearning_OPDiscoveryDF-fyoydhuesnoytlbbbitgpbkgyzwh/Build/Products/Release-iphoneos/OPDiscoveryDF.framework/OPDiscoveryDF are: armv7 arm64
lmydeMacBook-Pro:~ lmy$
说明:真集framework中包含 armv7 arm64
lmydeMacBook-Pro:~ lmy$ lipo -info /Users/lmy/Library/Developer/Xcode/DerivedData/CloudLearning_OPDiscoveryDF-fyoydhuesnoytlbbbitgpbkgyzwh/Build/Products/Release-iphonesimulator/OPDiscoveryDF.framework/OPDiscoveryDF
Architectures in the fat file: /Users/lmy/Library/Developer/Xcode/DerivedData/CloudLearning_OPDiscoveryDF-fyoydhuesnoytlbbbitgpbkgyzwh/Build/Products/Release-iphonesimulator/OPDiscoveryDF.framework/OPDiscoveryDF are: i386 x86_64
lmydeMacBook-Pro:~ lmy$
说明:真集framework中包含 i386 x86_64
2、合成
lipo -create "/Users/lmy/Library/Developer/Xcode/DerivedData/CloudLearning_OPDiscoveryDF-fyoydhuesnoytlbbbitgpbkgyzwh/Build/Products/Release-iphoneos/OPDiscoveryDF.framework/OPDiscoveryDF" "/Users/lmy/Library/Developer/Xcode/DerivedData/CloudLearning_OPDiscoveryDF-fyoydhuesnoytlbbbitgpbkgyzwh/Build/Products/Release-iphonesimulator/OPDiscoveryDF.framework/OPDiscoveryDF" -output "/Users/lmy/Library/Developer/Xcode/DerivedData/CloudLearning_OPDiscoveryDF-fyoydhuesnoytlbbbitgpbkgyzwh/Build/Products/OPDiscoveryDF"
以上命令太长了,可以直接先cd到 Products 目录下,执行下面短的命令:
lipo -create "Release-iphoneos/OPDiscoveryDF.framework/OPDiscoveryDF" "Release-iphonesimulator/OPDiscoveryDF.framework/OPDiscoveryDF" -output "OPDiscoveryDF"
最终,在Products/目录下,生成了一个包含armv7 arm64、i386 x86_64 的全的库。
image.png
3、替换,使用
将生成的OPDiscoveryDF文件, 替换到任意一个OPDiscoveryDF.framework里面去, 这个OPDiscoveryDF.framework我们就合成并可以使用了, 支持真机和模拟器使用。