Rubymotion Enterprise Release - ios

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",
]

Related

Why Fastlane lanes from jenkins throwing PhaseScriptExecution [CP] Embed Pods Frameworks error?

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.

ipa upload to Testflight fails via Jenkins but passes via terminal

So I have been trying to automate ipa uploads to Testflight via Jenkins. I am using the following command to achieve the same :
xcodebuild -exportArchive -archivePath Archive/application.xcarchive -exportPath Builds -exportOptionsPlist ~/Desktop/jenkins_slave/AppstoreExportOptions.plist -quiet
When executed via terminal, it works fine and the ipa is uploaded to Testflight.
However, when I am running via Jenkins, the upload fails citing authentication error.
Logs below :
2022-01-10 17:58:24.681 xcodebuild[14144:25274615] DVTPortal: Error:
Error Domain=DVTPortalServiceErrorDomain Code=1100 "Your session has expired. Please log in." UserInfo={payload={
creationTimestamp = "2022-01-10T17:58:24Z";
httpCode = 200;
protocolVersion = QH65B2;
requestUrl = "https://developerservices2.apple.com/services/QH65B2/viewDeveloper.action";
responseId = "207a4f29-2863-4dce-b290-7f28e845cc44";
resultCode = 1100;
resultString = "Your session has expired. Please log in.";
userLocale = "en_US";
userString = "Your session has expired. Please log in.";
}, NSLocalizedDescription=Your session has expired. Please log in.}
2022-01-10 17:58:24.682 xcodebuild[14144:25274618] IDEDistribution: Failed to log in with account 'xyz#gmail.com' while checking for an App Store Connect account
error: exportArchive: Failed to log in.
Error Domain=IDEDistributionErrorDomain Code=9 "Failed to log in." UserInfo={IDEDistributionErrorsAccountIssues=(
"Account \"xyz#gmail.com\": Failed to log in"
), NSLocalizedDescription=Failed to log in., NSLocalizedRecoverySuggestion=App Store Connect access for “Company xyz.” is required. Ensure that your Apple ID account usernames and passwords are correct in the Accounts preference pane.}
I can't figure out what is going wrong. I have already tried the following as mentioned in numerous places, but it still doesn't work :
defaults write com.apple.dt.Xcode DVTDeveloperAccountUseKeychainService_2 -bool NO
I know you'll would suggest to use fastlane to achieve this faster and effectively. Eventually I would integrate fastlane in my project, but I want to understand what is going wrong here.

electron-builder: Identity name is specified, but no valid identity with this name in the keychain

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)'
}
}

How to access environment variable from CircleCI in fastlane

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

Update provisioning profile in xCode project fastlane sigh command

I'm using Fastlane for automatic deploy of a project for multiple clients. For each I set a new and different bundle_identifier. I use produce command to create the app in the dev portal.Then I'm using sigh command to generate and download provisioning profile for the new app created in the dev portal. I ran into a problem. It downloads and installs the profile. The problem is that if I look up into my project and I choose the target I want to deploy and look up into the signing(release) section the provisioning profile is not set. When using gym I'm getting an error.
I post here contents of my fastfile. Maybe I'm using something wrong or I'm missing something.
update_info_plist(
plist_path: 'Plist.plist',
xcodeproj: 'PathToMyProject/MyProject.xcodeproj',
block: lambda { |plist|
plist['CFBundleDisplayName'] = 'App 1'
plist['CFBundleIdentifier'] = 'com.xxx.App1'
plist['CFBundleName'] = 'App1'
}
)
ENV["GYM_WORKSPACE"] = 'MyProject.xcworkspace'
produce(
username: 'xxx#xxx.xxx',
app_identifier: 'com.xxx.App1',
app_name: 'App1',
skip_itc: true,
)
sigh(
username: 'xxx#xxx.xxx',
app_identifier: 'com.xxx.App1',
provisioning_name: 'App1DistribProvProf',
output_path: 'PathToMyProject/MyProject.xcodeproj',
adhoc: true,
)
update_project_provisioning(
xcodeproj: 'PathToMyProject/MyProject.xcodeproj',
target_filter: '.*App1Target1.*'
)
#ENV["PROFILE_UUID"] = lane_context[SharedValues::SIGH_UDID]
gym(scheme: 'App1Scheme', export_method: 'ad-hoc')
Thank you.

Resources