Using fastlane with an app that uses a notification extension - ios

I am using fastlane to build and send my app to testflight. This worked until I added a Notification Extension. Now it always gives me the error:
Error Domain=IDEProvisioningErrorDomain Code=9
""OneSignalNotificationServiceExtension.appex" requires a provisioning
profile with the App Groups feature."
UserInfo={NSLocalizedDescription="OneSignalNotificationServiceExtension.appex" requires a provisioning profile with the App Groups feature.,
NSLocalizedRecoverySuggestion=Add a profile to the
"provisioningProfiles" dictionary in your Export Options property
list.}
Everything is supposed to be handled automatically on Xcode, and my fastfile looks like this:
default_platform(:ios)
platform :ios do
before_all do
increment_build_number
end
desc "Push a new beta build to TestFlight"
lane :beta do
get_certificates # invokes cert
get_provisioning_profile # invokes sigh
build_app(workspace: "MyApp.xcworkspace", scheme: "MyApp (Production)")
pilot(skip_waiting_for_build_processing: true)
end
end
My bundle identifier for my app is like com.myapp.ios and my bundle identifier for my notification service is like com.myapp.ios.notificationservice.
I've tried creating multiple provisioning profiles for the different bundle identifiers manually, but fastlane only selects one. How can I fix this?

I fixed this by changing my manually specifying the provisioning profiles in my fastfile like this:
default_platform(:ios)
platform :ios do
before_all do
increment_build_number
end
desc "Push a new beta build to TestFlight"
lane :beta do
get_certificates # invokes cert
get_provisioning_profile # invokes sigh
build_app(workspace: "MyApp.xcworkspace",
scheme: "MyApp (Production)",
export_method: "app-store",
export_options: {
provisioningProfiles: {
"com.myapp.ios" => "com.myapp.ios AppStore 1530397498",
"com.myapp.ios.OneSignalNotificationServiceExtension" => "MyApp Notification Extension Provisioning Profile"
}
})
pilot(skip_waiting_for_build_processing: true)
end
end
If you want to use match, you can replace export_options with this:
match(
app_identifier:["com.myapp.ios","com.myapp.ios.OneSignalNotificationServiceExtension"],
type: "appstore"
)

Related

Fastlane upload fails: An attribute value is not acceptable for the current resource state. - The attribute 'versionString' can not be modified

I am trying to push a new build to the appstore.
But my fastlane build failed with this error message:
/Library/Ruby/Gems/2.6.0/gems/fastlane-2.204.3/spaceship/lib/spaceship/connect_api/api_client.rb:199:in
`handle_response': [!] An attribute value is not acceptable for the
current resource state. - The attribute 'versionString' can not be
modified. - /data/attributes/versionString
(Spaceship::UnexpectedResponse)
platform :ios do
desc "Push a new release build to the App Store"
lane :Runner do
increment_build_number(xcodeproj: "Runner.xcodeproj")
build_app(scheme: "Runner", silent: true)
upload_to_app_store
end
end
Turns out the problem was that that app isn't approved and released for the appstore yet.
So I can only upload it to TestFlight.
I needed to use upload_to_testflight fastlane
So the whole script in the Fastfile looks like:
platform :ios do
desc "Push a new release build to the App Store"
lane :Runner do
increment_build_number(xcodeproj: "Runner.xcodeproj")
build_app(scheme: "Runner", silent: true)
upload_to_testflight
end
end

error: exportArchive: Code signing "MyFramework.framework" failed in fastlane build

Archive succeeded but export failed through Fastlane build.
But the same export is working fine through Xcode because Xcode is not even asking for MyFrameworkIOS to sign.
I have two ways in mind to get this resolution:
How to avoid signing MyFrameworkIOS when building through fastlane in build machine? Because as you can see above, when building through xcode then MyFrameworkIOS signing is not required at all.
If we need to sign it then how to sign MyFrameworkIOS which is our own Framework created separately and being embedded in MyProject?
Fastfile:
default_platform(:ios)
platform :ios do
desc "Build the application"
lane :testflightbuild do
build_app(
scheme: "MyScheme",
workspace: "MyProject.xcworkspace",
export_method: "app-store",
export_options: {
},
include_bitcode: true
)
end
end
Thanks for helping in advance.

Fastlane selecting wrong provisioning profile

I've configured my iOS project with 2 targets and several configurations (6 for the 1st target, debug and release for the 2nd target).
Each of the release configurations has different bundleID, hence the appropriate adhoc distribution provisioning profiles are selected (in the gym command):
desc "Build target1-config1"
lane :deployTarget1 do
gym(
workspace: "myProj-ios.xcworkspace",
scheme: "target1-config1",
configuration: "target1-Release",
export_method: "ad-hoc",
export_options: {
provisioningProfiles: {
"com.target1.config1" => "AdHocProvProfile1"
}
},
output_directory: "./build",
output_name: "target1-config1.ipa"
)
firebase_app_distribution(
app: "xxxxxxxx",
groups: "ios_app_testers",
release_notes: "Automatic dev build from develop",
firebase_cli_path: "/usr/local/bin/firebase",
debug: true
)
end
When trying to build target2 with AdhocProvProfile2, I receive an error. It looks like fastlane is not properly selecting the provProfile (and bundleID!). Additionally, in project settings the profiles are selected properly. What could be causing the issue? There is no external gym file.
There seems to be a mismatch between your provided `export_method` in gym
[11:15:55]: and the selected provisioning profiles. You passed the following options:
[11:15:55]: export_method: ad-hoc
[11:15:55]: Bundle identifier: com.target1.config1
[11:15:55]: Profile name: Target1 Development ProvProfile
[11:15:55]: Profile type: development

iOS and Firebase app distribution doesn't want to sign app with development profile and distribute it

I have problem with firebase app distribution.
I am using Xcode 11 and there are new iOS Development certificates, namely Apple Development certificates.
I have added fastlane, added plugin to fastlane for firebase-app-distribution.
But when I am executing my lane to distribute application there is error
note: Using new build system
[19:55:21]: ▸ note: Planning build
[19:55:21]: ▸ note: Constructing build description
[19:55:21]: ▸ error: No profile for team 'TEAM_ID' matching 'App Name Development' found: Xcode couldn't find any provisioning profiles matching 'TEAM_ID/App Name Development'. Install the profile (by dragging and dropping it onto Xcode's dock item) or select a different one in the Signing & Capabilities tab of the target editor. (in target 'AppNameDev' from project 'AppName')
I have similar configuration and fastlane lane with this plugin for other app but run in Xcode 10, and I think it has old certificates iOS Development not new one Apple Development and it builds and distribute correctly.
I can build this app using Archive, export .ipa and distribute it manually via firebase console and it works.
I have also such error informations
There seems to be a mismatch between your provided `export_method` in gym
[19:55:21]: and the selected provisioning profiles. You passed the following options:
[19:55:21]: export_method:
[19:55:21]: Bundle identifier: com.company.AppNameDev
[19:55:21]: Profile name: App Name Development
[19:55:21]: Profile type: development
So It just suggest profile name and type and bundle id that I've already correctly types in my Fastfile file in build_ios_app
desc "Firebase App Distribution to testers"
lane :firebase_distribution do
build_ios_app(
workspace: "AppName.xcworkspace",
configuration: "Release",
scheme: "AppName Dev",
silent: true,
clean: true,
output_directory: "firebase-builds",
output_name: "appname.ipa",
sdk: "iphoneos13.1",
export_options: {
method: "development",
provisioningProfiles: {
"com.company.AppNameDev" => "App Name Development"
}
}
)
firebase_app_distribution(
app: "<id goes here>",
testers_file: "fastlane/crashlytics_testers.txt",
release_notes: "Lots of amazing new features to test out!",
firebase_cli_path: "/usr/local/bin/firebase"
)
end
end

Error uploading to itunes connect using fastlane

Firstly, here's the error:
22:13:47]: [Transporter Error Output]: ERROR ITMS-90161: "Invalid Provisioning Profile. The provisioning profile included in the bundle com.fitbugg.apps.FitBugg [Payload/FitBugg.app] is invalid. [Missing code-signing certificate]. A Distribution Provisioning profile should be used when submitting apps to the App Store. For more information, visit the iOS Developer Portal."
[22:13:47]: Transporter transfer failed.
[22:13:47]:
[22:13:47]: ERROR ITMS-90161: "Invalid Provisioning Profile. The provisioning profile included in the bundle com.fitbugg.apps.FitBugg [Payload/FitBugg.app] is invalid. [Missing code-signing certificate]. A Distribution Provisioning profile should be used when submitting apps to the App Store. For more information, visit the iOS Developer Portal."
[22:13:47]: ERROR ITMS-90161: "Invalid Provisioning Profile. The provisioning profile included in the bundle com.fitbugg.apps.FitBugg [Payload/FitBugg.app] is invalid. [Missing code-signing certificate]. A Distribution Provisioning profile should be used when submitting apps to the App Store. For more information, visit the iOS Developer Portal."
Return status of iTunes Transporter was 1: ERROR ITMS-90161: "Invalid Provisioning Profile. The provisioning profile included in the bundle com.fitbugg.apps.FitBugg [Payload/FitBugg.app] is invalid. [Missing code-signing certificate]. A Distribution Provisioning profile should be used when submitting apps to the App Store. For more information, visit the iOS Developer Portal."
The call to the iTMSTransporter completed with a non-zero exit status: 1. This indicates a failure.
[22:13:47]: Variable Dump:
[22:13:47]: {:DEFAULT_PLATFORM=>:ios, :PLATFORM_NAME=>:ios, :LANE_NAME=>"ios beta", :CERT_FILE_PATH=>"/Users/james/Documents/workspace/fb-ios-recover/K3E6UZV9MX.cer", :CERT_CERTIFICATE_ID=>"K3E6UZV9MX", :SIGH_PROFILE_PATH=>"/Users/james/Documents/workspace/fb-ios-recover/AppStore_com.fitbugg.apps.FitBugg.mobileprovision", :SIGH_PROFILE_PATHS=>["/Users/james/Documents/workspace/fb-ios-recover/AppStore_com.fitbugg.apps.FitBugg.mobileprovision"], :SIGH_UDID=>"2cf7a401-960e-4e39-a2f9-2f6627f0642c", :SIGH_PROFILE_TYPE=>"app-store", :IPA_OUTPUT_PATH=>"/Users/james/Documents/workspace/fb-ios-recover/FitBugg.ipa", :DSYM_OUTPUT_PATH=>"/Users/james/Documents/workspace/fb-ios-recover/FitBugg.app.dSYM.zip", :XCODEBUILD_ARCHIVE=>"/Users/james/Library/Developer/Xcode/Archives/2016-08-04/FitBugg 2016-08-04 22.09.00.xcarchive"}
[22:13:47]: Error uploading ipa file, for more information see above
Here's the Fastfile:
# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md
# can also be listed using the `fastlane actions` command
# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`
# If you want to automatically update fastlane if a new version is available:
# update_fastlane
# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "1.98.0"
#username 'james#fitbugg.com'
#app_identifier 'com.fitbugg.apps.FitBugg'
#PRODUCT_BUNDLE_IDENTIFIER='com.fitbugg.apps.FitBugg'
default_platform :ios
platform :ios do
before_all do
# ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
#cocoapods
cocoapods(podfile: 'Podfile')
end
# desc "Runs all the tests"
# lane :test do
# scan
# end
desc "Submit a new Beta Build to Apple TestFlight"
desc "This will also make sure the profile is up to date"
lane :beta do
cert
sigh(force: true)
match(type: "appstore") # more information: https://codesigning.guide
gym(scheme: "FitBugg") # Build your app - more options available
#gym # Build your app - more options available
pilot
# sh "your_script.sh"
# You can also use other beta testing services here (run `fastlane actions`)
end
# desc "Deploy a new version to the App Store"
# lane :fitbuggappstore do
# match(type: "appstore")
# snapshot
# gym(scheme: "FitBugg") # Build your app - more options available
# deliver(force: true)
# frameit
# end
# You can define as many lanes as you want
after_all do |lane|
# This block is called, only if the executed lane was successful
# slack(
# message: "Successfully deployed new App Update."
# )
end
error do |lane, exception|
# slack(
# message: exception.message,
# success: false
# )
end
end
# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md
# fastlane reports which actions are used
# No personal data is recorded. Learn more at https://github.com/fastlane/enhancer
Various commands I've run are:
match (development, distribution)
cert create
To me it seems to be close, but what I can't figure out is why the provisioning profile isn't valid. I thought fastlane uploaded it for me.
Here's my view of provisioning profiles on Apple Dev Conn:
And my certs on the ADC:
To make sure everything works, it is recommended to run match nuke distribution and match nuke development to clean out your old and expired profiles, as well as the ones you created.
Then, run match for the app and environment you need it for. This should solve your issue.
Well a fix of sorts. I more or less started again.
I went ahead and created a completely new app identifier, provisioning profiles, and certs. I had to make the relevant changes in xcode.
Then I was able to make this Fastfile work:
fastlane_version "1.99.0"
default_platform :ios
ENV["XCODE_TEAMNAME"] = "myapp Pty Ltd"
ENV["XCODE_TEAMID"] = "92U9K4P32Y"
# latest_testflight_build_number(version: "0.25.12")
#
# increment_build_number({
# build_number: latest_testflight_build_number + 1
# })
platform :ios do
before_all do
ENV["SLACK_URL"] = "https://hooks.slack.com/services/[webhook-url]" # Webhook URL created in Slack
end
desc "Installs FixCode which disables the \"Fix Issue\" button in Xcode"
lane :xcode do
install_xcode_plugin(
url: "https://github.com/fastlane/FixCode/releases/download/0.2.0/FixCode.xcplugin.zip"
)
end
desc "Fetches the provisioning profiles so you can build locally and deploy to your device"
lane :certs do
match(app_identifier: "com.myapp.test.myapp", type: "development")
match(app_identifier: "com.myapp.test.myapp", type: "appstore")
match(app_identifier: "com.myapp.test.myapp", type: "appstore")
end
desc "Runs all the unit and ui tests"
lane :test do
cocoapods
if is_ci
scan(skip_slack: false)
else
scan
end
end
desc "Creates new screenshots and uploads them to iTunes Connect"
lane :screens do
cocoapods
match(app_identifier: "com.myapp.test.myapp", type: "development")
snapshot
frameit
deliver(app: 925311796, app_identifier: "com.myapp.test.myapp", skip_metadata: true, force: true)
end
desc "Submits a new Beta Build to Apple TestFlight"
lane :beta do
increment_build_number({
build_number: latest_testflight_build_number + 1
})
cocoapods
match(app_identifier: "com.myapp.test.myapp", type: "appstore")
gym(configuration: "Internal Beta")
pilot(app_identifier: "com.myapp.test.myapp", skip_waiting_for_build_processing: true)
end
desc "Deploys a new version to the App Store"
lane :deploy do
cocoapods
match(app_identifier: "com.myapp.test.myapp", type: "appstore")
gym(configuration: "Release")
deliver(force: true)
end
desc "Clean everything"
lane :clean_all do
xcclean(scheme: "myapp")
clean_build_artifacts
clean_cocoapods_cache
end
after_all do |lane|
# This block is called, only if the executed lane was successful
end
error do |lane, exception|
if is_ci
slack(
message: exception.message,
success: false
)
end
end
end

Resources