{"id":5001,"date":"2022-02-20T20:07:05","date_gmt":"2022-02-20T12:07:05","guid":{"rendered":"http:\/\/123.57.164.21\/?p=5001"},"modified":"2022-02-28T17:52:26","modified_gmt":"2022-02-28T09:52:26","slug":"swift-package-manager%e7%9a%84%e4%b8%80%e4%ba%9btips","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=5001","title":{"rendered":"Swift Package Manager\u7684\u4e00\u4e9bTips"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\">\u6982\u89c8<\/h5>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Swift Package Manager\uff08SPM\uff09\u662f Xcode \u5185\u7f6e\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u652f\u6301\u8fdc\u7a0b\u516c\/\u79c1\u6709\u5e93\u548c\u672c\u5730\u5e93\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u521b\u5efa Package Manager<\/h5>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>\u521b\u5efa\u65b9\u6cd5<\/strong><\/p>\n\n\n\n<p>\u4e24\u79cd\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<ul><li>\u5728 Xcode \u83dc\u5355\u680f\u4f9d\u6b21\u9009\u4e2d&nbsp;<strong>File &gt; New &gt; Package Manager<\/strong><\/li><\/ul>\n\n\n\n<ul><li>\u5728\u76ee\u6807\u6587\u4ef6\u5939\u4e2d\u4f7f\u7528\u547d\u4ee4\uff1a<code>Swift package init<\/code><\/li><\/ul>\n\n\n\n<p>\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u5728&nbsp;<strong>Sources<\/strong>&nbsp;\u6587\u4ef6\u4e0b\u6dfb\u52a0\u4ee3\u7801\uff0c\u7136\u540e\u6309 cmd + B \u7f16\u8bd1\u3002\u5982\u679c\u53d1\u73b0\u7f16\u8bd1\u5668\u62a5\u9519\uff0c\u662f\u56e0\u4e3a\u6d4b\u8bd5\u4ee3\u7801\u6709\u8bef\u3002\u5982\u679c\u6211\u4eec\u4e0d\u9700\u8981\u7f16\u5199\u6d4b\u8bd5\u4ee3\u7801\uff0c\u6ce8\u91ca\u5373\u53ef\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-9-1024x579.png\" alt=\"\" class=\"wp-image-5003\" width=\"600\" height=\"338\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-9-1024x579.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-9-300x170.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-9-1536x869.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-9-230x130.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-9-350x198.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-9.png 1824w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/figure><\/div>\n\n\n\n<p><strong>\u76ee\u5f55\u7ed3\u6784<\/strong><\/p>\n\n\n\n<p>\u5982\u4e0b\u662f\u4e00\u4e2a Package \u7684\u76ee\u5f55\u7ed3\u6784\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">.\n\u251c\u2500\u2500 Package.swift \/\/ \u914d\u7f6e\u6587\u4ef6\n\u251c\u2500\u2500 README.md \/\/ \u5305\u7684\u529f\u80fd\u3001\u4f7f\u7528\u8bf4\u660e\n\u251c\u2500\u2500 Sources \/\/ \u6e90\u7801\u76ee\u5f55\n\u2502   \u2514\u2500\u2500 Biu\n\u2502       \u2514\u2500\u2500 Print.swift\n\u2514\u2500\u2500 Tests \/\/ \u6d4b\u8bd5\u6587\u4ef6\u76ee\u5f55\n    \u251c\u2500\u2500 BiuTests\n    \u2502   \u251c\u2500\u2500 BiuTests.swift\n    \u2502   \u2514\u2500\u2500 XCTestManifests.swift\n    \u2514\u2500\u2500 LinuxMain.swift<\/pre>\n\n\n\n<p><strong>Package.swift<\/strong>&nbsp;\u5305\u542b\u5982\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n<p>\u9700\u8981\u7279\u522b\u6ce8\u610f\u5728<strong>Package.swift<\/strong>\u4e2d\u6307\u5b9a <span class=\"has-inline-color has-vivid-red-color\">platforms<\/span>\uff0c\u4e5f\u5c31\u662f\u8fd9\u4e2aPackage\u80fd\u591f\u652f\u6301\u7684\u5e73\u53f0\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ swift-tools-version:5.3\n\/\/ The swift-tools-version declares the minimum version of Swift required to build this package.\n\nimport PackageDescription\n\nlet package = Package(\n    \/\/ \u5305\u540d\n    name: \"Biu\",\n    \/\/ \u9700\u8981\u6ce8\u610fPackage\u8fd0\u884c\u7684\u5e73\u53f0, \u5426\u5219\u4ee3\u7801\u53ef\u80fd\u7f16\u8bd1\u4e0d\u8fc7\u53bb\uff01\uff01\uff01\uff01\uff01\n    platforms: [\n            .iOS(.v14),\n    ],\n    \/\/ \u5305\u5bf9\u5916\u63d0\u4f9b\u7684 products\uff08\u5e93\u3001\u53ef\u6267\u884c\u6587\u4ef6\uff09\n    products: [\n        .library(\n            name: \"Biu\",\n            targets: [\"Biu\"]),\n    ],\n    \/\/ \u4f9d\u8d56\u7684\u5176\u5b83\u5305\n    dependencies: [\n        \/\/ .package(url: \/* package url *\/, from: \"1.0.0\"),\n    ],\n  \t\/\/ \u5305\u542b\u7684 targets\n    targets: [\n      \t\/\/ \u6bcf\u4e2a target \u6240\u9700\u4f9d\u8d56\n        .target(\n            name: \"Biu\",\n            dependencies: []),\n        .testTarget(\n            name: \"BiuTests\",\n            dependencies: [\"Biu\"]),\n    ]\n)\n<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    name: \u5305\u7684\u9879\u76ee\u540d\u79f0\n    platforms: \u652f\u6301\u7684\u5e73\u53f0\u53ca\u5bf9\u5e94\u5e73\u53f0\u7684\u6700\u4f4e\u7248\u672c\n    targets: \u5305\u542b\u591a\u4e2atarget\u7684\u96c6\u5408\uff0c\u6211\u4eec\u6307\u5b9atarget\u7684\u540d\u5b57\u4e3aZZPackage\uff0cxcode\u4f1a\u81ea\u52a8\u628aSources\/ZZPackage\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u6dfb\u52a0\u5230package\u4e2d\u3002\u5982\u679c\u4f60\u60f3\u518d\u65b0\u5efa\u4e00\u4e2atarget, \u9700\u8981\u5728Sources\/\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u7136\u540e\u518dtargets\u6570\u7ec4\u4e2d\u6dfb\u52a0\u65b0\u7684target\u3002\n    .target\u662fPackageDescription.Target\u5b9e\u4f8b\u7c7b\uff0c\u53c2\u6570\u8bf4\u660e\uff1a\n        name: target\u540d\u5b57\n        dependencies: target\u7684\u4f9d\u8d56\uff0c\u4e3b\u8981\u6307\u5b9aPackage\u6dfb\u52a0\u7684\u4f9d\u8d56module\u7684\u540d\u5b57\n        path: target\u7684\u8def\u5f84\uff0c\u5982\u679c\u81ea\u5b9a\u4e49\u6587\u4ef6\u5939\u9700\u8981\u8bbe\u7f6e\u6b64\u53c2\u6570\n        exclude: target path\u4e2d\u4e0d\u5e0c\u671b\u88ab\u5305\u542b\u7684path\n        sources: \u8d44\u6e90\u6587\u4ef6\u8def\u5f84\n        publicHeadersPath: \u516c\u5171header\u6587\u4ef6\u8def\u5f84\n\n    products: \u5bf9\u5916\u516c\u5f00\u5bfc\u51fatarget\u4ea7\u7269\uff0c\u4f7f\u5f97\u5176\u4ed6target\u80fd\u591f\u4f7f\u7528\u5b83\u4eec\u3002\u5982\u679c\u4e0d\u5199\u4f1a\u7f16\u8bd1\u62a5\u9519\n        .library(\n        name: \"ZZPackage\",\n        type: .static,\n        targets: [\"ZZPackage\"]) : \u53ef\u6307\u5b9a\u9759\u6001\u5e93\u6216\u52a8\u6001\u5e93\uff0c\u9ed8\u8ba4\u9759\u6001\u5e93\n\n    dependencies: \u6dfb\u52a0\u5305\u6240\u4f9d\u8d56\u7684\u5176\u4ed6\u7b2c\u4e09\u65b9package\u5305\u7684\u96c6\u5408\n        .package(url: \"https:\/\/github.com\/Alamofire\/Alamofire.git\", from: \"5.0.0\"),\n        .package(url: \"https:\/\/github.com\/SnapKit\/SnapKit.git\", from: .init(5, 0, 1)),\n        .package(url: \"https:\/\/github.com\/SnapKit\/SnapKit.git\", from: .init(stringLiteral: \"5.0.1\")),\n        .package(url: \"https:\/\/github.com\/SnapKit\/SnapKit.git\", Package.Dependency.Requirement.branch(\"master\")), : \u6307\u5b9a\u5206\u652f\uff0c\u5982\u679c\u7b2c\u4e09\u65b9\u4e0d\u652f\u6301spm\u7684\u8bdd\u53ef\u4ee5\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\n        .package(path: \"..\/ZZPackage\") : \u5173\u8054\u672c\u5730\u7684SPM\u5e93\n\n    swiftLanguageVersions: \u652f\u6301\u7684swift\u7248\u672c<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>\u672c\u5730\u6dfb\u52a0\u548c\u6d4b\u8bd5 Package<\/strong><\/h5>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<ul><li>\u65b0\u5efa\u4e00\u4e2a Biu_test \u5de5\u7a0b\uff0c\u76f4\u63a5\u5c06 Biu \u76ee\u5f55\u62d6\u5165\u5de5\u7a0b<\/li><li><strong>General -&gt; Frameworks, Libraries, and Embedded Content<\/strong>&nbsp;\u4e0b\u6dfb\u52a0 Package<\/li><li>\u5bfc\u5165 Package\uff08<code>import Biu<\/code>\uff09\u5373\u53ef<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-11-1024x642.png\" alt=\"\" class=\"wp-image-5005\" width=\"665\" height=\"416\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-11-1024x642.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-11-300x188.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-11-768x481.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-11-1536x963.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-11-830x520.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-11-230x144.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-11-350x219.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-11-480x301.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-11.png 1774w\" sizes=\"(max-width: 665px) 100vw, 665px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-12-1024x599.png\" alt=\"\" class=\"wp-image-5006\" width=\"670\" height=\"391\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-12-1024x599.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-12-300x175.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-12-768x449.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-12-1536x898.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-12-830x486.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-12-230x135.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-12-350x205.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-12-480x281.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-12.png 1754w\" sizes=\"(max-width: 670px) 100vw, 670px\" \/><\/figure><\/div>\n\n\n\n<p>\u6ce8\uff1a\u5982\u9047\u5230\u65e0\u6cd5\u5bfc\u5165\u6216\u627e\u4e0d\u5230 Package \u7684\u95ee\u9898\uff0c\u53ef\u5c1d\u8bd5\u9000\u51fa\u5de5\u7a0b\u6216\u91cd\u542f Xcode \u89e3\u51b3 \ud83e\udd37\u200d\u2642\ufe0f<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u53d1\u5e03\u4e0e\u66f4\u65b0 Package<\/h5>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u53ef\u4ee5\u4f7f\u7528 Git \u547d\u4ee4\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 Xcode \u5185\u7f6e\u7684\u7248\u672c\u63a7\u5236\u5de5\u5177\u3002<\/p>\n\n\n\n<p>\u521d\u6b21\u53d1\u5e03\u65f6\uff0c\u521d\u59cb\u5316 Package \u4e3a Git \u4ed3\u5e93\uff0c\u6253\u4e0a Tag\uff0c\u518d\u63a8\u9001\u81f3\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/p>\n\n\n\n<p>\u66f4\u65b0 Package \u540e\uff0c\u6253\u4e0a\u65b0\u7684 Tag\uff0cPush \u5373\u53ef\u3002<\/p>\n\n\n\n<p><strong>\u4f7f\u7528 Package<\/strong><\/p>\n\n\n\n<p><strong>\u6dfb\u52a0<\/strong><\/p>\n\n\n\n<p>\u6211\u4eec\u5148\u79fb\u9664\u4e0a\u6587\u4e2d\u7684\u5de5\u7a0b Biu_test \u5f15\u5165\u7684\u672c\u5730 Package\uff08Biu\uff09\uff0c\u7136\u540e\u5728 Xcode \u4e2d\u9009\u62e9&nbsp;<strong>File &gt; Swift Packages &gt; Add Package Dependency&#8230;<\/strong>\uff0c\u8f93\u5165 Package \u5730\u5740\uff08<a href=\"https:\/\/github.com\/keisme\/Biu\">https:\/\/github.com\/keisme\/Biu<\/a>\uff09\uff0c\u70b9\u51fb Next \u5b89\u88c5\u3002<\/p>\n\n\n\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u91cd\u65b0\u8fd0\u884c\u9879\u76ee\uff0c\u7ed3\u679c\u4e0e\u9884\u671f\u4e00\u81f4\u3002<\/p>\n\n\n\n<p><strong>\u66f4\u65b0<\/strong><\/p>\n\n\n\n<p>\u5982\u679c\u9700\u8981\u66f4\u65b0 Package\uff0c\u9009\u62e9&nbsp;<strong>File &gt; Swfit Packages &gt; Update to Latest Package Versions<\/strong>\u3002<\/p>\n\n\n\n<p><strong>\u79fb\u9664<\/strong><\/p>\n\n\n\n<p>\u5728\u5de5\u7a0b\u4e2d\u627e\u5230&nbsp;<strong>Swift Package Manager<\/strong>\uff0c\u79fb\u9664\u76f8\u5e94\u7684 Package\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-14-1024x345.png\" alt=\"\" class=\"wp-image-5009\" width=\"680\" height=\"229\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-14-1024x345.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-14-300x101.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-14-768x259.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-14-1536x517.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-14-830x280.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-14-230x77.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-14-350x118.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-14-480x162.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-14.png 1734w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/figure><\/div>\n\n\n\n<h5 class=\"wp-block-heading\">Package\u7684\u4f8b\u5b50<\/h5>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>File &gt; New &gt; Package Manager<\/strong> \u521b\u5efa\u4e00\u4e2aTestPackage<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-15-1024x681.png\" alt=\"\" class=\"wp-image-5013\" width=\"659\" height=\"438\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-15-1024x681.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-15-300x200.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-15-768x511.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-15-1536x1022.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-15-2048x1363.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-15-830x552.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-15-230x153.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-15-350x233.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-15-480x319.png 480w\" sizes=\"(max-width: 659px) 100vw, 659px\" \/><\/figure><\/div>\n\n\n\n<p>\u521b\u5efa\u4e00\u4e2aSwiftUIView\u7c7b<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-29-1024x655.png\" alt=\"\" class=\"wp-image-5038\" width=\"649\" height=\"415\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-29-1024x655.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-29-300x192.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-29-768x491.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-29-1536x982.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-29-830x531.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-29-230x147.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-29-350x224.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-29-480x307.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-29.png 1936w\" sizes=\"(max-width: 649px) 100vw, 649px\" \/><\/figure><\/div>\n\n\n\n<p>\u6211\u4eec\u628aTestPackage\u4e0a\u4f20\u5230Github\u4e0a\u53bb\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-19-1024x740.png\" alt=\"\" class=\"wp-image-5017\" width=\"673\" height=\"486\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-19-1024x740.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-19-300x217.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-19-768x555.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-19-1536x1110.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-19-2048x1480.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-19-830x600.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-19-230x166.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-19-350x253.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-19-480x347.png 480w\" sizes=\"(max-width: 673px) 100vw, 673px\" \/><\/figure><\/div>\n\n\n\n<p>\u65b0\u5efa\u4e00\u4e2aXcode\u5de5\u7a0b&#8211;&gt;\u70b9\u51fb<strong>File<\/strong>&#8211;&gt; <strong>Add Packages<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-21-1024x549.png\" alt=\"\" class=\"wp-image-5022\" width=\"667\" height=\"357\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-21-1024x549.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-21-300x161.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-21-768x412.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-21-1536x823.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-21-2048x1098.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-21-830x445.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-21-230x123.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-21-350x188.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-21-480x257.png 480w\" sizes=\"(max-width: 667px) 100vw, 667px\" \/><\/figure><\/div>\n\n\n\n<p>\u53f3\u4e0a\u89d2\u8f93\u5165github\u7684url -&gt; \u9009\u62e9<strong>Add Github Enterprise account<\/strong>\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-22-1024x523.png\" alt=\"\" class=\"wp-image-5023\" width=\"678\" height=\"346\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-22-1024x523.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-22-300x153.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-22-768x392.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-22-1536x784.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-22-2048x1046.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-22-830x424.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-22-230x117.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-22-350x179.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-22-480x245.png 480w\" sizes=\"(max-width: 678px) 100vw, 678px\" \/><\/figure><\/div>\n\n\n\n<p>\u8f93\u5165Account \u548c Token\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-23-1024x576.png\" alt=\"\" class=\"wp-image-5026\" width=\"693\" height=\"389\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-23-1024x576.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-23-300x169.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-23-768x432.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-23-1536x864.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-23-830x467.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-23-230x129.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-23-350x197.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-23-480x270.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-23.png 2020w\" sizes=\"(max-width: 693px) 100vw, 693px\" \/><\/figure><\/div>\n\n\n\n<p>Token\u7684\u83b7\u53d6\u65b9\u6cd5\uff0cSetting -&gt; Developer settings<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-24-1024x827.png\" alt=\"\" class=\"wp-image-5027\" width=\"694\" height=\"560\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-24-1024x827.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-24-300x242.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-24-768x620.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-24-1536x1240.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-24-830x670.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-24-230x186.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-24-350x283.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-24-480x388.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-24.png 1890w\" sizes=\"(max-width: 694px) 100vw, 694px\" \/><\/figure><\/div>\n\n\n\n<p>Personal access tokens &#8211;&gt; Generate new token<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-25-1024x318.png\" alt=\"\" class=\"wp-image-5029\" width=\"727\" height=\"225\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-25-1024x318.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-25-300x93.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-25-768x238.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-25-1536x477.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-25-830x258.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-25-230x71.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-25-350x109.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-25-480x149.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-25.png 1992w\" sizes=\"(max-width: 727px) 100vw, 727px\" \/><\/figure><\/div>\n\n\n\n<p>\u7528Token\u767b\u5f55\u540e\uff0c\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2aTestPackage  \u70b9\u51fbAdd Package\u6dfb\u52a0\u5230\u5de5\u7a0b<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-26-1024x562.png\" alt=\"\" class=\"wp-image-5031\" width=\"704\" height=\"386\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-26-1024x562.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-26-300x165.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-26-768x421.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-26-1536x843.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-26-2048x1124.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-26-830x455.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-26-230x126.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-26-350x192.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-26-480x263.png 480w\" sizes=\"(max-width: 704px) 100vw, 704px\" \/><\/figure><\/div>\n\n\n\n<p>\u5728DemoApp\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u53ef\u4ee5\u5f15\u7528\u5230 TestPackage\u4e2d\u7684 SwiftUIView\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-30-1024x488.png\" alt=\"\" class=\"wp-image-5039\" width=\"714\" height=\"340\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-30-1024x488.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-30-300x143.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-30-768x366.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-30-1536x732.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-30-2048x976.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-30-830x395.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-30-230x110.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-30-350x167.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-30-480x229.png 480w\" sizes=\"(max-width: 714px) 100vw, 714px\" \/><\/figure><\/div>\n\n\n\n<h5 class=\"wp-block-heading\">Swift Package Manager \u6dfb\u52a0\u8d44\u6e90\u6587\u4ef6<\/h5>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u4ece\u66f4\u65b0\u5230\u73b0\u5728\uff0cSwiftPM \u4ee4\u4eba\u8bdf\u75c5\u7684\u4e00\u4e2a\u95ee\u9898\u5c31\u662f\u65e0\u6cd5\u5728\u5305\u91cc\u6dfb\u52a0\u8d44\u6e90\u6587\u4ef6\u3002\u8fd9\u5bf9\u4e8e\u5df2\u7ecf\u4e60\u60ef\u4e8e\u4f7f\u7528 CocoaPods \u7684\u5f00\u53d1\u8005\u9020\u6210\u4e86\u5f88\u5927\u7684\u9ebb\u70e6\uff0c\u5f53\u7136\u76ee\u524d SwiftPM \u5dee\u4e8e Cocoapods \u4e0d\u6b62\u8fd9\u4e00\u70b9\u3002SwiftPM \u4e5f\u610f\u8bc6\u5230\u4e86\u8fd9\u4e00\u70b9\uff0c\u4ece\u53bb\u5e74\u5c31\u53ef\u4ee5\u770b\u5230 github \u7684 SwiftPM \u5bf9\u5e94\u4ed3\u5e93\u7684\u6709 <code>resource<\/code> \u7b49 API \u76f8\u5173\u63d0\u4ea4\u3002<\/p>\n\n\n\n<p>\u6b64\u6b21\u7684 SwiftPM \u66f4\u65b0\u4e2d\u9664\u4e86\u4e0a\u9762\u8bf4\u7684\u53ef\u4ee5\u6dfb\u52a0\u8d44\u6e90\u6587\u4ef6\uff0c\u8fd8\u6dfb\u52a0\u4e86\u672c\u5730\u5316\u7b49\u529f\u80fd\u3002<\/p>\n\n\n\n<p>SwiftPM \u7684\u8d44\u6e90\u6587\u4ef6\u7ba1\u7406\u529f\u80fd\u5728 swift-tool-version 5.3\uff0c\u5373 Swift 5.3\uff0c\u5bf9\u5e94 Xcode 12\u3002\u6240\u4ee5 <code>package.swift<\/code> \u914d\u7f6e\u4e2d\u9700\u8981\u58f0\u660e swift 5.3 \u4ee5\u4e0a(\u8fd9\u884c\u5e76\u4e0d\u662f\u6ce8\u91ca\uff0c\u800c\u662f\u6587\u4ef6\u89e3\u6790\u4e2d\u5fc5\u987b\u7684\u914d\u7f6e)\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-63-1024x483.png\" alt=\"\" class=\"wp-image-5160\" width=\"499\" height=\"235\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-63-1024x483.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-63-300x141.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-63-768x362.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-63-830x391.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-63-230x108.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-63-350x165.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-63-480x226.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-63.png 1340w\" sizes=\"(max-width: 499px) 100vw, 499px\" \/><\/figure><\/div>\n\n\n\n<p><strong>\u6dfb\u52a0\u548c\u914d\u7f6e\u8d44\u6e90\u6587\u4ef6<\/strong><\/p>\n\n\n\n<p>\u5bf9\u4e8e\u4e00\u4e9b\u4f7f\u7528\u76ee\u7684\u660e\u786e\u7684\u6587\u4ef6\u7c7b\u578b\uff0c\u6bd4\u5982\u4e0b\u9762\u56fe\u4e2d\u7684\u8fd9\u4e9b\u3002\u5f00\u53d1\u8005\u4e0d\u9700\u8981\u5728 <code>package.swift<\/code> \u6587\u4ef6\u4e2d\u914d\u7f6e\u4efb\u4f55\u4e1c\u897f\uff0c\u56e0\u4e3a Xcode \u77e5\u9053\u8fd9\u4e9b\u7c7b\u578b\u7684\u6587\u4ef6\u662f\u4ee3\u8868\u4ec0\u4e48\uff0c\u6bd4\u5982 <code>.xcassets<\/code> \u6587\u4ef6\u4ee3\u8868\u56fe\u7247\u3001\u989c\u8272\u8d44\u6e90\uff0c <code>xib<\/code> \u4ee3\u8868\u7528\u6237\u754c\u9762\u6587\u4ef6\u7b49<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-65-1024x455.png\" alt=\"\" class=\"wp-image-5162\" width=\"577\" height=\"256\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-65-1024x455.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-65-300x133.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-65-768x341.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-65-830x368.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-65-230x102.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-65-350x155.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-65-480x213.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-65.png 1266w\" sizes=\"(max-width: 577px) 100vw, 577px\" \/><\/figure><\/div>\n\n\n\n<p><br>\u800c\u5bf9\u4e8e\u4e00\u4e9b\u4f7f\u7528\u76ee\u7684\u4e0d\u592a\u660e\u786e\u7684\u6587\u4ef6\u7c7b\u578b\uff08\u5982\u4e0b\u56fe\u4e2d\u7684\u4e00\u4e9b\u6587\u4ef6\u7c7b\u578b\uff09\uff0c\u5219\u9700\u8981\u5728 <code>package.swift<\/code> \u6587\u4ef6\u4e2d\u914d\u7f6e\u3002\u4f8b\u5982\u7eaf\u6587\u672c\u6587\u4ef6\uff0c\u8fd9\u79cd\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u53ef\u80fd\u662f\u9700\u8981\u5728\u8fd0\u884c\u65f6\u88ab\u52a0\u8f7d\u800c\u8ba1\u7b97\u6216\u8005\u5c55\u793a\uff0c\u4e5f\u53ef\u80fd\u53ea\u662f\u4e00\u4e2a\u5f00\u53d1\u8005\u6587\u6863\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-66-1024x497.png\" alt=\"\" class=\"wp-image-5163\" width=\"572\" height=\"277\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-66-1024x497.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-66-300x146.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-66-768x373.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-66-830x403.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-66-230x112.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-66-350x170.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-66-480x233.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-66.png 1302w\" sizes=\"(max-width: 572px) 100vw, 572px\" \/><\/figure><\/div>\n\n\n\n<p>\u5bf9\u4e8e\u4e0a\u9762\u8fd9\u79cd\u610f\u4e49\u4e0d\u660e\u7684\u6587\u4ef6\uff0c\u5c31\u9700\u8981\u5728 <code>package.swift<\/code> \u6e05\u5355\u4e2d\u6839\u636e\u89c4\u5219\u914d\u7f6e\uff0c\u4e0b\u9762\u4ee5\u8fd9\u4e2a GameLogin \u4f5c\u4e3a\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-67-1024x535.png\" alt=\"\" class=\"wp-image-5165\" width=\"578\" height=\"301\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-67-1024x535.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-67-300x157.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-67-768x401.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-67-830x434.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-67-230x120.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-67-350x183.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-67-480x251.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-67.png 1274w\" sizes=\"(max-width: 578px) 100vw, 578px\" \/><\/figure><\/div>\n\n\n\n<ul><li>\u5bf9\u4e8e <code>Media.xcasset<\/code> \u548c <code>main.storyboard<\/code> \u6587\u4ef6\uff0cXcode \u80fd\u660e\u786e\u77e5\u9053\u5b83\u4ee3\u8868\u4ec0\u4e48\uff0c\u6240\u4ee5\u4e0d\u9700\u8981\u5728\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6\u4e2d\u6807\u8bb0<\/li><li><code>internal Note.txt<\/code> \u6587\u4ef6\u548c <code>Artwork Creation<\/code> \u6587\u4ef6\u5939\u662f\u6a21\u5757\u5185\u90e8\u6587\u4ef6\uff0c\u6240\u4ee5\u5199\u5728 <code>target<\/code> \u7684 <code>exclude<\/code> \u5c5e\u6027\u4e2d\uff0c\u8fd9\u6837 Xcode \u5c31\u4e0d\u4f1a\u628a\u5b83\u7f16\u8bd1\u5230\u5305\u91cc<\/li><li>\u5176\u4ed6\u4e0d\u80fd\u81ea\u52a8\u8bc6\u522b\u7684\u7c7b\u578b\u5e76\u4e14\u9700\u8981\u88ab\u52a0\u8f7d\u5230 package \u91cc\u7684\u6587\u4ef6\u5219\u914d\u7f6e\u5728 <code>resource<\/code> \u5c5e\u6027\u4e2d\u3002<\/li><\/ul>\n\n\n\n<p>\u4e0a\u9762\u5c31\u662f\u914d\u7f6e\u8d44\u6e90\u6587\u4ef6\u7684\u4e00\u4e9b\u89c4\u5219\uff0c\u5176\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5bf9\u4e8e <code>resource<\/code> \u5c5e\u6027\uff0c\u6709\u4e24\u4e2a\u9759\u6001\u65b9\u6cd5\uff1a <code>process()<\/code> \u548c <code>copy()<\/code> \u3002\u6839\u636e session \u4e2d\u7684\u4ecb\u7ecd\uff0c <code>process()<\/code> \u662f\u63a8\u8350\u7684\u65b9\u5f0f\uff0c\u5b83\u6240\u914d\u7f6e\u7684\u6587\u4ef6\u4f1a\u6839\u636e\u5177\u4f53\u4f7f\u7528\u7684\u5e73\u53f0\u548c\u5185\u7f6e\u89c4\u5219\u8fdb\u884c\u9002\u5f53\u7684\u4f18\u5316\u3002\u6bd4\u5982\u5728\u8fd0\u884c\u65f6\u5c06 <code>storyboard<\/code> \u6216\u8005 <code>asset catalog<\/code> \u8f6c\u6362\u6210\u9002\u5f53\u7684\u5f62\u5f0f\uff0c\u4e5f\u5305\u62ec\u538b\u7f29\u56fe\u7247\u7b49\u3002\u5982\u679c\u6587\u4ef6\u7c7b\u578b\u65e0\u6cd5\u8bc6\u522b\uff0c\u6216\u8005\u4e0d\u80fd\u6839\u636e\u5e73\u53f0\u505a\u4efb\u4f55\u4f18\u5316\uff0c\u5c31\u53ea\u4f1a\u88ab\u7b80\u5355\u7684\u62f7\u8d1d\uff0c\u4e5f\u5c31\u662f <code>copy()<\/code> \u3002<\/p>\n\n\n\n<p><strong>\u6784\u5efa\u8fc7\u7a0b<\/strong><\/p>\n\n\n\n<p>\u5f53\u4e00\u4e2a App \u4f7f\u7528 package \u65f6\uff0c\u8fd9\u4e2a package \u5305\u62ec\u6e90\u6587\u4ef6\u548c\u8d44\u6e90\u6587\u4ef6\u3002\u5728\u7f16\u8bd1\u65f6\u9996\u5148\u4f1a\u5c06 Package \u4e2d\u6bcf\u4e2a target \u7684\u6e90\u6587\u4ef6\u7f16\u8bd1\u6210 module \u94fe\u63a5\u5230 App \u4e2d\uff0c\u7136\u540e\u8fd9\u4e9b target \u4e2d\u7684\u8d44\u6e90\u6587\u4ef6\u5219\u4f1a\u88ab\u52a0\u5de5\u6210 bundle \u653e\u5230\u8fd9\u4e9b module \u4e2d\u3002<br><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-68-1024x469.png\" alt=\"\" class=\"wp-image-5167\" width=\"593\" height=\"271\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-68-1024x469.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-68-300x137.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-68-768x352.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-68-830x380.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-68-230x105.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-68-350x160.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-68-480x220.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-68.png 1310w\" sizes=\"(max-width: 593px) 100vw, 593px\" \/><\/figure><\/div>\n\n\n\n<p>\u5728 Apple \u5e73\u53f0\u4e2d\uff0cApp \u548c App extension \u90fd\u662f bundle \u96c6\u5408\uff0c\u8fd9\u4e9b package \u7684 bundle \u5c31\u662f App \u7684\u4e00\u90e8\u5206\uff0c\u6240\u4ee5\u4e0d\u9700\u8981\u505a\u5176\u4ed6\u5904\u7406\uff0c\u5c31\u80fd\u5728\u8fd0\u884c\u65f6\u83b7\u53d6\u8fd9\u4e9b bundle\u3002 \u5f53\u88ab\u7f16\u8bd1\u5230\u4e00\u4e2a unbundle \u4ea7\u7269\u65f6\uff0c\u6bd4\u5982\u811a\u672c\u5de5\u5177\uff0c\u5219\u9700\u8981\u5728\u811a\u672c\u542f\u52a8\u7684\u540c\u65f6\u52a0\u8f7d\u8d44\u6e90 bundle(\u8fd9\u4e00\u6b65\u7684\u5177\u4f53\u6b65\u9aa4\u8fd8\u4e0d\u592a\u7406\u89e3)<\/p>\n\n\n\n<p><strong>\u8bbf\u95ee\u8d44\u6e90\u6587\u4ef6<\/strong><\/p>\n\n\n\n<p>\u5728\u7f16\u8bd1\u6709\u8d44\u6e90\u6587\u4ef6\u7684 Package \u4e2d\uff0c\u4f1a\u81ea\u52a8\u521b\u5efa\u5e76\u6dfb\u52a0\u5230 module \u4e2d\u4e00\u4e2a\u6587\u4ef6\uff1a<code>resource_bundle_accessor.swift<\/code> \uff0c\u91cc\u9762\u7684\u5185\u5bb9\u5927\u6982\u7b49\u4ef7\u4e8e\u4e0b\u9762\u8fd9\u6837\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import Foundation\nextension Bundle {\n\tstatic let module = Bundle(path: \"\\(Bundle.main.bundlePath)\/path\/to\/this\/targets\/resource\/bundle\")\n}\n<\/pre>\n\n\n\n<p>\u5bf9\u4e8e Swift \u548c OC \u5206\u522b\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u8fd9\u79cd\u65b9\u5f0f\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u4f7f\u7528 UIImage \u81ea\u5df1\u7684\u5e26\u6709 <code>Bundle<\/code> \u53c2\u6570\u7684 Api\u3001<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-69-1024x236.png\" alt=\"\" class=\"wp-image-5168\" width=\"591\" height=\"135\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-69-1024x236.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-69-300x69.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-69-768x177.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-69-830x191.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-69-230x53.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-69-350x81.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-69-480x111.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-69.png 1232w\" sizes=\"(max-width: 591px) 100vw, 591px\" \/><\/figure><\/div>\n\n\n\n<p>\u5bf9\u4e8eSwiftUI\u6765\u8bf4\uff0c\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7<strong><span class=\"has-inline-color has-vivid-red-color\">Bundle.modul<\/span>e <\/strong>\u6765\u8bbf\u95ee\uff0c\u56fe\u7247\u653e\u5230Target\u4e0b\u9762\u7684\u7684Media.xcassets\u5373\u53ef<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-70.png\" alt=\"\" class=\"wp-image-5170\" width=\"563\" height=\"299\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-70.png 1000w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-70-300x160.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-70-768x409.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-70-830x442.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-70-230x122.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-70-350x186.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-70-480x255.png 480w\" sizes=\"(max-width: 563px) 100vw, 563px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">struct HeaderBackgroundView: View {\n\n    var body: some View {\n        GeometryReader { gr in\n            ZStack {\n                Image(\"imageName\", bundle: Bundle.module).resizable().frame(width: gr.size.width, height: gr.size.height * 0.26)\n            }.frame(width: gr.size.width, height: gr.size.height * 0.26)\n        }\n    }\n}<\/pre>\n\n\n\n<p>\u9898\u5916\u8bdd\uff1a\u5728SwiftUI\u4e2d\u8bfb\u53d6\u6307\u5b9aBundle\u4e2d\u56fe\u7247\u7684\u4f8b\u5b50<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import SwiftUI\n\nstruct ContentView: View {\n    \n    var body: some View {\n        Group{\n            if let resBundlePath = Bundle.main.path(forResource: \"Resources\", ofType: \"bundle\"),\n               let resBundle = Bundle(path: resBundlePath),\n               let uiImage = UIImage(named: \"imagename\", in: resBundle, with: nil){\n                    Image(uiImage: uiImage)\n                        .resizable()\n                        .scaledToFit()\n            }else{\n                Color.red\n            }\n        }\n    }\n}\n\n<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Package\u4e2d\u5f00\u53d1SwiftUI\u753b\u9762<br><\/h5>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5728Package\u4e2d\u5f00\u53d1SwiftUI\u753b\u9762\u6709\u4e9b\u5c34\u5c2c\uff0c\u59cb\u7ec8\u6ca1\u627e\u5230\u8fd0\u884c\u7684\u65b9\u6cd5\uff0c\u53ea\u80fd\u5148\u901a\u8fc7 SwiftUIView_Previews\u6765\u8c03\u8bd5\u4e86\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-71-1024x645.png\" alt=\"\" class=\"wp-image-5173\" width=\"502\" height=\"316\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-71-1024x645.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-71-300x189.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-71-768x484.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-71-1536x967.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-71-2048x1289.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-71-830x523.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-71-230x145.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-71-350x220.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/02\/\u56fe\u7247-71-480x302.png 480w\" sizes=\"(max-width: 502px) 100vw, 502px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u89c8 Swift Package Manager\uff08SPM\uff09\u662f Xcode \u5185\u7f6e\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u652f\u6301\u8fdc\u7a0b\u516c\/\u79c1\u6709\u5e93 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,8],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/5001"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5001"}],"version-history":[{"count":21,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/5001\/revisions"}],"predecessor-version":[{"id":5177,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/5001\/revisions\/5177"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}