- 新建項目時選擇Cocoa Touch Framework
-
將所需要封裝的文件拖到項目中
-
添加需要暴露的.h文件
- 選擇模擬器 和 Generic iOS Device下各Command+B一次
- 點擊Products中的framework陕壹,右鍵Show in Finder篓吁。
- 在Debug-iphoneos 和Debug-iphonesimulator文件夾下找到對應(yīng)的. framework文件术浪。
- 打開終端悼凑,輸入命令
lipo -info
$ lipo -info '文件路徑/'xxxLib.framework/xxxLib
在xxxLib.framework中有個以xxxLib命名的文件,將此文件直接拖進終端即可得到路徑叁怪。
終端輸出
Architectures in the fat file: /Users/XXX/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/xxxLib.framework/xxxLib are: i386 x86_64
i386 x86_64 支持模擬器固阁,因為上述輸出的是Debug-iphonesimulator文件夾下的,實際開發(fā)中霞掺,一般都要同時支持模擬器和真機谊路,這時讹躯,需要將Debug-iphoneos 和Debug-iphonesimulator文件夾下的framework合并。
使用命令:lipo -create '第一個文件路徑' '第二個文件路徑' -output '輸出文件路徑'
- 將Debug-iphoneos 和Debug-iphonesimulator文件夾下的xxxLib.framework下xxxLib拖入終端
$ lipo -create /Users/nathan/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/WSBLELib.framework/WSBLELib /Users/nathan/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphoneos/WSBLELib.framework/WSBLELib -output /Users/nathan/Desktop/WSBLELib
- 此時桌面上生成WSBLELib文件缠劝,使用lipo -info 查看信息
$ lipo -info /Users/nathan/Desktop/WSBLELib
Architectures in the fat file: /Users/nathan/Desktop/WSBLELib are: i386 armv7 armv7s x86_64 arm64
i386 armv7 armv7s x86_64 arm64
已同時支持模擬器和真機
- 將Debug-iphoneos 或者Debug-iphonesimulator文件夾下的framework隨便拷貝一個出來潮梯,將里面的WSBLELib替換成合并成功的WSBLELib文件,到此惨恭,framework制作完成秉馏。