{"id":6429,"date":"2023-10-09T12:33:34","date_gmt":"2023-10-09T04:33:34","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=6429"},"modified":"2023-10-09T12:33:34","modified_gmt":"2023-10-09T04:33:34","slug":"ios-framework%e6%89%93%e5%8c%85%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e7%9a%84%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/6429\/","title":{"rendered":"ios framework\u6253\u5305\u5982\u4f55\u5b9e\u73b0\u7684\uff1f"},"content":{"rendered":"

iOS framework\u662fiOS\u5f00\u53d1\u4e2d\u5e38\u7528\u7684\u4e00\u79cd\u5f00\u53d1\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5c06\u4e00\u4e2a\u6216\u591a\u4e2a\u7f16\u5199\u597d\u7684OC\u6216Swift\u6587\u4ef6\u548c\u8d44\u6e90\u6253\u5305\u6210\u4e00\u4e2a\u9759\u6001\u5e93\uff0c\u65b9\u4fbf\u5728\u591a\u4e2a\u9879\u76ee\u4e2d\u590d\u7528\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u590d\u7528\u6027\u3002\u672c\u6587\u5c06\u5bf9iOS framework\u6253\u5305\u7684\u539f\u7406\u548c\u8be6\u7ec6\u64cd\u4f5c\u8fdb\u884c\u4ecb\u7ecd\u3002<\/p>\n

\u4e00\u3001iOS Framework\u6253\u5305\u7684\u539f\u7406<\/p>\n

1. iOS Framework\u7684\u5b9a\u4e49<\/p>\n

iOS Framework\u662f\u5c06\u5e38\u7528\u7684\u4ee3\u7801\u6253\u5305\u4e3a\u4e00\u4e2a\u9759\u6001\u5e93\uff0c\u5e38\u4e0eOC\u8fdb\u884c\u914d\u5408\u4f7f\u7528\uff0c\u53ef\u4ee5\u4f7f\u5f00\u53d1\u8005\u628a\u4e00\u4e9b\u5171\u7528\u4ee3\u7801\u6253\u5305\u6210 Framework \u90e8\u7f72\u5230 App \u4e2d\uff0c\u8fbe\u5230\u8282\u7701\u5927\u91cf\u4ee3\u7801\u3001\u6709\u6548\u51cf\u5c11\u6587\u4ef6\u5927\u5c0f\u4ee5\u53ca\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u7684\u6548\u679c\u3002<\/p>\n

2. iOS Framework\u7684\u4f18\u70b9<\/p>\n

\u67e5\u770bios\u6253\u5305\u8bc1\u4e66\u8fc7\u671f\u65f6\u95f4<\/a>\u901a\u8fc7iOS Framework\u7684\u65b9\u5f0f\uff0c\u80fd\u591f\u5b9e\u73b0\u591a\u4e2a\u9879\u76ee\u4e4b\u95f4\u4ee3\u7801\u7684\u9ad8\u5ea6\u590d\u7528\uff0c\u63d0\u9ad8\u5f00\u53d1\u4eba\u5458\u7684\u5de5\u4f5c<\/p>\n

<\/figure>\n<\/p>\n

\u6548\u7387\u3002\u540c\u65f6\uff0c\u4f7f\u7528Framework\u53ef\u4ee5\u4fbf\u6377\u7684\u8fdb\u884c\u7248\u672c\u66f4\u65b0\u3001\u591a\u4e2a\u9879\u76ee\u7684\u7edf\u4e00\u7ef4\u62a4\u548c\u7ba1\u7406\uff0c\u4f7f\u5f97\u4ee3\u7801\u7684\u53ef\u7ef4\u62a4\u6027\u548c\u53ef\u91cd\u7528\u6027\u5f97\u5230\u5927\u5927\u63d0\u5347\u3002<\/p>\n

3. iOS Framework\u7684\u7f3a\u70b9<\/p>\n

\u4f7f\u7528iOS Framework\u9700\u6ce8\u610f\uff0c\u5b83\u53ea\u80fd\u88ab\u4f7f\u7528\u4e8e\u5f00\u53d1\u8005\u81ea\u5df1\u7684\u5e94\u7528\u4e2d\uff0c\u8fd9\u5c31\u610f\u5473\u7740\u6253\u51fa\u7684Framework\u53ea\u80fd\u5728\u672c\u516c\u53f8\u7684App\u4e2d\u4f7f\u7528\uff0c\u5e76\u4e14\u4e0d\u9002\u5408\u4e8e\u5f00\u6e90\u56e2\u961f\u9879\u76ee\u7b49\u516c\u5171\u4ee3\u7801\u7684\u60c5\u51b5\u3002<\/p>\n

\u4e8c\u3001iOS Framework\u6253\u5305\u7684\u6b65\u9aa4<\/p>\n

1. \u521b\u5efaiOS Framework<\/p>\n

\u6253\u5f00Xcode\uff0c\u9009\u62e9File -> New -> Project\uff0c\u9009\u62e9iOS -> Framework & Library -> Cocoa Touch Framework\uff0c\u8f93\u5165\u9700\u8981\u521b\u5efa\u7684Framework\u540d\u79f0\u548c\u9009\u62e9\u5b58\u653e\u4f4d\u7f6e\uff0c\u6700\u540e\u70b9\u51fbCreate\u6309\u94ae\u521b\u5efa\u3002<\/p>\n

2. \u6784\u5efaiOS Framework<\/p>\n

\u5728\u521b\u5efa\u597d\u7684Framework\u4e2d\uff0c\u6211\u4eec\u5c06\u4e3b\u8981\u6587\u4ef6\u653e\u5165\u5176\u4e2d\uff0c\u5e76\u4f9d\u636e\u8981\u6c42\u6784\u5efa\u597d\u81ea\u5df1\u9700\u8981\u7684\u7c7b\u548c\u5176\u4ed6\u5185\u5bb9\u3002\u4e3a\u4e86\u8fbe\u5230\u4ee3\u7801\u590d\u7528\u7684\u76ee\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u591a\u4e2a\u9879\u76ee\u516c\u7528\u7684\u7c7b\u548c\u65b9\u6cd5\u6253\u5305\u5728\u4e00\u8d77\uff0cios \u4e0a\u67b6\u6253\u5305 loader<\/a>\u5f62\u6210\u4e00\u4e2aFramework\u8fdb\u884c\u7edf\u4e00\u7ba1\u7406\uff0c\u8fd9\u6837\u53ef\u4ee5\u7b80\u5316\u5f00\u53d1\u6d41\u7a0b\uff0c\u907f\u514d\u91cd\u590d\u52b3\u52a8\u3002<\/p>\n

3. \u7f16\u8bd1iOS Framework<\/p>\n

\u5728\u5b8c\u6210Framework\u7684\u5f00\u53d1\u540e\uff0c\u9700\u8981\u8fdb\u884c\u7f16\u8bd1\uff0c\u4ee5\u751f\u6210Framework\u7684\u9759\u6001\u5e93\u3002\u9996\u5148\uff0c\u9700\u8981\u9009\u62e9Framework\u9879\u76ee\u7684Target\uff0c\u70b9\u51fbBuild Phases -> Link Binary With Libraries -> Add Other\uff0c\u9009\u62e9\u751f\u6210\u7684\u9759\u6001\u5e93\u6587\u4ef6\u8fdb\u884c\u5bfc\u5165\u3002<\/p>\n

4. \u6253\u5305iOS Framework<\/p>\n

\u5728\u7f16\u8bd1\u751f\u6210\u4e86iOS Framework\u9759\u6001\u5e93\u540e\uff0c\u9700\u8981\u628aFramework\u6253\u5305\u6210.framework\u683c\u5f0f\u65b9\u4fbf\u5176\u4ed6\u9879\u76ee\u53ef\u4ee5\u5bfc\u5165\u4f7f\u7528\u3002\u70b9\u51fb\u9879\u76ee\u5de6\u4fa7\u8fd0\u884c\u83dc\u5355\uff0c\u9009\u62e9\u6a21\u62df\u5668\u6216\u8005\u771f\u673a\uff0c\u5728Xcode\u8f93\u51fa\u9762\u677f\u4e2d\u53ef\u4ee5\u770b\u5230Framework\u7684\u8def\u5f84\uff0c\u5c06\u8def\u5f84\u8f93\u5165\u7ec8\u7aef\u547d\u4ee4\u884c\u4e2d\uff0c\u8f93\u5165\u547d\u4ee4\uff1a<\/p>\n

lipo -create Framework\u8def\u5f84\/Release-iphonesimulator\/Framework.framework\/Framework Framework\u8def\u5f84\/Release-iphoneos\/Framework.framework\/Framework -output Framework\u8def\u5f84\/Framework<\/p>\n

\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u751f\u6210\u4e00\u4e2aiOS Framework\u7684\u53ef\u7528\u9759\u6001\u5e93\u4e86\u3002<\/p>\n

5. \u5bfc\u5165iOS Framework<\/p>\n

\u5728\u5176\u4ed6\u9879\u76ee\u4e2d\u9700\u8981\u4f7f\u7528\u8be5iOS Framework\u65f6\uff0c\u5148\u5c06\u5176\u5bfc\u5165\u5230\u65b0\u9879\u76ee\u4e2d\u3002\u5728Xcode\u4e2d\uff0c\u9009\u62e9\u9700\u8981\u5bfc\u5165Framework\u7684Target\uff0c\u70b9\u51fbBuild Phases -> Link Binary With Libraries -> Add Other\uff0c\u5f15\u5165\u6211\u4eec\u521a\u624d\u6253\u5305\u597d\u7684.framework\u6587\u4ef6\u3002<\/p>\n

6. \u94fe\u63a5iOS Framework<\/p>\n

\u5728\u4f7f\u7528\u5bfc\u5165\u7684Framework\u65f6\uff0c\u5728\u9700\u8981\u7528\u5230\u7684\u6587\u4ef6\u4e2d\uff0c\u9700\u8981\u5f15\u5165\u76f8\u5e94\u7684\u5934\u6587\u4ef6\uff0c\u4ee5\u4f7f\u7528Framework\u4e2d\u7684\u7c7b\u548c\u65b9\u6cd5\u3002\u540c\u65f6\uff0c\u8fd8\u9700\u8981\u5728\u9879\u76ee\u7684Build Settings\u4e2d\u627e\u5230\u201cOther Linker Flags\u201d\u9879\uff0c\u6dfb\u52a0\u201c-ObjC\u201d\u6807\u5fd7\uff0c\u4fdd\u8bc1Framework\u80fd\u6b63\u786e\u7684\u94fe\u63a5\u3002<\/p>\n

\u4e09\u3001\u603b\u7ed3<\/p>\n

\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\u7684\u4ecb\u7ecd\uff0c\u6211\u4eec\u53ef\u4ee5\u4e86\u89e3\u5230\u6253\u5305iOS Framework\u7684\u8fc7\u7a0b\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\uff1aFramework\u6587\u4ef6\u4e0d\u80fd\u88ab\u5171\u4eab\u7ed9\u5916\u90e8\u7684\u5176\u4ed6app\u4f7f\u7528\u3002\u901a\u8fc7\u6253\u5305Framework\uff0c\u53ef\u4ee5\u5c06\u4ee3\u7801\u7528\u4e8e\u591a\u4e2a\u9879\u76ee\uff0c\u5927\u5927\u63d0\u9ad8\u4e86\u4ee3\u7801\u7684\u590d\u7528\u6027\uff0c\u540c\u65f6\u4e5f\u66f4\u5bb9\u6613\u7ef4\u62a4\u548c\u7ba1\u7406\u4ee3\u7801\u3002\u6240\u4ee5\u5bf9\u4e8e\u591a\u4e2a\u9879\u76ee\u4e2d\u516c\u7528\u7684\u90e8\u5206\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u6253\u5305\u6210Framework\u7684\u5f62\u5f0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

iOS framework\u662fiOS\u5f00\u53d1\u4e2d\u5e38\u7528\u7684\u4e00\u79cd\u5f00\u53d1\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5c06\u4e00\u4e2a\u6216\u591a\u4e2a\u7f16\u5199\u597d\u7684OC\u6216Swift\u6587\u4ef6\u548c\u8d44\u6e90\u6253\u5305\u6210\u4e00\u4e2a\u9759\u6001\u5e93\uff0c\u65b9\u4fbf\u5728\u591a\u4e2a\u9879\u76ee\u4e2d\u590d\u7528\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u590d\u7528\u6027\u3002\u672c\u6587\u5c06\u5bf9iOS framewo<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[9860,11707,29,1006,23],"topic":[],"class_list":{"0":"post-6429","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-appkf","7":"tag-ios","9":"tag-29","10":"tag-1006","11":"tag-23"},"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/6429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=6429"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/6429\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=6429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=6429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=6429"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=6429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}