You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在同一Flutter代码库中为iOS端独立配置版本号与构建号

Can I use independent version/build numbers for iOS in the same Flutter codebase?

Absolutely! You can totally maintain separate version and build numbers for iOS and Android within your single Flutter codebase—this is a standard practice, especially when one platform is launching later than the other (like your iOS app, which is behind your already-updated Android version).

How to set up independent iOS versioning

You have a few straightforward options to make iOS start at 1.0.0 (with your chosen build number) while keeping Android on 1.0.13+15:

Option 1: Directly modify Xcode settings

This is the most manual but straightforward approach for one-off or initial setup:

  • Open your Flutter project's ios/Runner.xcworkspace in Xcode
  • Select the Runner target from the project navigator
  • Go to the General tab, and look for the Identity section
  • Update the Version field to 1.0.0 and the Build field to your starting build number (e.g., 1)
  • Xcode will prioritize these values over the version specified in your pubspec.yaml for iOS builds

Option 2: Override via Flutter build commands

If you prefer to keep pubspec.yaml as the source of truth for Android and override iOS during builds:

  • When building your iOS IPA, use these command-line flags to set the iOS-specific version and build number:
    flutter build ipa --build-name=1.0.0 --build-number=1
    
  • This temporary override ensures the iOS package uses your desired starting values, while Android builds will still use the version from pubspec.yaml unless you specify otherwise

Option 3: Automate with scripts (for CI/CD workflows)

If you use a CI/CD tool like GitHub Actions or GitLab CI, you can add a step to dynamically set the iOS version during builds:

  • Write a simple shell script that checks the target platform and injects the correct version/build number
  • Or pass the --build-name and --build-number flags directly in your CI pipeline's iOS build step

Key things to remember

  • App Store requirements: iOS version numbers must follow semantic versioning (e.g., 1.0.0 → 1.0.1 → 1.1.0) and build numbers must be unique, positive integers (each new submission to App Store Connect needs a higher build number than the last)
  • Android independence: Your Android app's versioning (1.0.13+15 and future updates) won't be affected by any changes you make to iOS's version settings
  • Consistency for your team: If multiple developers are working on the project, make sure to document the versioning strategy so everyone knows how to handle iOS vs Android builds

内容的提问来源于stack exchange,提问作者hasib_ullah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 17:32:37