Hi, So I’ve hit a couple of walls, I was hoping implementing Fastlane was going to be a simple task but I’m having some issues.
For IOS I am not able to Authenticate the 2FA with my iCloud credentials. It seems the only way to be able to achieve this is with an updated version of Fastlane so that we can use api_key_path or api_key in the parameters. Is there any news or information about getting the latest version of Fastlane installed?
For Android it doesn’t seem like I can setup Fastlane in the Cloud Build config. Is it supported for Android on Cloud Build or am I doing something wrong to not see it?
Any help would be really appreciated.
Thanks in advance.
Fastlane works without 2FA if BOTH apple_id and skip_waiting_for_build_processing are sent as parameters to upload_to_testflight action in the Fastfile. As far as I know the API approach is not yet supported by the Fastlane version used in the Unity Cloud Build currently.
For Android, it indeed seems that the custom Fastlane configuration option is missing. I have been looking for that as well. I think a custom post process logic is required to make it work. I hope Unity would add support for custom Fastlane setup for Android as well, so I could use Fastlane/Supply to deliver builds directly to Google Play.
Interesting, so i’m assuming its not fussing about Fastlane but maybe the version that is being used by Cloud build. It might be worth running “fastlane version” in your shell script and take a look at the Fastlane Docs to see if something has changed.
Actually, I figured this out. The problem was with the Fastlane Supply AAB path parameter. I didn’t realize at first that the “Android.aab” was actually the supposed to be the unique name of the build target. Mine was not named “Android” so naturally the submission failed.
Below is my adjusted script, which is a bit more advanced so that all the parameters (such as JSON_KEY path, and RELEASE_TRACK) can be setup in the beginning of the script. This also removes the requirement to manually add the BUILD_NAME in case this same script is used in multiple pipelines (which is our use case).
Thank you for your input. I had indeed managed to upload it to TestFlight using xcrun altool --upload-app [see below], but I was really trying to figure out a way to do it with fastlane… since it is already installed and that is what UCB uses to build the ipa anyway.
I’m baffled though that this has become a week-long tasks… while it should just be a check box in the build configurations…
I have also reported the issue to fastlane directly because the authentication is failing even after following their docs/tutorial…
this is really a lot harder than it should be… I wish more companies started to think about developers’ quality of life…
#!/bin/bash
#Path is "/BUILD_PATH/<ORG_ID>.<PROJECT_ID>.<BUILD_TARGET_ID>/.build/last/<BUILD_TARGET_ID>/build.ipa"
build_folder_path="$WORKSPACE/.build/last/$TARGET_NAME"
path="$build_folder_path/build.ipa"
echo "###############################################"
echo "Uploading IPA to Appstore Connect..."
echo "-----------------------------------------------"
env
echo "-----------------------------------------------"
pwd
echo "-----------------------------------------------"
brew install jq
echo "-----------------------------------------------"
BUILD_TARGET=$(jq -r 'keys[0]' < build.json)
BUILD_NAME=$(jq -r ".[\"${BUILD_TARGET}\"].executablename" < build.json)
BUNDLE_ID=$(jq -r ".[\"${BUILD_TARGET}\"].bundleid" < build.json)
if [[ -z "${BUNDLE_ID}" ]]; then
# bundleId="your.hardcoded.bundleid"
echo "======== Using default value for bundleId - ${bundleId}"
else
bundleId="$BUNDLE_ID"
echo "======== bundleId set to ${bundleId}"
fi
if [[ -z "${APPSTORE_PUSH_TYPE}" ]]; then
pushType="ios"
echo "======== Using default value for pushType - ${pushType}"
else
pushType="$APPSTORE_PUSH_TYPE"
echo "======== pushType set to ${pushType}"
fi
# https://stackoverflow.com/a/31921249/6120464
# CFBundleShortVersionString gives you the version of your app.
# It's typically incremented each time you publish your app to the App Store.
# This is the version that is visible on the "Version" section for the App Store page of your application.
if ! [[ -z "${BUNDLE_VERSION}" ]]; then
echo "-----------------------------------------------"
bundleShortVersionString="$BUNDLE_VERSION"
echo "======== bundleShortVersionString set to ${bundleShortVersionString}"
# else
# echo "======== Using default value for bundleShortVersionString - ${bundleShortVersionString}"
fi
# CFBundleVersion gives you the build number which is used for development and testing, namely "technical" purposes.
# The end user is rarely interested in the build number but during the development you may need to know what's being developed
# and fixed on each build. This is typically incremented on each iteration of internal release. And you can use continuous
# integration tools like Jenkins to auto-increment the build number on each build.
if ! [[ -z "${UCB_BUILD_NUMBER}" ]]; then
bundleVersion="$UCB_BUILD_NUMBER"
echo "======== bundleVersion set to ${UCB_BUILD_NUMBER}"
# else
# echo "======== Using default value for bundleVersion - ${bundleVersion}"
fi
echo "-----------------------------------------------"
search_depth=2
search_results=($(find . -maxdepth $search_depth -type f -name Info.plist))
plist_filepath=${search_results[0]}
find_error_message="File Doesn't Exist, Will Create"
# regex operator https://linuxize.com/post/how-to-check-if-string-contains-substring-in-bash/#using-regex-operator
if [ $plist_filepath == "" ] || [[ "$plist_filepath" =~ .*"$find_error_message".* ]]; then
echo "Error PList no found!\n $search_results"
exit 1
else
echo "Found PList! $plist_filepath"
fi
plist_build_number=$(/usr/libexec/PlistBuddy -c "print :CFBundleVersion" "$plist_filepath")
plist_version=$(/usr/libexec/PlistBuddy -c "print :CFBundleShortVersionString" "$plist_filepath")
echo "-----------------------------------------------"
if [ $plist_build_number -lt 1 ]; then
echo "Error! plist_build_number [$plist_build_number] should match bundleVersion [$bundleVersion]"
else
echo "plist_build_number [$plist_build_number] retrieved correctly."
bundleVersion=$plist_build_number
fi
if [[ "$plist_version" == "" ]]; then
echo "Error! plist_version [$plist_version] should match bundleShortVersionString [$plist_version]"
else
echo "plist_version [$plist_version] retrieved correctly."
bundleShortVersionString=$plist_version
fi
echo "-----------------------------------------------"
echo " Info.plist log "
echo "-----------------------------------------------"
cat $plist_filepath
echo "-----------------------------------------------"
# https://keith.github.io/xcode-man-pages/altool.1.html
exit_code=0
if xcrun altool --upload-package $path \
--type $pushType \
--apple-id $APPLE_ID \
--bundle-version $bundleVersion \
--bundle-short-version-string $bundleShortVersionString \
--bundle-id $bundleId \
-u $APPLE_DEVELOPMENT_USERNAME \
-p $APP_SPECIFIC_PASSWORD ; then
echo "======== Upload IPA to Appstore Connect finished with success"
# end without error
exit_code=0
else
echo "======== Upload IPA to Appstore Connect failed"
echo "======== Current Folder Content"
ls -a .
# end with error
exit_code=1
fi
echo "###############################################"
exit $exit_code
@L4ZZAR8 were you able to figure out how to upload using fastlane? We’re also able to use altool, but I think the benefits of fastlane would be that we can change additional things like release / test notes.
Just a quick note that we were able to make this work using the following post build script. It allows us to add information to testflight release notes, which is super useful when building with multiple configs.We’re creating the json file live as we didn’t want to check that in our source code, so the API key is an environment variable.