I have the following Fastfile that I'm using to upload a TestFlight build of a MacOS app:
# Fastfile
default_platform(:mac)
DEVELOPER_APP_ID = ENV["DEVELOPER_APP_ID"]
APP_IDENTIFIER = ENV["APP_IDENTIFIER"]
PROVISIONING_PROFILE_SPECIFIER = ""
TEMP_KEYCHAIN_USER = ENV["TEMP_KEYCHAIN_USER"]
TEMP_KEYCHAIN_PASSWORD = ENV["TEMP_KEYCHAIN_PASSWORD"]
APPLE_ISSUER_ID = ENV["APPLE_ISSUER_ID"]
APPLE_KEY_ID = ENV["APPLE_KEY_ID"]
APPLE_KEY_CONTENT = ENV["APPLE_KEY_CONTENT"]
GIT_AUTHORIZATION = ENV["GIT_AUTHORIZATION"]
TEAM_ID = '752MACT599'
ORG_NAME = 'Meter'
PROJECT_NAME = 'Meter'
SIGH_PROVISIONING_PROFILE_NAME = "com.meter.vpn-client1 AppStore"
def delete_temp_keychain(name)
delete_keychain(
name: name
) if File.exist? File.expand_path("~/Library/Keychains/#{name}-db")
end
def create_temp_keychain(name, password)
create_keychain(
name: name,
password: password,
unlock: false,
timeout: 0
)
end
def ensure_temp_keychain(name, password)
delete_temp_keychain(name)
create_temp_keychain(name, password)
end
update_fastlane
desc 'Build, Archive, and Upload to App Store Connect'
lane :release do |options|
is_nightly = 0
app_identifier = ENV['APP_IDENTIFIER']
scheme = 'Meter'
configuration = 'Release'
UI.message("Debug: Creating App Store Connect API key...")
keychain_name = TEMP_KEYCHAIN_USER
keychain_password = TEMP_KEYCHAIN_PASSWORD
ensure_temp_keychain(keychain_name, keychain_password)
api_key = app_store_connect_api_key(
key_id: APPLE_KEY_ID,
issuer_id: APPLE_ISSUER_ID,
key_content: APPLE_KEY_CONTENT,
duration: 1200,
in_house: false
)
increment_build_number(
xcodeproj: "Meter.xcodeproj"
)
match(
# app_identifier: app_identifier,
git_basic_authorization: Base64.strict_encode64(GIT_AUTHORIZATION),
additional_cert_types: 'mac_installer_distribution',
readonly: false,
keychain_name: keychain_name,
keychain_password: keychain_password,
api_key: api_key,
platform: "macos"
)
cert(
keychain_path: "~/Library/Keychains/#{keychain_name}-db",
keychain_password: keychain_password,
api_key: api_key,
platform: "macos"
)
sigh(
app_identifier: app_identifier,
readonly: false,
cert_id: lane_context[SharedValues::CERT_CERTIFICATE_ID],
provisioning_name: ENV['SIGH_PROVISIONING_PROFILE_NAME'],
ignore_profiles_with_different_name: true,
api_key: api_key,
platform: "macos"
)
update_project_team(
path: "Meter.xcodeproj",
teamid: TEAM_ID
)
gym(
project: 'Meter.xcodeproj',
scheme: scheme,
export_method: 'app-store',
configuration: configuration,
clean: false,
derived_data_path: './build',
xcargs: "WARNING_CFLAGS='$(inherited)'",
skip_profile_detection: true,
)
upload_to_testflight(
app_identifier: app_identifier,
skip_submission: true,
skip_waiting_for_build_processing: true,
pkg: './Meter.pkg'
)
end
I keep getting the following error; even though I am incrementing the bundle id:
[19:42:32]: Successfully exported and signed the pkg file:
[19:42:32]: /Users/runner/work/client-app-swift/client-app-swift/Meter.pkg
[19:42:32]: ----------------------------------
[19:42:32]: --- Step: upload_to_testflight ---
[19:42:32]: ----------------------------------
[19:42:32]: Creating authorization token for App Store Connect API
[19:42:33]: Ready to upload new build to TestFlight (App: 6449044498)...
[19:42:33]: Going to upload updated app to App Store Connect
[19:42:33]: This might take a few minutes. Please don't interrupt the script.
[19:42:39]: [altool] 2023-09-27 19:42:39.760 *** Error: The provided entity includes an attribute with a value that has already been used The bundle version must be higher than the previously uploaded version: '27'. (ID: a4eed95a-923c-40d7-a697-0c47012fe8be) (-19232)
[19:42:39]: [altool] {
[19:42:39]: [altool] NSLocalizedDescription = "The provided entity includes an attribute with a value that has already been used";
[19:42:39]: [altool] NSLocalizedFailureReason = "The bundle version must be higher than the previously uploaded version: \U201827\U2019. (ID: a4eed95a-923c-40d7-a697-0c47012fe8be)";
[19:42:39]: [altool] NSUnderlyingError = "Error Domain=IrisAPI Code=-19241 \"The provided entity includes an attribute with a value that has already been used\" UserInfo={status=409, detail=The bundle version must be higher than the previously uploaded version., source={\n pointer = \"/data/attributes/cfBundleVersion\";\n}, id=a4eed95a-923c-40d7-a697-0c47012fe8be, code=ENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATE, title=The provided entity includes an attribute with a value that has already been used, meta={\n previousBundleVersion = 27;\n}, NSLocalizedDescription=The provided entity includes an attribute with a value that has already been used, NSLocalizedFailureReason=The bundle version must be higher than the previously uploaded version.}";
[19:42:39]: [altool] "iris-code" = "ENTITY_ERROR.ATTRIBUTE.INVALID.DUPLICATE";
[19:42:39]: [altool] previousBundleVersion = 27;
[19:42:39]: [altool] }
[19:42:39]: Application Loader output above ^
[19:42:39]: Error uploading '/var/folders/r_/vbvvglrx3lvds6dp_mbyq3_c0000gn/T/881530bf-4d94-4419-84f8-32cb1b667364.pkg'.
[19:42:39]: The provided entity includes an attribute with a value that has already been used The bundle version must be higher than the previously uploaded version: '27'. (ID: a4eed95a-923c-40d7-a697-0c47012fe8be) (-19232)
[19:42:39]: The call to the altool completed with a non-zero exit status: 1. This indicates a failure.
[19:42:39]: Could not download/upload from App Store Connect!
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Lane Context |
+------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| DEFAULT_PLATFORM | mac |
| PLATFORM_NAME | |
| LANE_NAME | release |
| KEYCHAIN_PATH | ~/Library/Keychains/*** |
| BUILD_NUMBER | 2 |
| SIGH_PROFILE_TYPE | app-store |
| MATCH_PROVISIONING_PROFILE_MAPPING | {"***"=>"match AppStore *** macos", "***.extension"=>"match AppStore ***.extension macos"} |
| CERT_FILE_PATH | /Users/runner/work/client-app-swift/client-app-swift/7532RULTT7.cer |
| CERT_CERTIFICATE_ID | 7532RULTT7 |
| SIGH_PROFILE_PATH | /Users/runner/work/client-app-swift/client-app-swift/AppStore_***.provisionprofile |
| SIGH_PROFILE_PATHS | ["/Users/runner/work/client-app-swift/client-app-swift/AppStore_***.provisionprofile"] |
| SIGH_UDID | 61cc4105-d494-4957-a18a-1a757e194d34 |
| SIGH_UUID | 61cc4105-d494-4957-a18a-1a757e194d34 |
| SIGH_NAME | match AppStore *** macos |
| PKG_OUTPUT_PATH | /Users/runner/work/client-app-swift/client-app-swift/Meter.pkg |
| XCODEBUILD_ARCHIVE | /Users/runner/Library/Developer/Xcode/Archives/2023-09-27/Meter 2023-09-27 19.39.33.xcarchive |
+------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[19:42:39]: Error uploading pkg file:
[Application Loader Error Output]: Error uploading '/var/folders/r_/vbvvglrx3lvds6dp_mbyq3_c0000gn/T/881530bf-4d94-4419-84f8-32cb1b667364.pkg'.
[Application Loader Error Output]: The provided entity includes an attribute with a value that has already been used The bundle version must be higher than the previously uploaded version: '27'. (ID: a4eed95a-923c-40d7-a697-0c47012fe8be) (-19232)
[Application Loader Error Output]: The call to the altool completed with a non-zero exit status: 1. This indicates a failure.
+------------------------------------------------+
| fastlane summary |
[!] Error uploading pkg file:
[Application Loader Error Output]: Error uploading '/var/folders/r_/vbvvglrx3lvds6dp_mbyq3_c0000gn/T/881530bf-4d94-4419-84f8-32cb1b667364.pkg'.
[Application Loader Error Output]: The provided entity includes an attribute with a value that has already been used The bundle version must be higher than the previously uploaded version: '27'. (ID: a4eed95a-923c-40d7-a697-0c47012fe8be) (-19232)
[Application Loader Error Output]: The call to the altool completed with a non-zero exit status: 1. This indicates a failure.
+------+---------------------------+-------------+
| Step | Action | Time (in s) |
+------+---------------------------+-------------+
| 1 | default_platform | 0 |
| 2 | update_fastlane | 5 |
| 3 | create_keychain | 0 |
| 4 | app_store_connect_api_key | 0 |
| 5 | increment_build_number | 6 |
| 6 | match | 4 |
| 7 | cert | 0 |
| 8 | sigh | 0 |
| 9 | update_project_team | 0 |
| 10 | gym | 299 |
| | upload_to_testflight | 6 |
+------+---------------------------+-------------+
[19:42:39]: fastlane finished with errors
I see:
Meaning, the new build you are trying to upload to TestFlight has a bundle version number that already exists in the App Store Connect.
This typically happens if the new build version you are attempting to upload is the same as or lower than the version of the build that has been previously uploaded.
Your Fastfile includes the
increment_build_numberaction:This action should increment the build number in your Xcode project, but the error suggests it is not the case.
So make sure you are incrementing the correct attribute; iOS and macOS applications have both a
CFBundleVersion(Build Number) and aCFBundleShortVersionString(Version Number), as mentioned in this comment. If you are only incrementing one but not the other, you may still run into this error.You can add
--verboseto yourfastlanecommand to get more details, which could give you a clue about why the build number is not being incremented as expected.And you can also add debug statements before and after the
increment_build_numberaction to print the current build number. This can help you understand whether it is getting incremented or not.