{"id":40,"date":"2012-10-11T18:14:15","date_gmt":"2012-10-11T10:14:15","guid":{"rendered":"http:\/\/sunyuping.cn\/?p=40"},"modified":"2012-10-11T18:14:15","modified_gmt":"2012-10-11T10:14:15","slug":"ios%e5%bc%80%e5%8f%91%e4%b9%8b-%e9%9d%99%e6%80%81%e5%ba%93%e7%9a%84%e7%bc%96%e8%af%91%e4%bb%a5%e5%8f%8a%e7%9b%b8%e5%85%b3%e9%97%ae%e9%a2%98%e7%9a%84%e5%a4%84%e7%90%86","status":"publish","type":"post","link":"https:\/\/www.sunyuping.com\/index.php\/2012\/10\/11\/ios%e5%bc%80%e5%8f%91%e4%b9%8b-%e9%9d%99%e6%80%81%e5%ba%93%e7%9a%84%e7%bc%96%e8%af%91%e4%bb%a5%e5%8f%8a%e7%9b%b8%e5%85%b3%e9%97%ae%e9%a2%98%e7%9a%84%e5%a4%84%e7%90%86\/","title":{"rendered":"iOS\u5f00\u53d1\u4e4b&#8212;\u9759\u6001\u5e93\u7684\u7f16\u8bd1\u4ee5\u53ca\u76f8\u5173\u95ee\u9898\u7684\u5904\u7406"},"content":{"rendered":"<p>\t\t\t\t\u9759\u6001\u5e93\u7684\u7f16\u5199\uff1a<\/p>\n<p>1.\u9759\u6001\u5e93\u5de5\u7a0b\u7684\u5efa\u7acb\uff1aXcode New\u4e00\u4e2a\u65b0\u7684project\uff0c\u9009\u62e9IOS\u4e0b\u9762\u7684Framework&amp;Library\uff0c\u4e0b\u9762\u6709\u4e00\u4e2aCocoa Touch Static Library\u3002\u76f4\u63a5next\u53bb\u5efa\u7acb\u4e00\u4e2astaticlib\u8fd9\u6837\u7684\u5de5\u7a0b\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/hi.csdn.net\/attachment\/201110\/25\/0_1319509726mY65.gif\" alt=\"\" \/><\/p>\n<p>2.\u5de5\u7a0b\u5efa\u7acb\u4e86\uff0c\u6211\u4eec\u6dfb\u52a0\u4e00\u4e2a\u5f88\u7b80\u5355\u7684&#8221;- (void)helloworld;&#8221;\u7684\u65b9\u6cd5\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u7684\u5b9e\u73b0\u4e5f\u662f\u5f88\u7b80\u5355\u7684\uff0c\u5728*.m\u6587\u4ef6\u4e2d\u7684\u5b9e\u73b0\u5c31\u662f\u4e00\u4e2a&#8221;NSLog\uff08@\u201chelloworld\u201d);&#8221;\u8fd9\u6837\u6211\u4eec\u7f16\u8bd1\u51fa\u6765\u7684libstaticlib\u5c31\u53ef\u4ee5\u88ab\u5176\u4ed6\u7684IOS\u5de5\u7a0b\u8fdb\u884c\u8c03\u7528\u4e86\u3002\u8fd9\u5757\u6ce8\u610f\u4e00\u4e0b\uff0c\u76ee\u524d\u6211\u4eec\u7684staticlib-&gt;iOS Device<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/hi.csdn.net\/attachment\/201110\/25\/0_1319509948ejF2.gif\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/hi.csdn.net\/attachment\/201110\/25\/0_13195101673b6e.gif\" alt=\"\" \/><\/p>\n<p>3.OK\uff0c\u7f16\u8bd1\uff0c\u6211\u4eec\u53ef\u4ee5\u5728Products\u4e0b\u9762\u627e\u5230\u6211\u4eec\u7f16\u8bd1\u751f\u6210\u7684libstaticlib.a\u8fd9\u4e2a\u6587\u4ef6\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/hi.csdn.net\/attachment\/201110\/25\/0_131951021146rR.gif\" alt=\"\" \/><\/p>\n<p>4.ok\uff0c\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e0aOpen In Finder\u3002\u8fd9\u65f6\u5019\u6211\u4eec\u6253\u5f00\u4e86\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u91cc\u9762\u6709\u4e00\u4e2alibstaticlib.a\u3002\u540e\u9762\u6211\u4eec\u7ee7\u7eed\u7f16\u5199\u4e00\u4e2a\u8c03\u7528\u8fd9\u4e2alibstaticlib.a\u7684Base UI App\u3002\u4f46\u662f\u8fd9\u4e2aApp\u5728\u7f16\u8bd1\u65f6\u5019\u4f1a\u51fa\u9519\uff0c\u901a\u8fc7\u8fd9\u4e2a\u9519\u8bef\u7684\u89e3\u51b3\uff0c\u8bf4\u660eXcode\u7684\u4e00\u4e9b\u7f16\u8bd1\u76f8\u5173\u7684\u4e1c\u897f\u3002\u8fd9\u91cc\uff0c\u6211\u4eec\u5728command\u4e0b\u9762\u6839\u636e\u8def\u5f84\u627e\u5230\u8fd9\u4e2a\u6587\u4ef6\uff0c\u7528\u8fd9\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u547d\u4ee4\u67e5\u770b\u4e00\u4e0b\u8fd9\u4e2alib\u7684\u4fe1\u606f\uff01\u547d\u4ee4\u662f\uff1alipo -info libstaticlib.a\uff0c\u53ef\u4ee5\u770b\u5230\u663e\u793a\u7684\u7ed3\u679c\u662f\uff1aArch\u662fArm6 Arm7\u3002\u5982\u679c\u53ea\u662f\u505a\u5e94\u7528\u7684\u670b\u53cb\u53ef\u80fd\u4e0d\u662f\u5f88\u4e86\u89e3\u8fd9\u4e2a\u4e1c\u897f\uff0c\u540e\u9762\u6211\u4f1a\u5177\u4f53\u4ecb\u7ecd\u4e00\u4e0b\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/hi.csdn.net\/attachment\/201110\/25\/0_1319510458ndL1.gif\" alt=\"\" \/><\/p>\n<p>5.\u5c06\u8fd9\u4e2alibstaticlib.a\u62f7\u8d1d\u51fa\u6765\uff0c\u7528\u4e8e\u540e\u9762\u5e94\u7528\u7684\u8c03\u7528\u3002<\/p>\n<p>6.\u5efa\u7acb\u4e00\u4e2a\u8c03\u7528\u8fd9\u4e2astaticilib\u7684\u5e94\u7528\u3002\u5e94\u7528\u5c31\u5f88\u7b80\u5355\u4e86\uff0c\u5c31\u662f\u4e00\u4e2a\u5f88\u7b80\u5355\u7684base UI\u7684app\u5c31\u53ef\u4ee5\u3002OK\uff0c\u6211\u4eec\u6dfb\u52a0\u521a\u624dstatic lib\u7684*.h\u6587\u4ef6\u3002<\/p>\n<p>\u7136\u540e\u5728\u8fd9\u4e2a\u5de5\u7a0b\u7684Build Phases\u7684Link Binary With Library\u91cc\u9762\u6dfb\u52a0\u6211\u4eec\u521a\u624d\u62f7\u8d1d\u51fa\u6765\u7684\u90a3\u4e2alibstaticlib.a\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/hi.csdn.net\/attachment\/201110\/25\/0_13195114914q40.gif\" alt=\"\" \/><\/p>\n<p>7.\u63d2\u5165\u4e86h\u548ca\u6587\u4ef6\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5728control\u91cc\u9762\u8c03\u7528\u8fd9\u4e2astaticlib\u91cc\u9762\u7684\u51fd\u6570\u4e86\u3002<\/p>\n<p>8.\u51fd\u6570\u7684\u8c03\u7528\u5c31\u6bd4\u8f83\u7b80\u5355\u4e86\u3002<\/p>\n<p>\u5728statictestViewController.m\u8fd9\u4e2a\u6587\u4ef6\u4e2d\uff0c#import &#8220;staticlib.h&#8221;\u8fd9\u4e2a\u5934\u6587\u4ef6\u3002<\/p>\n<p>\u7136\u540e\u5728<\/p>\n<p>&#8211; (void)viewDidLoad<\/p>\n<p>{<br \/>\nstaticlib *a = [[staticlib alloc]init];<br \/>\n[a helloworld];<br \/>\n[super viewDidLoad];<br \/>\n}<\/p>\n<p>9.OK\uff0c\u7f16\u8bd1\u8fd0\u884c\u8fd9\u4e2a\u5e94\u7528\u7a0b\u5e8f\u3002\u989d\u3002\u3002\u3002\u9519\u8bef\u4e86\u3002\u3002\u8fd9\u4e2a\u5c31\u662f\u8fd9\u7bc7\u6587\u6863\u7684\u5173\u952e\u4e86\u3002\u4e3b\u8981\u5c31\u662f\u4e3a\u4e86\u4ecb\u7ecd\u7f16\u8bd1\u9759\u6001\u5e93\u76f8\u5173\u7684\u4e1c\u897f\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/hi.csdn.net\/attachment\/201110\/25\/0_131951234185Uk.gif\" alt=\"\" \/><\/p>\n<p>10.\u53ef\u4ee5\u770b\u5230undefine symbols for architecture i386\u8fd9\u6837\u7684\u9519\u8bef\u3002\u5176\u5b9e\u8fd9\u4e2a\u9519\u8bef\u539f\u56e0\u5f88\u7b80\u5355\uff0c\u5c31\u662f\u56e0\u4e3a\uff0c\u6211\u4eec\u7528\u9519\u4e86\u7f16\u8bd1\u51fa\u6765\u7684static lib\uff0c\u5728\u6a21\u62df\u5668\u91cc\u9762\uff0c\u6211\u4eec\u9700\u8981\u7684\u662f\u57fa\u4e8ei386\u6784\u67b6\u7f16\u8bd1\u7684static lib\uff0c\u4f46\u662f\u8fd9\u4e2aa\u6587\u4ef6\uff0c\u5927\u5bb6\u8fd8\u8bb0\u5f97\u524d\u9762\u8bf4\u7684arm6 arm7\u6784\u67b6\u7684\u4e48\u3002\u8fd9\u4e2aa\u5176\u5b9e\u662f\u5728iphone\u8fd9\u4e2aarm\u6784\u67b6\u4e0a\u8fd0\u884c\u7684\u4ee3\u7801\u3002\u5176\u5b9eshow in finder\u6307\u5411\u7684\u662f\u4e00\u4e2aios device\u7684\u5e93\uff0c\u5e76\u4e0d\u662fi386\u6a21\u62df\u5668\u4e0b\u7684\u5e93\u3002\u90a3\u5982\u4f55\u7f16\u8bd1i386\u7684\u5e93\u5462\uff1f\u8fd8\u8bb0\u5f97\u4e0a\u9762\u8bf4\u7684staticlib-&gt;iOS Device\u4e48\uff1f\u6211\u4eec\u5c06\u8fd9\u4e2aiOS Device\u4fee\u6539\u6210iPhone4.3 Simulator\u3002\u5728\u8fdb\u884c\u7f16\u8bd1\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u7f16\u8bd1\u51fai386\u4e0b\u9762\u7684\u5e93\u3002\u8fd9\u4e2a\u65f6\u5019\u6211\u4eecshow in finder\u6253\u5f00\u7684\u6587\u4ef6\u5939\u8fd8\u662fios device\u4e0b\u7684\u5e93\u3002\u6211\u4eec\u6700\u597d\u81ea\u5df1\u53bb\u90a3\u4e2a\u76ee\u5f55\u4e0b\u770b\u4e00\u4e0b\u3002\u8fd9\u91cc\u6211\u4eec\u7528command\u53bb\u67e5\u770b\u4e86\u4e00\u4e0b\u76ee\u5f55\u60c5\u51b5\uff0c\u5982\u4e0b\uff1a\u53ef\u4ee5\u770b\u5230\u4e00\u4e2aiphoneos\u7684\u76ee\u5f55\u548c\u4e00\u4e2asimulator\u7684\u76ee\u5f55\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/hi.csdn.net\/attachment\/201110\/25\/0_1319512855EN9D.gif\" alt=\"\" \/><\/p>\n<p>11.\u8fd9\u4e8c\u4e2a\u6587\u4ef6\u5939\u4e0b\u7684\uff0cdebug-iphoneos\u91cc\u9762\u7684\u662f\u57fa\u4e8earm6 arm7\u7f16\u8bd1\u51fa\u6765\u7684\u5e93\u6587\u4ef6\u3002debug-iphonesimulator\u6587\u4ef6\u5939\u4e0b\u9762\u7684\u662f\u57fa\u4e8ei386\u7f16\u8bd1\u51fa\u6765\u7684\u6587\u4ef6\u3002\u5982\u56fe\uff0c\u53ef\u4ee5\u6ce8\u610fcommand\u91cc\u9762\u663e\u793a\u7684\u4fe1\u606f\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/hi.csdn.net\/attachment\/201110\/25\/0_1319513030aTHJ.gif\" alt=\"\" \/><\/p>\n<p>12.\u8fd9\u4e2a\u53ef\u4ee5\u770b\u5230\u6211\u4eec\u4e00\u4e2a\u6784\u67b6\u662farmv6 armv7\u548ci386\u7684\u3002\u6709\u4e8c\u4e2a\u5e93\uff0c\u8fd9\u4e8c\u4e2a\u5e93\u4e00\u4e2a\u662f\u7528\u4e8e\u771f\u673a\u8fd0\u884c\u7684\u4e00\u4e2a\u662f\u7528\u4e8e\u6a21\u62df\u5668\u8fd0\u884c\u7684\u3002<\/p>\n<p>13.\u5176\u5b9e\u6211\u4eec\u53ef\u4ee5\u5229\u7528lipo\u5c06\u8fd9\u4e8c\u4e2a\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2a\u901a\u7528\u7684a\u6587\u4ef6\u3002\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/hi.csdn.net\/attachment\/201110\/25\/0_1319513185Ul4W.gif\" alt=\"\" \/><\/p>\n<p>14.\u6253\u5305\u4ee5\u540e\u7684\u5e93\u6587\u4ef6\uff0c\u6211\u4eec\u67e5\u770b\u4fe1\u606f\uff0c\u53ef\u4ee5\u770b\u5230\u5982\u4e0b\u4fe1\u606f\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/hi.csdn.net\/attachment\/201110\/25\/0_1319513238NV79.gif\" alt=\"\" \/><\/p>\n<p>\u73b0\u5728\u6211\u4eec\u8fd9\u4e2a\u9759\u6001\u5e93\uff0c\u652f\u6301\u7684\u6784\u67b6\u5df2\u7ecf\u662farmv6 armv7 i386\u4e86\u3002<\/p>\n<p>15.ok\uff0c\u8fd9\u4e2a\u901a\u7528\u5e93\u751f\u6210\u540e\uff0c\u6211\u4eec\u5c06\u539f\u6765\uff0c\u8c03\u7528\u8fd9\u4e2a\u5e93\u8fdb\u884c\u66ff\u6362\u4e00\u4e0b\uff0c\u5728\u8fdb\u884c\u7f16\u8bd1\uff0c\u6210\u529f\u7f16\u8bd1\uff0c\u5e76\u4e14\u53ef\u4ee5\u770b\u5230\u5728\u547d\u4ee4\u884c\u91cc\u9762\u663e\u793a\u7684\u6211\u4eechelloworld\u8fd9\u4e2a\u51fd\u6570\u6253\u5370\u51fa\u6765\u7684\u4e1c\u897f\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/hi.csdn.net\/attachment\/201110\/25\/0_1319513330jHkg.gif\" alt=\"\" \/><\/p>\n<p>OK\uff0c\u6210\u529f\u3002\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9759\u6001\u5e93\u7684\u7f16\u5199\uff1a 1.\u9759\u6001\u5e93\u5de5\u7a0b\u7684\u5efa\u7acb\uff1aXcode New\u4e00\u4e2a\u65b0\u7684project\uff0c\u9009\u62e9IOS\u4e0b\u9762\u7684Framewo &#8230; <a title=\"iOS\u5f00\u53d1\u4e4b&#8212;\u9759\u6001\u5e93\u7684\u7f16\u8bd1\u4ee5\u53ca\u76f8\u5173\u95ee\u9898\u7684\u5904\u7406\" class=\"read-more\" href=\"https:\/\/www.sunyuping.com\/index.php\/2012\/10\/11\/ios%e5%bc%80%e5%8f%91%e4%b9%8b-%e9%9d%99%e6%80%81%e5%ba%93%e7%9a%84%e7%bc%96%e8%af%91%e4%bb%a5%e5%8f%8a%e7%9b%b8%e5%85%b3%e9%97%ae%e9%a2%98%e7%9a%84%e5%a4%84%e7%90%86\/\" aria-label=\"\u9605\u8bfb iOS\u5f00\u53d1\u4e4b&#8212;\u9759\u6001\u5e93\u7684\u7f16\u8bd1\u4ee5\u53ca\u76f8\u5173\u95ee\u9898\u7684\u5904\u7406\">\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":[11],"class_list":["post-40","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-jineng"],"_links":{"self":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts\/40","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=40"}],"version-history":[{"count":0,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/posts\/40\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/media?parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/categories?post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sunyuping.com\/index.php\/wp-json\/wp\/v2\/tags?post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}