美文网首页
iOS Framework制作

iOS Framework制作

作者: ___吉 | 来源:发表于2019-03-27 16:04 被阅读0次
  • 新建项目时选择Cocoa Touch Framework
    新建项目时选择Cocoa Touch Framework
  • 将所需要封装的文件拖到项目中


    将所需要封装的文件拖到项目中
  • 添加需要暴露的.h文件


    添加需要暴露的.h文件
  • 选择模拟器 和 Generic iOS Device下各Command+B一次
  • 点击Products中的framework,右键Show in Finder。
  • 在Debug-iphoneos 和Debug-iphonesimulator文件夹下找到对应的. 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文件夹下的,实际开发中,一般都要同时支持模拟器和真机,这时,需要将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制作完成。

相关文章

网友评论

      本文标题:iOS Framework制作

      本文链接:https://www.haomeiwen.com/subject/uywzvqtx.html