> For the complete documentation index, see [llms.txt](https://jacky-chen.gitbook.io/jackychen/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jacky-chen.gitbook.io/jackychen/ci-cd/xcode11-ban-hao-wen-ti.md).

# Xcode11 版號問題

* **問題**
  * CFBundleShortVersionString 變成 $(MARKETING\_VERSION)
  * CFBundleVersion 變成 $(CURRENT\_PROJECT\_VERSION)
* **原因**
  * 此為 Xcode11 雷點之一
* **造成影響**
  * 透過 jenkins 部署時，Export 路徑無法正確產生&#x20;
  * 透過 fastlane 上傳 Binary 至 Apple Store 時，版號會變成 $(MARKETING\_VERSION)&#x20;

![](/files/-M4Y03bA9UKgihq8WahH)

![](/files/-M4Y03b49dRs2qwJb8h2)

* **解法**
  * 透過 fastlane 取得正確的值，並回寫到 info.plist

```ruby
version_number = get_version_number(xcodeproj: project+".xcodeproj")
build_number = get_build_number(xcodeproj: project+".xcodeproj")

# 將 version number 和 build number 回寫 info.plist
lane :sync_version_and_build_number_to_info_plist do
    update_plist( 
      plist_path: "path/to/Info.plist",
      block: proc do |plist|
        plist["CFBundleShortVersionString"] = version_number
        plist["CFBundleVersion"] = build_number
      end
    )
end

desc "Firebase App_distribution"
  lane :distribute do |values|

    sync_version_and_build_number_to_info_plist     # 加入此行

    build_ios_app(
        ....do your project configure
    )

end

desc "export archive and ipa"
  lane :export do
  path = "Export/" + version_number + "/" + build_number

    sync_version_and_build_number_to_info_plist     # 加入此行

    gym(
        ....do your project configure
    )

  end
```
