{"id":175,"date":"2019-07-12T13:29:00","date_gmt":"2019-07-12T05:29:00","guid":{"rendered":"https:\/\/www.xianyuba.cn\/?p=175"},"modified":"2024-12-27T16:15:24","modified_gmt":"2024-12-27T08:15:24","slug":"%e9%97%b2%e9%b1%bcflutter%e6%b7%b7%e5%90%88%e5%b7%a5%e7%a8%8b%e6%8c%81%e7%bb%ad%e9%9b%86%e6%88%90%e7%9a%84%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b5","status":"publish","type":"post","link":"https:\/\/www.xianyuba.cn\/index.php\/2019\/07\/12\/%e9%97%b2%e9%b1%bcflutter%e6%b7%b7%e5%90%88%e5%b7%a5%e7%a8%8b%e6%8c%81%e7%bb%ad%e9%9b%86%e6%88%90%e7%9a%84%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b5\/","title":{"rendered":"\u95f2\u9c7cFlutter\u6df7\u5408\u5de5\u7a0b\u6301\u7eed\u96c6\u6210\u7684\u6700\u4f73\u5b9e\u8df5"},"content":{"rendered":"<header class=\"article-header\">\n<h1 class=\"article-title\">\u00a0<\/h1>\n<\/header>\n<article class=\"article-content\">\n<h2 id=\"1\">1. \u5f15\u8a00<\/h2>\n<p>\u5728\u4e4b\u524d\u7684\u6587\u7ae0\u300aFlutter\u6df7\u5408\u5de5\u7a0b\u6539\u9020\u5b9e\u8df5\u300b\u4e2d\uff0c\u6709\u4e9b\u540c\u5b66\u7559\u8a00\u60f3\u4e86\u89e3\u62bd\u53d6Flutter\u4f9d\u8d56\u5230\u8fdc\u7a0b\u7684\u4e00\u4e9b\u5b9e\u73b0\u7ec6\u8282\uff0c\u6240\u4ee5\u672c\u6587\u91cd\u70b9\u6765\u8bb2\u4e00\u8bb2Flutter\u6df7\u5408\u5de5\u7a0b\u4e2d\u7684Flutter\u76f4\u63a5\u4f9d\u8d56\u89e3\u9664\u7684\u4e00\u4e9b\u5177\u4f53\u5b9e\u73b0\u3002<\/p>\n<h2 id=\"2\">2. \u601d\u8003<\/h2>\n<p>\u56e0\u4e3a\u76ee\u524d\u6211\u4eec\u95f2\u9c7c\u662fFlutter\u548cNative\u6df7\u5408\u5f00\u53d1\u7684\u6a21\u5f0f\uff0c\u6240\u4ee5\u5b58\u5728\u4e00\u90e8\u5206\u540c\u5b66\u53ea\u505aNative\u5f00\u53d1\uff0c\u5e76\u4e0d\u719f\u6089Flutter\u6280\u672f\u3002<br \/>\uff081\uff09\u5982\u679c\u76f4\u63a5\u91c7\u7528Flutter\u5de5\u7a0b\u7ed3\u6784\u6765\u4f5c\u4e3a\u65e5\u5e38\u5f00\u53d1\uff0c\u90a3\u8fd9\u90e8\u5206Native\u5f00\u53d1\u540c\u5b66\u4e5f\u9700\u8981\u914d\u7f6eFlutter\u73af\u5883\uff0c\u4e86\u89e3Flutter\u4e00\u4e9b\u6280\u672f\uff0c\u6210\u672c\u6bd4\u8f83\u5927\u3002<br \/>\uff082\uff09\u963f\u91cc\u96c6\u56e2\u7684\u6784\u5efa\u7cfb\u7edf\u76ee\u524d\u5e76\u4e0d\u652f\u6301\u76f4\u63a5\u6784\u5efaFlutter\u9879\u76ee\uff0c\u8fd9\u4e2a\u4e5f\u8981\u6c42\u6211\u4eec\u89e3\u9664Native\u5de5\u7a0b\u5bf9Flutter\u7684\u76f4\u63a5\u4f9d\u8d56\u3002<br \/>\u9274\u4e8e\u8fd9\u4e24\u70b9\u539f\u56e0\uff0c\u6211\u4eec\u5e0c\u671b\u53ef\u4ee5\u8bbe\u8ba1\u4e00\u4e2a<strong>Flutter\u4f9d\u8d56\u62bd\u53d6\u6a21\u5757<\/strong>\uff0c\u53ef\u4ee5\u5c06Flutter\u7684\u4f9d\u8d56\u62bd\u53d6\u4e3a\u4e00\u4e2aFlutter\u4f9d\u8d56\u5e93\u53d1\u5e03\u5230\u8fdc\u7a0b\uff0c\u4f9b\u7eafNative\u5de5\u7a0b\u5f15\u7528\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<\/article>\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"901\" src=\"https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-82-1024x901.png\" alt=\"\" class=\"wp-image-176\" srcset=\"https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-82-1024x901.png 1024w, https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-82-300x264.png 300w, https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-82-768x676.png 768w, https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-82.png 1279w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n<figure class=\"wp-block-image\"><\/figure>\n<blockquote class=\"wp-block-quote\">\n<p>Flutter\u76f4\u63a5\u4f9d\u8d56\u89e3\u9664<\/p>\n<\/blockquote>\n<h2 id=\"3\">3. \u5b9e\u73b0<\/h2>\n<h3 id=\"4\">3.1 Native\u5de5\u7a0b\u4f9d\u8d56\u7684Flutter\u5206\u6790<\/h3>\n<p>\u6211\u4eec\u5206\u6790Flutter\u5de5\u7a0b\uff0c\u4f1a\u53d1\u73b0Native\u5de5\u7a0b\u5bf9Flutter\u5de5\u7a0b\u7684\u4f9d\u8d56\u4e3b\u8981\u6709\u4e09\u90e8\u5206\uff1a<br \/>\n<strong>1. Flutter\u5e93\u548c\u5f15\u64ce:<\/strong>\u00a0Flutter\u7684Framework\u5e93\u548c\u5f15\u64ce\u5e93\u3002<br \/>\n<strong>2. Flutter\u5de5\u7a0b:<\/strong>\u00a0\u6211\u4eec\u81ea\u5df1\u5b9e\u73b0\u7684Flutter\u6a21\u5757\u529f\u80fd\uff0c\u4e3b\u8981\u4e3aFlutter\u5de5\u7a0b\u4e0blib\u76ee\u5f55\u4e0b\u7684dart\u4ee3\u7801\u5b9e\u73b0\u7684\u8fd9\u90e8\u5206\u529f\u80fd\u3002<br \/>\n<strong>3. \u81ea\u5df1\u5b9e\u73b0\u7684Flutter Plugin:<\/strong>\u00a0\u6211\u4eec\u81ea\u5df1\u5b9e\u73b0\u7684Flutter Plugin\u3002<\/p>\n<figure class=\"wp-block-image\">\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"457\" src=\"https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-83-1024x457.png\" alt=\"\" class=\"wp-image-177\" srcset=\"https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-83-1024x457.png 1024w, https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-83-300x134.png 300w, https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-83-768x343.png 768w, https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-83.png 1280w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n<\/figure>\n<p>\u6211\u4eec\u89e3\u5f00Android\u548ciOS\u7684APP\u6587\u4ef6\uff0c\u53d1\u73b0Flutter\u4f9d\u8d56\u7684\u4e3b\u8981\u6587\u4ef6\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<blockquote class=\"wp-block-quote\">\n<p>Flutter\u4f9d\u8d56\u7684\u6587\u4ef6\uff08Flutter\u4ea7\u7269\uff09<\/p>\n<\/blockquote>\n<p><strong>\u5176\u4e2d\uff0c<\/strong><br \/>\n<strong>Android\u7684Flutter\u4f9d\u8d56\u7684\u6587\u4ef6\uff1a<\/strong><br \/>\n<strong>1. Flutter\u5e93\u548c\u5f15\u64ce\uff1a<\/strong><br \/>\nicudtl.dat\u3001libflutter.so\u3001\u8fd8\u6709\u4e00\u4e9bclass\u6587\u4ef6\u3002\u8fd9\u4e9b\u90fd\u5c01\u88c5\u5728flutter.jar\u4e2d\uff0c\u8fd9\u4e2ajar\u6587\u4ef6\u4f4d\u4e8eFlutter\u5e93\u76ee\u5f55\u4e0b\u7684[flutter\/bin\/cache\/artifacts\/engine]\u4e0b\u3002<br \/>\n<strong>2. Flutter\u5de5\u7a0b\u4ea7\u7269\uff1a<\/strong><br \/>\nisolate_snapshot_data\u3001isolate_snapshot_instr\u3001vm_snapshot_data\u3001vm_snapshot_instr\u3001flutter_assets\u3002<br \/>\n<strong>3. Flutter Plugin\uff1a<\/strong><br \/>\n\u5404\u4e2aplugin\u7f16\u8bd1\u51fa\u6765\u7684aar\u6587\u4ef6\u3002<br \/>\n<strong>\u5176\u4e2d\uff1a<\/strong><\/p>\n<ul>\n<li>isolate_snapshot_data \u5e94\u7528\u7a0b\u5e8f\u6570\u636e\u6bb5<\/li>\n<li>isolate_snapshot_instr \u5e94\u7528\u7a0b\u5e8f\u6307\u4ee4\u6bb5<\/li>\n<li>vm_snapshot_data VM\u865a\u62df\u673a\u6570\u636e\u6bb5<\/li>\n<li>vm_snapshot_instr VM\u865a\u62df\u673a\u6307\u4ee4\u6bb5<\/li>\n<\/ul>\n<p><strong>iOS\u7684Flutter\u4f9d\u8d56\u7684\u6587\u4ef6\uff1a<\/strong><br \/>\n<strong>1. Flutter\u5e93\u548c\u5f15\u64ce\uff1a<\/strong>Flutter.framework<br \/>\n<strong>2. Flutter\u5de5\u7a0b\u7684\u4ea7\u7269\uff1a<\/strong>App.framework<br \/>\n<strong>3. Flutter Plugin\uff1a<\/strong>\u7f16\u8bd1\u51fa\u6765\u7684\u5404\u79cdplugin\u7684framework\uff0c\u56fe\u4e2d\u7684\u5176\u4ed6framework<\/p>\n<p>\u90a3\u6211\u4eec\u53ea\u9700\u8981\u5c06\u8fd9\u4e09\u90e8\u5206\u7684\u7f16\u8bd1\u7ed3\u679c\u62bd\u53d6\u51fa\u6765\uff0c\u6253\u5305\u6210\u4e00\u4e2aSDK\u4f9d\u8d56\u7684\u5f62\u5f0f\u63d0\u4f9b\u7ed9Native\u5de5\u7a0b\uff0c\u5c31\u53ef\u4ee5\u89e3\u9664Native\u5de5\u7a0b\u5bf9Flutter\u5de5\u7a0b\u7684\u76f4\u63a5\u4f9d\u8d56\u3002<\/p>\n<h3 id=\"5\">3.2 Android\u4f9d\u8d56\u7684Flutter\u5e93\u62bd\u53d6<\/h3>\n<h4 id=\"6\">3.2.1 Android\u4e2dFlutter\u7f16\u8bd1\u4efb\u52a1\u5206\u6790<\/h4>\n<p>Flutter\u5de5\u7a0b\u7684Android\u6253\u5305\uff0c\u5176\u5b9e\u53ea\u662f\u5728Android\u7684Gradle\u4efb\u52a1\u4e2d\u63d2\u5165\u4e86\u4e00\u4e2aflutter.gradle\u7684\u4efb\u52a1\uff0c\u800c\u8fd9\u4e2aflutter.gradle\u4e3b\u8981\u505a\u4e86\u4e09\u4ef6\u4e8b\uff1a\uff08\u8fd9\u4e2a\u6587\u4ef6\u53ef\u4ee5\u5728Flutter\u5e93\u4e2d\u7684[flutter\/packages\/flutter_tools\/gradle]\u76ee\u5f55\u4e0b\u80fd\u627e\u5230\u3002\uff09<br \/>\n<strong>1.<\/strong>\u00a0\u589e\u52a0flutter.jar\u7684\u4f9d\u8d56\u3002<br \/>\n<strong>2.<\/strong>\u00a0\u63d2\u5165Flutter Plugin\u7684\u7f16\u8bd1\u4f9d\u8d56\u3002<br \/>\n<strong>3.<\/strong>\u00a0\u63d2\u5165Flutter\u5de5\u7a0b\u7684\u7f16\u8bd1\u4efb\u52a1\uff0c\u6700\u7ec8\u5c06\u4ea7\u7269\uff08\u4e24\u4e2aisolaate_snapshot\u6587\u4ef6\u3001\u4e24\u4e2avm_snapshot\u6587\u4ef6\u548cflutter_assets\u6587\u4ef6\u5939\uff09\u62f7\u8d1d\u5230mergeAssets.outputDir\uff0c\u6700\u7ec8merge\u5230APK\u7684assets\u76ee\u5f55\u4e0b\u3002<\/p>\n<h4 id=\"7\">3.2.2 Android\u7684Flutter\u4f9d\u8d56\u62bd\u53d6\u5b9e\u73b0<\/h4>\n<p>\u5f04\u660e\u767dFlutter\u5de5\u7a0b\u7684Android\u7f16\u8bd1\u4ea7\u7269\u4e4b\u540e\uff0c\u56e0\u6b64\u6211\u4eec\u5bf9Android\u7684Flutter\u4f9d\u8d56<strong>\u62bd\u53d6\u6b65\u9aa4\u5982\u4e0b<\/strong>\uff1a<br \/>\n<strong>1. \u7f16\u8bd1Flutter\u5de5\u7a0b\u3002<\/strong><br \/>\n\u8fd9\u90e8\u5206\u4e3b\u8981\u5de5\u4f5c\u662f\u7f16\u8bd1Flutter\u7684dart\u548c\u8d44\u6e90\u90e8\u5206\uff0c\u53ef\u4ee5\u7528AOT\u548cBundle\u547d\u4ee4\u7f16\u8bd1\u3002<\/p>\n<pre class=\"wp-block-code\"><code>echo \"Clean old build\"\nfind . -d -name \"build\" | xargs rm -rf\n.\/flutter\/bin\/flutter clean\n\necho \"Get packages\"\n.\/flutter\/bin\/flutter packages get\n\necho \"Build release AOT\"\n.\/flutter\/bin\/flutter build aot --release --preview-dart-2 --output-dir=build\/flutteroutput\/aot\necho \"Build release Bundle\"\n.\/flutter\/bin\/flutter build bundle --precompiled --preview-dart-2 --asset-dir=build\/flutteroutput\/flutter_assets<\/code><\/pre>\n<p><strong>2. \u5c06flutter.jar\u548cFlutter\u5de5\u7a0b\u7684\u4ea7\u7269\u6253\u5305\u6210\u4e00\u4e2aaar\u3002<\/strong><br \/>\n\u8fd9\u8fb9\u90e8\u5206\u7684\u4e3b\u8981\u5de5\u4f5c\u662f\u5c06flutter.jar\u548c\u7b2c1\u6b65\u7f16\u8bd1\u7684\u4ea7\u7269\u5c01\u88c5\u6210\u4e00\u4e2aaar\u3002<br \/>\n\uff081\uff09\u6dfb\u52a0flutter.jar\u4f9d\u8d56<\/p>\n<pre class=\"wp-block-code\"><code>project.android.buildTypes.each {\n    addFlutterJarImplementationDependency(project, releaseFlutterJar)\n}\nproject.android.buildTypes.whenObjectAdded {\n    addFlutterJarImplementationDependency(project, releaseFlutterJar)\n}\n\nprivate static void addFlutterJarImplementationDependency(Project project, releaseFlutterJar) {\n    project.dependencies {\n        String configuration\n        if (project.getConfigurations().findByName(\"implementation\")) {\n            configuration = \"implementation\"\n        } else {\n            configuration = \"compile\"\n        }\n        add(configuration, project.files {\n            releaseFlutterJar\n        })\n    }\n}<\/code><\/pre>\n<p>\uff082\uff09Merge Flutter\u7684\u4ea7\u7269\u5230assets<\/p>\n<pre class=\"wp-block-code\"><code>\/\/ merge flutter assets\ndef allertAsset =\"${project.projectDir.getAbsolutePath()}\/flutter\/assets\/release\"\nTask mergeFlutterAssets = project.tasks.create(name: \"mergeFlutterAssets${variant.name.capitalize()}\", type: Copy) {\n    dependsOn mergeFlutterMD5Assets\n    from (allertAsset){\n        include \"flutter_assets\/**\" \/\/ the working dir and its files\n        include \"vm_snapshot_data\"\n        include \"vm_snapshot_instr\"\n        include \"isolate_snapshot_data\"\n        include \"isolate_snapshot_instr\"\n    }\n    into variant.mergeAssets.outputDir\n}\nvariant.outputs[0].processResources.dependsOn(mergeFlutterAssets)<\/code><\/pre>\n<p><strong>2. \u540c\u65f6\u5c06\u8fd9\u4e2aaar\u548cFlutter Plugin\u7f16\u8bd1\u51fa\u6765\u7684aar\u4e00\u8d77\u53d1\u5e03\u5230maven\u4ed3\u5e93\u3002<\/strong><br \/>\n\uff081\uff09\u53d1\u5e03Flutter\u5de5\u7a0b\u4ea7\u7269\u6253\u5305\u7684aar<\/p>\n<pre class=\"wp-block-code\"><code>echo 'Clean packflutter input(flutter build)'\nrm -f -r android\/packflutter\/flutter\/\n\n# \u62f7\u8d1dflutter.jar\necho 'Copy flutter jar'\nmkdir -p android\/packflutter\/flutter\/flutter\/android-arm-release &amp;&amp; cp flutter\/bin\/cache\/artifacts\/engine\/android-arm-release\/flutter.jar \"$_\"\n\n\n# \u62f7\u8d1dasset\necho 'Copy flutter asset'\nmkdir -p android\/packflutter\/flutter\/assets\/release &amp;&amp; cp -r build\/flutteroutput\/aot\/* \"$_\"\nmkdir -p android\/packflutter\/flutter\/assets\/release\/flutter_assets &amp;&amp; cp -r build\/flutteroutput\/flutter_assets\/* \"$_\"\n\n# \u5c06flutter\u5e93\u548cflutter_app\u6253\u6210aar \u540c\u65f6publish\u5230Ali-maven\necho 'Build and publish idlefish flutter to aar'\ncd android\nif [ -n \"$1\" ]\nthen\n    .\/gradlew :packflutter:clean :packflutter:publish -PAAR_VERSION=$1\nelse\n    .\/gradlew :packflutter:clean :packflutter:publish\nfi\ncd ..\/<\/code><\/pre>\n<p>\uff082\uff09\u53d1\u5e03Flutter Plugin\u7684aar<\/p>\n<pre class=\"wp-block-code\"><code># \u5c06plugin\u53d1\u5e03\u5230Ali-maven\necho \"Start publish flutter-plugins\"\nfor line in $(cat .flutter-plugins)\ndo\n    plugin_name=${line%%=*}\n    echo 'Build and publish plugin:' ${plugin_name}\n    \n    cd android\n    if [ -n \"$1\" ]\n    then\n        .\/gradlew :${plugin_name}:clean :${plugin_name}:publish -PAAR_VERSION=$1\n    else\n        .\/gradlew :${plugin_name}:clean :${plugin_name}:publish\n    fi\n    cd ..\/\ndone<\/code><\/pre>\n<p><strong>3. \u7eaf\u7cb9\u7684Native\u9879\u76ee\u53ea\u9700\u8981compile\u6211\u4eec\u53d1\u5e03\u5230maven\u7684aar\u5373\u53ef\u3002<\/strong><br \/>\n\u5e73\u65f6\u5f00\u53d1\u9636\u6bb5\uff0c\u6211\u4eec\u9700\u8981\u5b9e\u65f6\u80fd\u4f9d\u8d56\u6700\u65b0\u7684aar\uff0c\u6240\u4ee5\u6211\u4eec\u91c7\u7528SNAPSHOT\u7248\u672c\u3002<\/p>\n<pre class=\"wp-block-code\"><code>configurations.all {\n    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'\n}\n\next {\n    flutter_aar_version = '6.0.2-SNAPSHOT'\n}\n\ndependencies {\n    \/\/flutter\u4e3b\u5de5\u7a0b\u4f9d\u8d56\uff1a\u5305\u542b\u57fa\u4e8eflutter\u5f00\u53d1\u7684\u529f\u80fd\u3001flutter\u5f15\u64celib\n    compile(\"com.taobao.fleamarket:IdleFishFlutter:${getFlutterAarVersion(project)}\") {\n        changing = true\n    }\n    \/\/...\u5176\u4ed6\u4f9d\u8d56\n}\n\nstatic def getFlutterAarVersion(project) {\n    def resultVersion = project.flutter_aar_version\n    if (project.hasProperty('FLUTTER_AAR_VERSION')) {\n        resultVersion = project.FLUTTER_AAR_VERSION\n    }\n    return resultVersion\n}<\/code><\/pre>\n<h3 id=\"8\">3.3 iOS\u4f9d\u8d56\u7684Flutter\u5e93\u7684\u62bd\u53d6<\/h3>\n<h4 id=\"9\">3.3.1 iOS\u4e2dFlutter\u4f9d\u8d56\u6587\u4ef6\u5982\u4f55\u4ea7\u751f<\/h4>\n<p>\u6267\u884c\u7f16\u8bd1\u547d\u4ee4\u201cflutter build ios\u201d\uff0c\u6700\u7ec8\u4f1a\u6267\u884cFlutter\u7684\u7f16\u8bd1\u811a\u672c[xcode_backend.sh]\uff0c\u800c\u8fd9\u4e2a\u811a\u672c\u4e3b\u8981\u505a\u4e86\u4e0b\u9762\u51e0\u4ef6\u4e8b\uff1a<br \/>\n<strong>1.<\/strong>\u00a0\u83b7\u53d6\u5404\u79cd\u53c2\u6570(\u5982project_path\uff0ctarget_path\uff0cbuild_mode\u7b49\uff09\uff0c\u4e3b\u8981\u6765\u81ea\u4e8eGenerated.xcconfig\u7684\u5404\u79cd\u5b9a\u4e49\u3002<br \/>\n<strong>2.<\/strong>\u00a0\u5220\u9664Flutter\u76ee\u5f55\u4e0b\u7684App.framework\u548capp.flx\u3002<br \/>\n<strong>3.<\/strong>\u00a0\u5bf9\u6bd4Flutter\/Flutter.framework\u4e0e${FLUTTER\\_ROOT}\/bin\/cache\/artifacts\/engine\/${artifact_variant}\u76ee\u5f55\u4e0b\u7684Flutter.framework\uff0c\u82e5\u4e0d\u76f8\u7b49\uff0c\u5219\u7528\u540e\u8005\u8986\u76d6\u524d\u8005\u3002<br \/>\n<strong>4.<\/strong>\u00a0\u83b7\u53d6\u751f\u6210App.framework\u547d\u4ee4\u6240\u9700\u53c2\u6570\uff08build_dir\uff0clocal_engine_flag\uff0cpreview_dart_2_flag\uff0caot_flags\uff09\u3002<br \/>\n<strong>5.<\/strong>\u00a0\u751f\u6210App.framework\uff0c\u5e76\u5c06\u751f\u6210\u7684App.framework\u548cAppFrameworkInfo.plist\u62f7\u8d1d\u5230XCode\u5de5\u7a0b\u7684Flutter\u76ee\u5f55\u4e0b\u3002<\/p>\n<h4 id=\"10\">3.3.2 iOS\u7684Flutter\u4f9d\u8d56\u62bd\u53d6\u5b9e\u73b0<\/h4>\n<p><strong>iOS\u7684Flutter\u4f9d\u8d56\u7684\u62bd\u53d6\u6b65\u9aa4\u5982\u4e0b\uff1a<\/strong><br \/>\n<strong>1. \u7f16\u8bd1Flutter\u5de5\u7a0b\u751f\u6210App.framework\u3002<\/strong><\/p>\n<pre class=\"wp-block-code\"><span style=\"background-color: #000000; color: #3366ff;\"><code>echo \"===\u6e05\u7406flutter\u5386\u53f2\u7f16\u8bd1===\"\n.\/flutter\/bin\/flutter clean\n\necho \"===\u91cd\u65b0\u751f\u6210plugin\u7d22\u5f15===\" .\/flutter\/bin\/flutter packages get\n\necho \"===\u751f\u6210App.framework\u548cflutter_assets===\"\n.\/flutter\/bin\/flutter build ios --release<\/code><\/span><\/pre>\n<p><strong>2. \u6253\u5305\u5404\u63d2\u4ef6\u4e3a\u9759\u6001\u5e93\u3002<\/strong><br \/>\n\u8fd9\u91cc\u4e3b\u8981\u6709\u4e24\u6b65\uff1a\u4e00\u662f\u5c06plugin\u6253\u6210\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u4e8c\u662f\u5c06plugin\u7684\u6ce8\u518c\u5165\u53e3\u6253\u6210\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002<\/p>\n<pre class=\"wp-block-code\"><code>echo \"===\u751f\u6210\u5404\u4e2aplugin\u7684\u4e8c\u8fdb\u5236\u5e93\u6587\u4ef6===\"\ncd ios\/Pods\n#\/usr\/bin\/env xcrun xcodebuild clean\n#\/usr\/bin\/env xcrun xcodebuild build -configuration Release ARCHS='arm64 armv7' BUILD_AOT_ONLY=YES VERBOSE_SCRIPT_LOGGING=YES -workspace Runner.xcworkspace -scheme Runner BUILD_DIR=..\/build\/ios -sdk iphoneos\nfor plugin_name in ${plugin_arr}\ndo\n    echo \"\u751f\u6210lib${plugin_name}.a...\"\n    \/usr\/bin\/env xcrun xcodebuild build -configuration Release ARCHS='arm64 armv7' -target ${plugin_name} BUILD_DIR=..\/..\/build\/ios -sdk iphoneos -quiet\n    \/usr\/bin\/env xcrun xcodebuild build -configuration Debug ARCHS='x86_64' -target ${plugin_name} BUILD_DIR=..\/..\/build\/ios -sdk iphonesimulator -quiet\n    echo \"\u5408\u5e76lib${plugin_name}.a...\"\n    lipo -create \"..\/..\/build\/ios\/Debug-iphonesimulator\/${plugin_name}\/lib${plugin_name}.a\" \"..\/..\/build\/ios\/Release-iphoneos\/${plugin_name}\/lib${plugin_name}.a\" -o \"..\/..\/build\/ios\/Release-iphoneos\/${plugin_name}\/lib${plugin_name}.a\"\ndone\n\necho \"===\u751f\u6210\u6ce8\u518c\u5165\u53e3\u7684\u4e8c\u8fdb\u5236\u5e93\u6587\u4ef6===\"\nfor reg_enter_name in \"flutter_plugin_entrance\" \"flutter_service_register\"\ndo\n    echo \"\u751f\u6210lib${reg_enter_name}.a...\"\n    \/usr\/bin\/env xcrun xcodebuild build -configuration Release ARCHS='arm64 armv7' -target ${reg_enter_name} BUILD_DIR=..\/..\/build\/ios -sdk iphoneos\n    \/usr\/bin\/env xcrun xcodebuild build -configuration Debug ARCHS='x86_64' -target ${reg_enter_name} BUILD_DIR=..\/..\/build\/ios -sdk iphonesimulator\n    echo \"\u5408\u5e76lib${reg_enter_name}.a...\"\n    lipo -create \"..\/..\/build\/ios\/Debug-iphonesimulator\/${reg_enter_name}\/lib${reg_enter_name}.a\" \"..\/..\/build\/ios\/Release-iphoneos\/${reg_enter_name}\/lib${reg_enter_name}.a\" -o \"..\/..\/build\/ios\/Release-iphoneos\/${reg_enter_name}\/lib${reg_enter_name}.a\"\ndone<\/code><\/pre>\n<p><strong>3. \u5c06\u8fd9\u4e9b\u4e0a\u4f20\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u5e76\u751f\u6210\u65b0\u7684Tag\u3002<\/strong><br \/>\n<strong>4. \u7eafNative\u9879\u76ee\u53ea\u9700\u8981\u66f4\u65b0pod\u4f9d\u8d56\u5373\u53ef\u3002<\/strong><\/p>\n<h2 id=\"11\">4. Flutter\u6df7\u5408\u5de5\u7a0b\u7684\u6301\u7eed\u96c6\u6210\u6d41\u7a0b<\/h2>\n<p>\u6309\u4e0a\u8ff0\u65b9\u5f0f\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u89e3\u9664Native\u5de5\u7a0b\u5bf9Flutter\u5de5\u7a0b\u7684\u76f4\u63a5\u4f9d\u8d56\u4e86\uff0c\u4f46\u662f\u5728\u65e5\u5e38\u5f00\u53d1\u4e2d\u8fd8\u662f\u5b58\u5728\u4e00\u4e9b\u95ee\u9898\uff1a<br \/>\n<strong>1.<\/strong>\u00a0Flutter\u5de5\u7a0b\u66f4\u65b0\uff0c\u8fdc\u7a0b\u4f9d\u8d56\u5e93\u66f4\u65b0\u4e0d\u53ca\u65f6\u3002<br \/>\n<strong>2.<\/strong>\u00a0\u7248\u672c\u96c6\u6210\u65f6\uff0c\u5bb9\u6613\u5fd8\u8bb0\u66f4\u65b0\u8fdc\u7a0b\u4f9d\u8d56\u5e93\uff0c\u5bfc\u81f4\u7248\u672c\u6ca1\u6709\u96c6\u6210\u6700\u65b0Flutter\u529f\u80fd\u3002<br \/>\n<strong>3.<\/strong>\u00a0\u540c\u65f6\u591a\u6761\u7ebf\u5e76\u884c\u5f00\u53d1Flutter\u65f6\uff0c\u7248\u672c\u7ba1\u7406\u6df7\u4e71\uff0c\u5bb9\u6613\u51fa\u73b0\u8fdc\u7a0b\u5e93\u88ab\u8986\u76d6\u7684\u95ee\u9898\u3002<br \/>\n<strong>4.<\/strong>\u00a0\u9700\u8981\u6700\u5c11\u4e00\u540d\u540c\u5b66\u6301\u7eed\u8ddf\u8fdb\u53d1\u5e03\uff0c\u4eba\u5de5\u6210\u672c\u8f83\u9ad8\u3002<br \/>\n\u9274\u4e8e\u8fd9\u4e9b\u95ee\u9898\uff0c\u6211\u4eec\u5f15\u5165\u4e86\u6211\u4eec\u56e2\u961f\u7684CI\u81ea\u52a8\u5316\u6846\u67b6\uff0c\u4ece\u4e24\u65b9\u9762\u6765\u89e3\u51b3\uff1a<br \/>\n\uff08\u5173\u4e8eCI\u81ea\u52a8\u5316\u6846\u67b6\uff0c\u6211\u4eec\u540e\u7eed\u4f1a\u64b0\u6587\u5206\u4eab\uff09<br \/>\n<strong>\u4e00\u65b9\u9762\u662f\u81ea\u52a8\u5316\uff0c\u901a\u8fc7\u81ea\u52a8\u5316\u51cf\u5c11\u4eba\u5de5\u6210\u672c\uff0c\u4e5f\u51cf\u5c11\u4eba\u4e3a\u5931\u8bef\u3002<\/strong><br \/>\n<strong>\u53e6\u4e00\u65b9\u9762\u662f\u505a\u597d\u7248\u672c\u63a7\u5236\uff0c \u81ea\u52a8\u5316\u7684\u5f62\u5f0f\u6765\u505a\u7248\u672c\u63a7\u5236\u3002<\/strong><br \/>\n<strong>\u5177\u4f53\u64cd\u4f5c\uff1a<\/strong><br \/>\n<strong>\u9996\u5148\uff0c<\/strong>\u6bcf\u6b21\u9700\u8981\u6784\u5efa\u7eaf\u7cb9Native\u5de5\u7a0b\u524d\u81ea\u52a8\u5b8c\u6210Flutter\u5de5\u7a0b\u5bf9\u5e94\u7684\u8fdc\u7a0b\u5e93\u7684\u7f16\u8bd1\u53d1\u5e03\u5de5\u4f5c\uff0c\u6574\u4e2a\u8fc7\u7a0b\u4e0d\u9700\u8981\u4eba\u5de5\u5e72\u9884\u3002<br \/>\n<strong>\u5176\u6b21\uff0c<\/strong>\u5728\u5f00\u53d1\u6d4b\u8bd5\u9636\u6bb5\uff0c\u91c7\u7528\u4e94\u6bb5\u5f0f\u7684\u7248\u672c\u53f7\uff0c\u6700\u540e\u4e00\u4f4d\u81ea\u52a8\u9012\u589e\u4ea7\u751f\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u4fdd\u8bc1\u6d4b\u8bd5\u9636\u6bb5\u7684\u6240\u6709\u5e76\u884c\u5f00\u53d1\u7684Flutter\u5e93\u7684\u7248\u672c\u53f7\u4e0d\u4f1a\u4ea7\u751f\u51b2\u7a81\u3002<br \/>\n<strong>\u6700\u540e\uff0c<\/strong>\u5728\u53d1\u5e03\u9636\u6bb5\uff0c\u91c7\u7528\u4e09\u6bb5\u5f0f\u6216\u56db\u6bb5\u5f0f\u7684\u7248\u672c\u53f7\uff0c\u53ef\u4ee5\u548cAPP\u7248\u672c\u53f7\u4fdd\u6301\u4e00\u81f4\uff0c\u4fbf\u4e8e\u540e\u7eed\u95ee\u9898\u8ffd\u6eaf\u3002<\/p>\n<figure class=\"wp-block-image\">\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"290\" src=\"https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-84-1024x290.png\" alt=\"\" class=\"wp-image-180\" srcset=\"https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-84-1024x290.png 1024w, https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-84-300x85.png 300w, https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-84-768x218.png 768w, https:\/\/www.xianyuba.cn\/wp-content\/uploads\/2024\/12\/\u95f2\u9c7c\u52a9\u624b-84.png 1280w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n<\/figure>\n<p><strong>\u6574\u4e2a\u6d41\u7a0b\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/strong><\/p>\n<blockquote class=\"wp-block-quote\">\n<p>Standalone\u6a21\u5f0f\u4e0b\u6784\u5efa\u6d41\u7a0b<\/p>\n<\/blockquote>\n<h2 id=\"12\">5. \u6700\u540e<\/h2>\n<p>\u95f2\u9c7c\u6280\u672f\u56e2\u961f\u662f\u4e00\u53ea\u77ed\u5c0f\u7cbe\u608d\u7684\u5de5\u7a0b\u6280\u672f\u56e2\u961f\u3002\u6211\u4eec\u4e0d\u4ec5\u5173\u6ce8\u4e8e\u4e1a\u52a1\u95ee\u9898\u7684\u6709\u6548\u89e3\u51b3\uff0c\u540c\u65f6\u6211\u4eec\u5728\u63a8\u52a8\u6253\u7834\u6280\u672f\u6808\u5206\u5de5\u9650\u5236\uff08android\/iOS\/Html5\/Server \u7f16\u7a0b\u6a21\u578b\u548c\u8bed\u8a00\u7684\u7edf\u4e00\uff09\u3001\u8ba1\u7b97\u673a\u89c6\u89c9\u6280\u672f\u5728\u79fb\u52a8\u7ec8\u7aef\u4e0a\u7684\u524d\u6cbf\u5b9e\u8df5\u5de5\u4f5c\u3002\u4f5c\u4e3a\u95f2\u9c7c\u6280\u672f\u56e2\u961f\u7684\u8f6f\u4ef6\u5de5\u7a0b\u5e08\uff0c\u60a8\u6709\u673a\u4f1a\u53bb\u5c55\u793a\u60a8\u6240\u6709\u7684\u624d\u80fd\u548c\u52c7\u6c14\uff0c\u5728\u6574\u4e2a\u4ea7\u54c1\u7684\u6f14\u8fdb\u548c\u7528\u6237\u95ee\u9898\u89e3\u51b3\u4e2d\u8bc1\u660e\u6280\u672f\u53d1\u5c55\u662f\u6539\u53d8\u751f\u6d3b\u65b9\u5f0f\u7684\u52a8\u529b\u3002<\/p>\n<div class=\"orbui orbui-post orbui-post-content\">\n<div style=\"text-align: left; font-size: 15px;\"><span style=\"font-weight: bold;\">\u95f2\u9c7c\u4e0a\u8d27\u52a9\u624b\u3001\u95f2\u9c7c\u5de5\u5177\u3001\u95f2\u9c7c\u94fa\u8d27\u8f6f\u4ef6\u8054\u7cfb\uff1a<\/span><br \/>\n\u5fae\u4fe1 <span style=\"font-weight: bold;\">yuhuba<\/span> QQ <span style=\"font-weight: bold;\">1459588488<\/span><\/div>\n<\/div>\n<\/article>\n<p><!--nextpage--><\/p>\n<p><!--nextpage--><\/p>\n<div class=\"post-actions\"><\/div>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 1. \u5f15\u8a00 \u5728\u4e4b\u524d\u7684\u6587\u7ae0\u300aFlutter\u6df7\u5408\u5de5\u7a0b\u6539\u9020\u5b9e\u8df5\u300b\u4e2d\uff0c\u6709\u4e9b\u540c\u5b66\u7559\u8a00\u60f3\u4e86\u89e3\u62bd\u53d6Flutter\u4f9d\u8d56\u5230\u8fdc\u7a0b\u7684\u4e00\u4e9b\u5b9e\u73b0\u7ec6\u8282\uff0c\u6240\u4ee5\u672c\u6587\u91cd\u70b9\u6765\u8bb2\u4e00\u8bb2Flutter\u6df7\u5408\u5de5\u7a0b\u4e2d\u7684Flutter\u76f4\u63a5\u4f9d\u8d56\u89e3\u9664\u7684\u4e00\u4e9b\u5177\u4f53\u5b9e\u73b0\u3002 2. \u601d\u8003 \u56e0\u4e3a\u76ee\u524d\u6211&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[178],"tags":[],"topic":[],"class_list":["post-175","post","type-post","status-publish","format-standard","hentry","category-178"],"_links":{"self":[{"href":"https:\/\/www.xianyuba.cn\/index.php\/wp-json\/wp\/v2\/posts\/175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xianyuba.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xianyuba.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xianyuba.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xianyuba.cn\/index.php\/wp-json\/wp\/v2\/comments?post=175"}],"version-history":[{"count":4,"href":"https:\/\/www.xianyuba.cn\/index.php\/wp-json\/wp\/v2\/posts\/175\/revisions"}],"predecessor-version":[{"id":1385,"href":"https:\/\/www.xianyuba.cn\/index.php\/wp-json\/wp\/v2\/posts\/175\/revisions\/1385"}],"wp:attachment":[{"href":"https:\/\/www.xianyuba.cn\/index.php\/wp-json\/wp\/v2\/media?parent=175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xianyuba.cn\/index.php\/wp-json\/wp\/v2\/categories?post=175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xianyuba.cn\/index.php\/wp-json\/wp\/v2\/tags?post=175"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.xianyuba.cn\/index.php\/wp-json\/wp\/v2\/topic?post=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}