OC创建动态库framework
2018-06-20 本文已影响0人
七叶昔洛
新建Cocoa Touch Framework
填写库的名字

此时我们编译一下, 成功(其实我们什么也没做呢...)
选择适配最低版本

我们新建一个文件
XLManager
,并在.h中申明一个make
函数
在.m中去实现函数
在headers中选择我们希望对外暴露的头文件,将其拖到Public下

Release模式下, 选择一个模拟器编译, 然后选择
Generic iOS Device
编译

这时候我们点击framework, show In Finder 进去, 可以看到在
Release-iphoneos
文件夹和Release-iphonesimulator
文件夹下面 都有一个文件DemoKit.framework


使用终端制作通用包
打开终端, cd到一个 空文件路径下(方便查找)
cd /Users/xl/Documents/Empty
lipo -create
空格+release-iphoneos文件夹下面的DemoKit二进制文件路径
空格+release-iphonesimulator文件夹下面的DemoKit二进制文件路径
空格-output
空格包名
(如下图)
lipo -create /Users/xl/Library/Developer/Xcode/DerivedData/DemoKit-ecvnwietpddglfehyilxongqacsq/Build/Products/Release-iphoneos/DemoKit.framework/DemoKit /Users/xl/Library/Developer/Xcode/DerivedData/DemoKit-ecvnwietpddglfehyilxongqacsq/Build/Products/Release-iphonesimulator/DemoKit.framework/DemoKit -output DemoKit

完成之后, 我们就在
Empty
文件夹下得到通用的二进制文件, 我们将得到的通用文件替换掉Release-iphoneos文件中的二进制文件, 此时Release-iphoneos文件中的framework文件就是最终我们需要的通用的动态库文件