最近要开发一款SDK,没办法硬着头皮从头开始,中途查阅了一些资料,也是不详细,网上大多内容较为陈旧,我是使用xcode8开发.
基本设置
首先要先建一个framework工程:

自己填写名称后就生成了一个完整的framework工程:

运行一下,红色的framework就变黑,说明framework已经生成了
随后我们需要设置一些参数,在在Build Setting,具体参数设置看下图:




参数的设置借鉴了别人的,
Architectures:包含哪些架构指令,这里我们需要添加armv7s架构
Build Active Architecture Only:是否只为当前架构编译
Dead Code Stripping:是否从framework中删除未使用的代码
Link With Standard Libraries:是否链接苹果标准库
Mach-O Type:这里有好几种类型,我们需要选中static library
Other Linker Flags:链接参数,如果framework中使用了category,最好加上ObjC、all_load,确保运行时系统会加载其中的category
Other C Flags:额外的C语言链接参数,如果需要支持bitcode,需要加上-fembed-bitcode
Generate Debug Symbols:生成Debug符号,设为Yes,这样作为依赖工程时断点才会生效
此时,一些打包时需要的参数设置就完成了,然后我们可以把需要打包的代码拖入工程
设置我们所需要公开的头文件

添加到public中,直接拖动,简单粗暴

多架构打包
下面就是进行打包了,我们使用Xcode提供的解决方案

有些人初次使用的时候会找不到从哪里添加,这边有两个方式可以添加:


选中刚创建的IDScannerCombiner,在Build Phase下添加一个执行脚本:


选择正确的scheme和目标,开始编译:

把打包的scheme的配置改为release:

然后进行编译,就能得到我们的framework,大功告成

网友评论