Use same CFBundleVersion and CFBundleShortVersionString in all targets

前端 未结 7 2125
南旧
南旧 2020-12-31 08:31

I received the following email from Apple when I submit an app update:

We have discovered one or more issues with your recent delivery for \"Project

7条回答
  •  旧巷少年郎
    2020-12-31 08:55

    The scheme actions aren't in source control so it's better to add a build phase into your app's target. Syncing the versions across all targets can be solved with a simple script that can be modified for every target you want synced:

    1. Add "New Run Script Phase" in "Build Phases" for your app's target

    1. Rename the script to something like "Sync Versions" and drag it above "Compile Sources" (NOTE: Xcode has a bug that may prevent the drag-drop to work. If so, you'll need to manually edit the .pbxproj file so the build phase goes in the right spot

    2. Paste the following script into the shell:

      INFOPLIST_MYAPP="${SRCROOT}/MyApp/MyApp-Info.plist"
      myAppVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_MYAPP")
      myAppBuild=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_MYAPP")
      
      INFOPLIST_SHAREEXT="${SRCROOT}/ShareExtension/Info.plist"
      /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $myAppVersion" "$INFOPLIST_SHAREEXT"
      /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $myAppBuild" "$INFOPLIST_SHAREEXT"
      

    1. Build your project as you normally and your share extension's version & build will stay in sync with your main target.

提交回复
热议问题