# 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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jacky-chen.gitbook.io/jackychen/ci-cd/xcode11-ban-hao-wen-ti.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
