{"id":21,"date":"2012-07-10T01:35:07","date_gmt":"2012-07-09T17:35:07","guid":{"rendered":"http:\/\/hmu023267.chinaw3.com\/wordpress\/?p=21"},"modified":"2012-07-10T01:35:07","modified_gmt":"2012-07-09T17:35:07","slug":"ios-framework-%e5%88%b6%e4%bd%9c%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.sunyuping.com\/index.php\/2012\/07\/10\/ios-framework-%e5%88%b6%e4%bd%9c%e6%95%99%e7%a8%8b\/","title":{"rendered":"iOS framework \u5236\u4f5c\u6559\u7a0b"},"content":{"rendered":"<p>\t\t\t\t\u6211\u4eec\u4f7f\u7528\u4e00\u79cd\u53d8\u901a\u7684\u65b9\u6cd5\u6765\u5236\u4f5c iOS framework,\u6b65\u9aa4\uff1a<\/p>\n<p>1.\u6253\u5f00Xcode\u521b\u5efa\u4e00\u4e2a\u201cCocoa Touch Static Library\u201d\u5de5\u7a0b\uff0c\u5e76\u5220\u9664\u73b0\u6709\u7684target.<\/p>\n<p>2.\u53f3\u952eproject\u9009\u62e9\u6dfb\u52a0New Target\uff0c\u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\u627e\u5230Cocoa ,\u5728Cocoa\u53f3\u4fa7\u7a97\u53e3\u4e2d\u9009\u62e9\u201cLoadable Bundle\u201d\u3002<br \/>\n\u6ce8\u610f\uff1a\u5230\u8fd9\u6b65\u7684\u65f6\u5019\u4e0d\u8981\u9009\u62e9framework,\u5e94\u4e3aframework\u662fMAC OS\u4e0a\u7684\uff0ciOS\u662f\u4e0d\u652f\u6301\u7684\uff0c\u4f46\u662fiOS \u652f\u6301\u201cLoadable Bundle(cfbundle)\u201d<\/p>\n<p>3.target \u4e0a\u53f3\u952eget Info \u5728Build\u00a0<wbr>\u00a0<wbr>Settings\u4e0b\u9762\u8bbe\u7f6e\u4e0b\u9762\u76845\u9879\u5185\u5bb9\uff1a<br \/>\na.\u641c\u7d22Wrapper Extension,\u628a\u9ed8\u8ba4\u7684bundle\u6539\u6210framework.<br \/>\nb.\u4fee\u6539Mach-O Type \u4e3aRelocatable Object File.<br \/>\nc.\u5173\u95edDead Code Stripping ,\u628a\u52fe\u53bb\u6389\uff01<br \/>\nd.\u5173\u95edLink With Standard Libraries.<br \/>\ne.\u79fb\u9664\u6240\u6709\u5173\u4e8e\u201cAppKit\u201d\u00a0<wbr>\u00a0<wbr>\u548c\u00a0<wbr>\u00a0<wbr>\u201cFoundation\u201d\u7684\u53c2\u8003\uff0c\u5220\u9664\u201cOther Linker Flags\u201d\u7684\u6240\u6709\u503c\uff0c\u5e76\u5220\u9664\u201cGCC_PREFIX_HEADER\u201c\u7684\u503c\uff01<\/p>\n<p>4.\u5728frameworks Info.plist\u6587\u4ef6\u4e2d\u5c06Bundle OS Type code\u7684\u503cBNDL\u6539\u4e3a\uff1aFMWK\uff0c\u5e76\u4e14\u5728target\u7684 get info\u7a97\u53e3\u4e2d\u7684Properties\u6807\u7b7e\u680f\u4e0b\u4e5f\u5c06Type\u6539\u4e3aFMWK\u3002<\/p>\n<p>5.\u5728\u5de5\u7a0b\u4e2d\u6dfb\u52a0\u4f60\u7684\u4ee3\u7801\u3002<br \/>\n\u4f8b\u5982\uff1a\u6211\u4eec\u6dfb\u52a0\u4e00\u4e2a\u7c7b<br \/>\n#import &lt;Foundation\/Foundation.h&gt;<\/p>\n<p>@interface Help : NSObject {<\/p>\n<p>}<\/p>\n<p>&#8211; (void)show;<\/p>\n<p>@end<\/p>\n<p>#import &#8220;Help.h&#8221;<\/p>\n<p>@implementation Help<\/p>\n<p>&#8211; (void)show<br \/>\n{<br \/>\n<wbr>\u00a0<wbr>\u00a0<wbr>\u00a0<wbr>NSLog(@&#8221;framework\uff01\uff01\uff01&#8221;);<br \/>\n}<\/p>\n<p>@end<\/p>\n<p>6.\u5728target\u4e0a\u53f3\u952eAdd&#8212;New Build Phase&#8212;New Copy Headers Build Phase,\u6b64\u65f6target\u4e0b\u9762\u4f1a\u591a\u51fa\u4e00\u4e2a\u7070\u8272\u7684\u6587\u4ef6\u5939\u2014Copy Headers\u3002<\/p>\n<p>7.\u7136\u540e\u5c06\u6211\u4eec\u521a\u624d\u6dfb\u52a0\u7684Help\u7c7b\u7684.h\u6587\u4ef6\u4ece\u4e0a\u9762\u62d6\u5230\u4e0b\u9762\u7684Copy Headers\u4e2d\uff0c\u518d\u5728\u8be5\u6587\u4ef6\u5939\u4e0a\u53f3\u952e\u2014Set Role&#8212;Public.<\/p>\n<p>8.\u4ece\u4e0a\u9762\u5c06\u6240\u6709\u8981\u6253\u8fdbframework\u7684.m\u6587\u4ef6\u62d6\u5230target\u4e0b\u7684Compile Sources\u6587\u4ef6\u5939\u91cc\u3002<\/p>\n<p>9.\u7f16\u8bd1,\u5982\u679c\u51fa\u9519\uff0c\u90a3\u5c31\u5728\u00a0<wbr>\u00a0<wbr>Build\u4e0b\u9762\u7684 \u5c06\u201cOther Linker Flags \u201c\u8bbe\u7f6e\u4e3a \u2013ObjC \u3001-all_load\u3001-lxml2,\u4e0d\u8981\u5199\u5728\u4e00\u8d77\uff0c\u8bf7\u4e00\u9879\u9879\u6dfb\u52a0\u3002<\/p>\n<p>\u6ce8\u610f\uff1a\u5982\u679c\u7f16\u8bd1\u51fa\u73b0\u5927\u91cf\u7684\u9519\u8bef\uff0c\u8bf4\u660e\u4f60\u6ca1\u6709\u5220\u9664\u201cAppKit\u201d\u00a0<wbr>\u00a0<wbr>\u548c\u00a0<wbr>\u00a0<wbr>\u201cFoundation\u201d\u7684\u53c2\u8003\uff0c<\/p>\n<p>\u7f16\u8bd1\u540e\u53c2\u8003\uff1a<\/p>\n<p><img decoding=\"async\" title=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" src=\"http:\/\/cc.cocimg.com\/bbs\/attachment\/Fid_21\/21_53328_b76795b34f0f18c.png\" alt=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" border=\"0\" \/><\/p>\n<p>\u5728build\/Debug-iphonesimulator\u4e0b\u9762\u51fa\u73b0\u4e00\u4e2aframework\u6587\u4ef6\u5939\uff1a<\/p>\n<p><img decoding=\"async\" title=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" src=\"http:\/\/cc.cocimg.com\/bbs\/attachment\/Fid_21\/21_53328_9c4aac869d2fda6.png\" alt=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" width=\"700\" border=\"0\" \/>\u00a0<wbr>\u00a0<wbr><\/p>\n<p><span style=\"font-size: large;\">\u4f7f\u7528\u6211\u4eec\u521a\u624d\u5236\u4f5c\u7684framework<\/span><\/p>\n<p>\u5728\u65b0\u7684\u5de5\u7a0b\u4e2d\u5bfc\u5165framework<\/p>\n<p><img decoding=\"async\" title=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" src=\"http:\/\/cc.cocimg.com\/bbs\/attachment\/Fid_21\/21_53328_fbcf44744201600.png\" alt=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" border=\"0\" \/><br \/>\n\u6211\u4eec\u628a\u521a\u624d\u5236\u4f5c\u7684kibernet.framework\u62f7\u8d1d\u5230\u65b0\u7684\u5de5\u7a0b\u7684\u76ee\u5f55\u4e0b\uff0c\u9009\u62e9kibernet.framework\u6587\u4ef6\u5939<\/p>\n<p>\u6dfb\u52a0\u540e\u7684\u6548\u679c\u56fe<\/p>\n<p><img decoding=\"async\" title=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" src=\"http:\/\/cc.cocimg.com\/bbs\/attachment\/Fid_21\/21_53328_347f7d35424bdb8.png\" alt=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" width=\"700\" border=\"0\" \/><\/p>\n<p>\u4f7f\u7528framework\u4e2d\u7684\u7c7b\uff1a<br \/>\n\u5bfc\u5165\u5934\u6587\u4ef6<\/p>\n<p><img decoding=\"async\" title=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" src=\"http:\/\/cc.cocimg.com\/bbs\/attachment\/Fid_21\/21_53328_9d1f678b4581136.png\" alt=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" border=\"0\" \/><\/p>\n<p>ViewDid Load\u4e2d\u6d4b\u8bd5\u4e00\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" title=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" src=\"http:\/\/cc.cocimg.com\/bbs\/attachment\/Fid_21\/21_53328_2c1b860dfd263cc.png\" alt=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" border=\"0\" \/>\u00a0\u00a0<wbr>\u00a0<wbr>\u00a0<wbr>\u00a0<wbr><br \/>\n\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<p><img decoding=\"async\" title=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" src=\"http:\/\/cc.cocimg.com\/bbs\/attachment\/Fid_21\/21_53328_c26cee64049bf72.png\" alt=\"iOS\u00a0&lt;wbr&gt;framework\u00a0&lt;wbr&gt;\u5236\u4f5c\u6559\u7a0b\" border=\"0\" \/>\u7b2c\u4e8c\u79cd\u65b9\u6cd5\u662f\uff1aiOS-Universal-Framework\u4e00\u4e2a\u6a21\u677f\u521b\u5efa\u3002\u6ce8\u610f\uff1a\u53ea\u652f\u6301xcode4\u30020&#8211;4.5\u4e00\u4e0b\u7684\u7248\u672c<\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr><\/wbr>\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u4f7f\u7528\u4e00\u79cd\u53d8\u901a\u7684\u65b9\u6cd5\u6765\u5236\u4f5c iOS framework,\u6b65\u9aa4\uff1a 1.\u6253\u5f00Xcode\u521b\u5efa\u4e00\u4e2a\u201cCocoa To &#8230; <a title=\"iOS framework \u5236\u4f5c\u6559\u7a0b\" class=\"read-more\" href=\"https:\/\/www.sunyuping.com\/index.php\/2012\/07\/10\/ios-framework-%e5%88%b6%e4%bd%9c%e6%95%99%e7%a8%8b\/\" aria-label=\"\u9605\u8bfb iOS framework \u5236\u4f5c\u6559\u7a0b\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[13],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-uncategorized-2"],"_links":{"self":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":0,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}