{"id":4869,"date":"2022-01-11T17:23:42","date_gmt":"2022-01-11T09:23:42","guid":{"rendered":"http:\/\/123.57.164.21\/?p=4869"},"modified":"2022-01-11T17:23:42","modified_gmt":"2022-01-11T09:23:42","slug":"xcode-%e8%bf%90%e8%a1%8c-script","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=4869","title":{"rendered":"Xcode \u8fd0\u884c Script"},"content":{"rendered":"\n<p>\u5f53\u6211\u4eec\u5728Xcode\u91cc\u9762Build App\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u5728Bulid\u540c\u65f6\u8fd0\u884c\u4e00\u4e9bsh\u811a\u672c\u3002<\/p>\n\n\n\n<p>\u8fdb\u5165Build Phases\u9875\u9762\uff0c\u70b9\u51fb\u52a0\u53f7\u9009\u62e9\u201cNew Run Script Phases\u201d\u521b\u5efaRun Script<\/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\/01\/\u56fe\u7247-14-1024x637.png\" alt=\"\" class=\"wp-image-4870\" width=\"488\" height=\"303\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-14-1024x637.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-14-300x187.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-14-768x478.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-14-1536x956.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-14-830x517.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-14-230x143.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-14-350x218.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-14-480x299.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-14.png 1960w\" sizes=\"(max-width: 488px) 100vw, 488px\" \/><\/figure><\/div>\n\n\n\n<p>\u548c\u4e00\u822c\u7684shell\u6ca1\u6709\u592a\u5927\u7684\u533a\u522b\uff0c\u4f46\u662f\u591a\u4e86\u5f88\u591a\u73af\u5883\u53d8\u91cf\u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2a Run Script,\u6dfb\u52a0\u4e00\u6761\u547d\u4ee4\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=\"\">env\n<\/pre>\n\n\n\n<p>\u53ef\u4ee5\u5728\u811a\u672c\u4e2d\u76f4\u63a5\u4f7f\u7528\u8fd9\u4e9b\u53d8\u91cf\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=\"\">\/\/ bundle id\nPRODUCT_BUNDLE_IDENTIFIER \n\n\/\/ info.plist \u7684\u4f4d\u7f6e\nINFOPLIST_PATH\n\n\/\/ \u5de5\u7a0b\u6839\u76ee\u5f55\nSRCROOT<\/pre>\n\n\n\n<p>\u8f93\u51fa\u8fd9\u4e9b\u73af\u5883\u53d8\u91cf\uff0c\u7ed3\u679c\u5982\u4e0b(\u901a\u8fc7 Xcode -> View -> Navigators -> Show the Report navigator \u67e5\u770b)<\/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\/01\/\u56fe\u7247-15-1024x882.png\" alt=\"\" class=\"wp-image-4871\" width=\"482\" height=\"414\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-15-1024x882.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-15-300x258.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-15-768x662.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-15-830x715.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-15-230x198.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-15-350x302.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-15.png 1402w\" sizes=\"(max-width: 482px) 100vw, 482px\" \/><\/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\/01\/\u56fe\u7247-16-1024x268.png\" alt=\"\" class=\"wp-image-4872\" width=\"524\" height=\"136\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-16-1024x268.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-16-300x79.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-16-768x201.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-16-830x217.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-16-230x60.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-16-350x92.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-16-480x126.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/01\/\u56fe\u7247-16.png 1512w\" sizes=\"(max-width: 524px) 100vw, 524px\" \/><\/figure><\/div>\n\n\n\n<p><strong>\u5e38\u7528\u7684 Run Script<\/strong><\/p>\n\n\n\n<ul><li>Build Number \u81ea\u589e<\/li><\/ul>\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=\"\"> if [ $CONFIGURATION == Release ]; then\n     echo \"Bumping build number...\"\n     plist=${PROJECT_DIR}\/${INFOPLIST_FILE}\n     \n     #increment the build number (ie 115 to 116)\n     buildnum=$(\/usr\/libexec\/PlistBuddy -c \"Print CFBundleVersion\" \"${plist}\")\n     \n     if [[ \"${buildnum}\" == \"\" ]]; then\n         echo \"No build number in $plist\"\n         exit 2\n     fi\n \n     buildnum=$(expr $buildnum + 1)\n \n     \/usr\/libexec\/Plistbuddy -c \"Set CFBundleVersion $buildnum\" \"${plist}\"\n \n     echo \"Bumped build number to $buildnum\"\n \n else\n     echo $CONFIGURATION \" build - Not bumping build number.\"\n fi<\/pre>\n\n\n\n<ul><li>\u6253\u5305\u4e0a\u4f20\u65f6\u79fb\u9664\u7b2c\u4e09\u65b9\u5e93\u4e2d\u65e0\u7528\u7684\u90e8\u5206<\/li><\/ul>\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=\"\"># Without further ado, here\u2019s the script. Add a Run Script step to your build steps, put it after your step to embed frameworks, set it to use \/bin\/sh and enter the following script:\n\nAPP_PATH=\"${TARGET_BUILD_DIR}\/${WRAPPER_NAME}\"\n\n# This script loops through the frameworks embedded in the application and\n# removes unused architectures.\nfind \"$APP_PATH\" -name '*.framework' -type d | while read -r FRAMEWORK\ndo\nFRAMEWORK_EXECUTABLE_NAME=$(defaults read \"$FRAMEWORK\/Info.plist\" CFBundleExecutable)\nFRAMEWORK_EXECUTABLE_PATH=\"$FRAMEWORK\/$FRAMEWORK_EXECUTABLE_NAME\"\necho \"Executable is $FRAMEWORK_EXECUTABLE_PATH\"\n\nEXTRACTED_ARCHS=()\n\nfor ARCH in $ARCHS\ndo\necho \"Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME\"\nlipo -extract \"$ARCH\" \"$FRAMEWORK_EXECUTABLE_PATH\" -o \"$FRAMEWORK_EXECUTABLE_PATH-$ARCH\"\nEXTRACTED_ARCHS+=(\"$FRAMEWORK_EXECUTABLE_PATH-$ARCH\")\ndone\n\necho \"Merging extracted architectures: ${ARCHS}\"\nlipo -o \"$FRAMEWORK_EXECUTABLE_PATH-merged\" -create \"${EXTRACTED_ARCHS[@]}\"\nrm \"${EXTRACTED_ARCHS[@]}\"\n\necho \"Replacing original executable with thinned version\"\nrm \"$FRAMEWORK_EXECUTABLE_PATH\"\nmv \"$FRAMEWORK_EXECUTABLE_PATH-merged\" \"$FRAMEWORK_EXECUTABLE_PATH\"\n\ndone\n\n<\/pre>\n\n\n\n<ul><li>build\u65f6\u5220\u9664\u4e00\u4e2a\u76ee\u5f55<\/li><\/ul>\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=\"\"># Type a script or drag a script file from your workspace to insert its path.\nAPP_PATH=\"${TARGET_BUILD_DIR}\/${WRAPPER_NAME}\"\necho \"${TARGET_BUILD_DIR}\/${WRAPPER_NAME}\/UIDesign\"\n# rm -rf \"${TARGET_BUILD_DIR}\/${WRAPPER_NAME}\/UIDesign\"\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u6211\u4eec\u5728Xcode\u91cc\u9762Build App\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u5728Bulid\u540c\u65f6\u8fd0\u884c\u4e00\u4e9bsh\u811a\u672c\u3002 \u8fdb\u5165Build Pha [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/4869"}],"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=4869"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/4869\/revisions"}],"predecessor-version":[{"id":4873,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/4869\/revisions\/4873"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4869"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4869"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4869"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}