Xcode 6制作动态及静态Framework

论坛 期权论坛     
选择匿名的用户   2021-5-23 19:53   63   0
<div class="field_body" id="detailbody" style="margin:0px; padding:0px; font-size:14px; color:rgb(37,37,37); line-height:28px; font-family:&#39;Microsoft YaHei&#39;">
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px"> 有没有写SDK或者要将一些常用的工具类做成Framework的经历? 你或许自己写脚本完成了这项工作,相信也有很多的人使用 iOS-Universal-Framework ,随着Xcode 6的发布,相信小伙伴们已经都知道了,Xcode 6支持做Framework了. 同时iOS-Universal-Framework开发者也宣布不在继续维持此项目的开发,建议开发者使用Xcode 6制作,目前网上也有很多制作iOS Framework的资料,但大多都不够详细,接下来本文会详情介绍一下在Xcode 6下制作iOS Framework.</p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px"> 关于静态库和动态库的概念,网上资料很多,这里不做叙述,只讲解制作过程。</p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px"> <strong>创建iOS动态库</strong></p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px"> 新建工程并选择默认Target为Cocoa Touch Framework, 如图:</p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px; text-align:center"> <img alt="11.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-53adb876b6bc4802cdeaa1b2ed9d83a0.png" style="border:0px; max-width:100%; margin:5px 0px; width:537px; height:322px" title="1416968618592047.png"></p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px"> 做编码工作,在这里我简单的写了一个Utils的类,并写了一个log方法</p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px; text-align:center"> <img alt="12.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-f227c1d52f252fe46ad60a5b47d400c2.png" style="border:0px; max-width:100%; margin:5px 0px; width:536px; height:269px" title="1416968640210748.png"></p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px"> <span style="line-height:1.8">设置开放的头文件:Framework中有些类可能是一些私有的辅助工具,不需要使用者看到,在这里只需要把开放出去的类放到Public下, 如图</span><br> </p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px; text-align:center"> <img alt="13.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-e516f5d4f50606e094d282e077c246bf.png" style="border:0px; max-width:100%; margin:5px 0px" title="1416968683381248.png"></p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px"> <span style="line-height:1.8">这样生成的Framework的Headers目录下也只能看到Public的头文件</span><br> </p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px; text-align:center"> <img alt="14.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-ad148dba957d1aef07bbc6f263ddbf89.png" style="border:0px; max-width:100%; margin:5px 0px" title="1416968745487455.png"></p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px"> <span style="line-height:1.8">编码完成之后,直接Run就能成功生成Framework文件了,选择 xCode-&gt;Window-&gt;Organizer-&gt;Projects-&gt;Your Project, 打开工程的Derived Data目录,这样就能找到生成的Framework文件了,如图</span><br> </p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px; text-align:center"> <img alt="15.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-fd603d3687f304a0f455ae0cd6c2a10b.png" style="border:0px; max-width:100%; margin:5px 0px" title="1416968769416024.png"></p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px; text-align:center"> <img alt="16.png" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-86e5f5a70d9eb92fd8efe1cef4e46304.png" style="border:0px; max-width:100%; margin:5px 0px" title="1416968807939410.png"></p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px"> <strong>新建测试工程,使用生成的Framework</strong></p>
<p style="margin-top:0px; margin-bottom:20px; padding-top:0px; padding-bottom:0px"> 将Framework文件导入到测试工程,调用Framework中的代码</p>
<div style="margin:0px; padding:0px">
  <div class="syntaxhighlighter  js" id="highlighter_91331" style="padding:0px; width:701px; margin:1em 0px!important; position:relative!important; overflow:auto!important; font-size:1em!important">
   <table border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse; border-spacing:0px; width:701px; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; margin:0px!important; outline:0px!important; overflow:visible!important; padding:0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; font-family:Consolas,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,Courier,monospace!important; font-size:1em!i
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP