I am working with Fastlane script to set up automate ios build with CI/CD. During the build time, Fastlane was unable to detect the Development provisioning file. I am getting errors as follows
error: No profiles for 'my-app-identifier' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'my-app-identifie'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'My-target' from project 'App-scheme')
By default in Xcode the automatic settings code signing is enabled and tried to disable it. And have selected certificates after that I am able to build the ios application with Fastlane.
I have already provided the provisioning profile details of the build_app function. Is there any option to select provisioning profiles with Fastlane?
Fastfile
default_platform(:ios)
platform :ios do
before_all do |lane, options|
APP_ID=ENV['APP_ID']
APP_SCHEME=ENV['APP_SCHEME']
setup_ci
end
desc "Fetches the provisioning profiles so you can build locally and deploy to your device"
lane :certs do
match(app_identifier: [APP_ID], type: "appstore", readonly: true, git_branch: "new-2")
match(app_identifier: [APP_ID], type: "development", readonly: true, git_branch: "new-2")
match(app_identifier: [APP_ID], type: "adhoc", readonly: true, git_branch: "new-2")
end
desc "Description of what the lane does"
lane :beta do
# add actions here: https://docs.fastlane.tools/actions
# increment_build_number
connect_appstore_api
build_app(
scheme: APP_SCHEME,
export_method: "app-store",
output_directory: "./build/appstore/",
clean: true,
archive_path: "./build/build",
export_options: {
provisioningProfiles: {
APP_ID => "match AppStore #{APP_ID}",
}
}
)
# pilot
end
desc "Generate certificates"
lane :generate_certs do
connect_appstore_api
match(
app_identifier: [APP_ID],
type: "development",
readonly: false,
git_branch: "new-2"
)
match(
app_identifier: [APP_ID],
type: "adhoc",
readonly: false,
git_branch: "new-2"
)
match(
app_identifier: [APP_ID],
type: "appstore",
readonly: false,
git_branch: "new-2"
)
end
private_lane :connect_appstore_api do
app_store_connect_api_key(
duration: 1200, # optional (maximum 1200)
in_house: false,
is_key_content_base64: true
)
end
lane :check_ci do
if is_ci
puts "I'm a computer"
else
puts "Hi Human!"
end
end
end
I've been battling this same problem for a while. I'm using fastlane on gitactions with nativescript. I've finally managed to get the archive stage of the build to work.
Make sure you have
setup_ci
(docs) in your lane you run in . I somehow missed this part of the documentation. This will sort out your keychains etc. The Fastfile above does havesetup_ci
.Make sure you're using the
app_store_connect_api_key
(docs) for match to authenticate because 2FA doesn't work in ci/cd. While I had set this up, I didn't actually run that command and match was using my app-password then asking for a security code. The Fastfile above usesconnect_appstore_api
which I can't find in the docs.Disable automatic code signing by using
update_code_signing_settings
(docs). Run this command before you build e.g. beforebuild_app
. Despite what the error says above, I really struggled to get anything to work WITH code signing enabled. You should also include your profile_name when calling this function as it will tell xcode what provisioning profile to use. Below is an example,Note the profile_name. If you run
fastlane match appstore
you'll see the provisioning profiles used for appstore distribution. I think it will look like what I have in the example but just to be sure that command will tell you what your profile_name parameter should be.Test your build locally. Without the
setup_ci
but with the app store API, match, and disabling code signing and specifying the provisioning profile, everything should build locally. If not, check the errors and make the required changes. For example, I had to change mybuild.xcconfig
to include theCODE_SIGN_IDENTITY
to explicitly tell excode what idendity to use,You can use
fastlane match appstore
to get this idendity. It'll be called the "Certificate Name"I'm now able to build the app fine. My new problem is it doesn't look like it's auto incrementing the build number, so the app store is rejecting the app. This might be related to turning off code signing... brb...