Using Fastlane with upload_build_to_testflight lane getting a ** ARCHIVE FAILED ** error with error Running script 'PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks we aren't able to do further process on the build as it's stuck at gym using Jenkins
By configuring these three files as mentioned below it's working fine on terminal but getting these errors from Jenkins only
(1) .env.default
(2) AppFile
(3) Fastfile
Please refer screenshots of ARCHIVE FAILED
This is how we got error on gym in Fastfile
Here is the configuration files which i have set:
.env.default file:
KEY_ID=“T43C5ACB3B”
ISSUER_ID=“11a2de5e-3c33-47g3-f055-5t8f7d33a6d3”
KEY_FILEPATH="./AuthKey_T43C5ACB3B.p8"
FASTLANE_KEYCHAIN_PATH="/Users/jenkins/Library/Keychains/login.keychain-db"
FASTLANE_KEYCHAIN_PASSWORD= “abcdef”
FASTLANE_PASSWORD = “password”
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD= “password”
TEAM_ID=“TEAMID”
ITC_TEAM_ID=“456456”
FASTLANE_USER= test#gmail.com
FASTLANE_TEAM_NAME=Team Inc.
FASTLANE_ITC_TEAM_NAME=Team Inc.
PRODUCE_APP_IDENTIFIER=com.fastlane.app
PRODUCE_APP_NAME= TestFastlane
PRODUCE_VERSION=1.1
PRODUCE_SKU=fastlanetest
PRODUCE_PLATFORMS=ios
PRODUCE_LANGUAGE=en-US
APP_WORKSPACE=“Fastlane.xcworkspace"
APP_SCHEME=“Fastlane”
TARGET=“Fastlane”
PROVISIONING_PROFILES=“fast lane”
XCODEPROJ=“Fastlane.xcodeproj"
CERTIFICATE="Apple Distribution: Fastlane Solutions, Inc. (TEAMID)”
AppFile
require('dotenv')
Dotenv.load '../.env.default'
app_identifier ENV["PRODUCE_APP_IDENTIFIER"] # The bundle identifier of your app
Fastfile
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:ios)
platform :ios do
profile_name = nil
app_identifier = "#{ENV["PRODUCE_APP_IDENTIFIER"]}"
app_schema = "#{ENV["APP_SCHEME"]}"
app_certificate = "#{ENV["CERTIFICATE"]}"
desc "Description of what the lane does"
lane :load_asc_api_key do
api_key = app_store_connect_api_key(
key_id: "#{ENV["KEY_ID"]}",
issuer_id: "#{ENV["ISSUER_ID"]}",
key_filepath: "#{ENV["KEY_FILEPATH"]}"
# in_house: false # detecting this via ASC private key not currently supported
)
# pilot(api_key: api_key)
end
lane :create_app_on_store do
load_asc_api_key
produce(
username: CredentialsManager::AppfileConfig.try_fetch_value(:apple_id),
app_identifier: app_identifier,
enable_services: {
push_notification: "on", # Valid values: "on", "off"
associated_domains: "on",
in_app_purchase: "on"
}
)
end
lane :create_appicon do
appicon(
appicon_image_file: '1024.png',
appicon_devices: [:ipad, :iphone, :ios_marketing],
appicon_path: "Fastlane/FastlaneImage Assest/WhitelabelledApp.xcassets"
)
end
desc "Bump build number based on most recent TestFlight build number"
lane :fetch_and_increment_build_number do
#fetch read your app identifier defined in your Appfile
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
current_version = get_version_number(
xcodeproj: "#{ENV["XCODEPROJ"]}"
#target: "#{ENV["TARGET"]}" # replace with your main target, required if you have more than one non-test target
)
latest_build_number = latest_testflight_build_number(
api_key: api_key,
version: current_version,
app_identifier: app_identifier
)
increment_build_number(
build_number: (latest_build_number + 1),
)
end
desc "Recreate the provisioning profiles so you can deploy to your device, release on fabric and push to app store"
lane :renew_certificates do
types = ["appstore"] #"development", "adhoc"
app_identifier = app_identifier
types.each do |type|
remove_provisioning_profile(app_identifier: app_identifier, type: type)
end
end
desc "Check certs and profiles"
lane :prepare_signing do |options|
app_id = app_identifier
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
profile_name = "#{ENV["PROVISIONING_PROFILES"]}" # replace with the name of your existing profile, or define a name for the profile that fastlane will create if it’s not found
cert(
api_key: api_key,
keychain_path: ENV["KEYCHAIN_PATH"] # the path to the keychain where your certificates are stored
)
# main app profile
sigh(
api_key: api_key,
app_identifier: app_id,
provisioning_name: profile_name,
force: true # always recreate this exact profile to ensure it's valid and not expired
)
profile_name = match_type = Actions.lane_context[SharedValues::SIGH_NAME]
end
lane :build_release do |options|
app_identifier = app_identifier
output_name = "#{ENV["PRODUCE_APP_NAME"]}" # specify the name of the .ipa file to generate
export_method = "app-store" # specify the export method
compile_bitcode = true # specify whether to enable bitcode
# turn off automatic signing during build so correct code signing identity is guaranteed to be used
update_code_signing_settings(
use_automatic_signing: false,
targets: ["#{ENV["TARGET"]}"], # specify which targets to update code signing settings for
code_sign_identity: app_certificate, # replace with name of code signing identity if different
bundle_identifier: app_identifier,
build_configurations: [app_schema], # only toggle code signing settings for Release configurations
profile_name: profile_name
)
gym(
scheme: app_schema, # replace with name of your project’s scheme
output_name: output_name,
# sdk: "iphoneos",
clean: true,
configuration: app_schema,
export_options: {
method: export_method,
provisioningProfiles: {
app_identifier => profile_name
},
compileBitcode: compile_bitcode,
xcargs: "ASSETCATALOG_COMPILER_APPICON_NAME=./Fastlane/Fastlane/Image Assest/Fastlane.xcassets/AppIcon.appiconset",
codesigning_identity: app_certificate,
}
)
end
lane :upload_release do
api_key = lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
deliver(
api_key: api_key,
skip_screenshots: true,
skip_metadata: true,
skip_app_version_update: true,
force: true, # skips verification of HTML preview file (since this will be run from a CI machine)
run_precheck_before_submit: false # not supported through ASC API yet
)
end
lane :upload_build_to_testflight do
load_asc_api_key
# create_appicon
fetch_and_increment_build_number
renew_certificates
prepare_signing
build_release
upload_release
end
end
Also i tried with pod deintegrate and install the pods using arch -x86_64 pod install
Can anyone help to resolve this error?
This configuration works perfectly and able to generate build successfully in local machine and virtual mac
Thanks in advance
Problem from the keychain is not unlock.
You need to unlock that by
security unlock-keychain
Or with password (run below code before trigger build ios)
security unlock-keychain -p <password>
Hope this way can help you, thanks.
I am trying to build and sign my Electron application. However, I keep receiving an error message about code signing certificates. (Sensitive values have been sanitized.)
electron-builder.js
module.exports = {
mac: {
identity: 'Apple Development: me#company.com (37HSQ92C44)'
}
}
Output from electron-builder
• skipped macOS application code signing reason=Identity name is specified, but no valid identity with this name in the keychain identity=Apple Development: me#company.com (37HSQ92C44) allIdentities=
1) [Redacted]
2) [Redacted]
3) [Redacted]
4) 4099C29CB27A058D14DFAD52A5BB5A4FEE1B293E "Apple Development: me#company.com (37HSQ92C44)"
5) [Redacted]
5 identities found
Valid identities only
1) [Redacted]
2) 4099C29CB27A058D14DFAD52A5BB5A4FEE1B293E "Apple Development: me#company.com (37HSQ92C44)"
2 valid identities found
electron-builder reports that it can see the identity that I wish to use. However, it's not able to match the identity name that I specify in the configuration file with that identity. I have tried all conceivable variations that I can think of to use in identity property, but none do the job:
4099C29CB27A058D14DFAD52A5BB5A4FEE1B293E
4099C29CB27A058D14DFAD52A5BB5A4FEE1B293E "Apple Development: me#company.com (37HSQ92C44)"
Apple Development: me#company.com (37HSQ92C44)
"Apple Development: me#company.com (37HSQ92C44)"
37HSQ92C44
I have also tried several combinations of CSC_NAME, CSC_LINK, CSC_KEYCHAIN, etc. to no avail.
You can try to remove Apple Development: from identity.
module.exports = {
mac: {
identity: 'me#company.com (37HSQ92C44)'
}
}
I have an environment variable called FIREBASE_TOKEN stored on my CircleCI account. I want to access this in my fastfile, but I'm not sure how I can do that. My initial guess it to use ENV['FIREBASE_TOKEN']. Will this work?
e.g.
desc "Distribute app"
lane :distribute do
build_ios_app(...)
firebase_app_distribution(
app: "appid",
testers: "tester1#company.com, tester2#company.com",
release_notes: "notes",
firebase_cli_token: ENV['FIREBASE_TOKEN']
)
end
I'm setting up a pipeline with Azure, which works fine for the first time, but when I try to use it again it doesn't use the application specific password anymore.
Here's what I have done:
Reinstalled fastlane.
Created a new application specific password at App Store.
Created a new FASTLANE_SESSION running the command spaceauth -u user#email.com on terminal.
It works once in a while, usually after reinstalling Fastlane.
Apart from this, the pipeline works fine.
pool:
vmImage: 'macos-latest'
steps:
- task: InstallAppleCertificate#2
inputs:
certSecureFile: 'iOSDistributionCertificate.p12'
certPwd: 'xxxxx'
keychain: 'temp'
- task: InstallAppleProvisioningProfile#1
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: '4e932719-f9bd-4d3e-b4e6-08b35260c632.mobileprovision'
- task: ios-bundle-version#1
inputs:
sourcePath: 'BookingApp/info.plist'
versionCodeOption: 'buildid'
versionCode: '$(Build.BuildId)'
versionCodeOffset: '0'
printFile: true
- task: Xcode#5
displayName: 'Build the app using Xcode'
inputs:
actions: 'build'
sdk: 'iphoneos12.4'
configuration: 'Release'
scheme: 'BookingApp'
packageApp: true
xcodeVersion: 10 # Options: 8, 9, 10, default, specifyPath
signingOption: 'auto'
useXcpretty: false # Makes it easier to diagnose build failures
xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace'
- task: AppStoreRelease#1
inputs:
serviceEndpoint: 'Booking App Connection'
appType: 'iOS'
ipaPath: '**/*.ipa'
releaseTrack: 'TestFlight'
installFastlane: false
Here's the output :
[command]fastlane pilot upload -u *** -i /Users/runner/runners/2.158.0/work/1/s/output/$(SDK)/$(Configuration)/BookingApp.ipa -q XXXXXXXX -r XXXXXX PLC
[15:59:22]: [33mGet started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile[0m
[15:59:23]: Sending anonymous analytics information
[15:59:23]: Learn more at https://docs.fastlane.tools/#metrics
[15:59:23]: No personal or sensitive data is sent.
[15:59:23]: You can disable this by adding `opt_out_usage` at the top of your Fastfile
[15:59:23]: Login to App Store Connect (***)
Session loaded from environment variable is not valid. Continuing with normal login.
Two-factor Authentication (6 digits code) is enabled for account '***'
More information about Two-factor Authentication: https://support.apple.com/en-us/HT204915
If you're running this in a non-interactive session (e.g. server or CI)
check out https://github.com/fastlane/fastlane/tree/master/spaceship#2-step-verification
(Input `sms` to escape this prompt and select a trusted phone number to send the code as a text message)
(You can also set the environment variable `SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER` to automate this)
(Read more at: https://github.com/fastlane/fastlane/blob/master/spaceship/docs/Authentication.md#auto-select-sms-via-spaceship-2fa-sms-default-phone-number)
Any idea on what could be the issue ? I'm using fastlane 2.28.3
Thanks in advance.
How does one release to a staging environment or create a release for Enterprise/Ad Hoc distribution?
This is different from an AppStore release and requires a different provisioning profile, and optionally a different bundle id.
You'll need to add a conditional in your Rakefile and make sure that you have all the correct certificates and provisioning profiles for each type of build you want.
app.release do
if ENV['staging'] == "true"
app.codesign_certificate = "iPhone Distribution: Your Company's Enterprise Certificate"
app.provisioning_profile = "distribution/Enterprise.mobileprovision"
app.identifier = "com.yourcompany.appnameenterprise"
else
app.codesign_certificate = "iPhone Distribution: Your Company's App Store Release Certificate"
app.provisioning_profile = "distribution/AppStore.mobileprovision"
app.identifier = "com.yourcompany.appname"
end
end
To set up the staging ENV variable I have another rake task that sets it:
task :set_staging do
ENV['staging'] = "true"
end
Then to actually release:
desc "Release Enterprise build"
task :enterprise_release => [
:set_staging,
"archive:distribution",
]