On both platforms, each build must include an incremented version id. If you submit a build with an invalid version id it will be rejected.
Unfortunately, Appflow does not have any mechanisms that can dynamically update the build/version number currently.
But if you are looking for a workaround that increments the version numbers based on the CI_BUILD_NUMBER of the builds in Appflow, you can follow this guide. CI_BUILD_NUMBER is the sequential build number specific to your app that is available as a Predefined Environment in Appflow. For more info refer to the Predefined Environments docs.
Note: This workaround may result in versioning that is not sequential, which is not ideal. The versions could be for example 1.0.361, 1.0.364 so on.
In a Capacitor project, you can directly modify the versioning to use the CI_BUILD_NUMBER. Here is the path to each file where these values are to be set for each platform.
On iOS, ios/App/App/Info.plist
def sysBuildNumber = System.getenv("CI_BUILD_NUMBER")
versionName "1.0." + sysBuildNumber
The above workaround works only for Capacitor and can only be used to update the patch version. It is recommended that you manually update the major and minor versions as needed.
This workaround used in combination with the Deploy to Appstore feature in appflow can automate your release pipeline.