Sign iOS Flutter application in Azure Pipelines - ios

I can't sign my Flutter project when archiving to ipa file on Azure Pipelines.
This is my build pipeline setup:
Certificate get and built from Apple Developper program;
Provisioning profile from Apple Developper program;
The Flutter build script is a copy of this one (no signing);
Launch of xcodebuild archive to get a signed ipa.
I tried manual signing and automatic signing.
With manual signing
/usr/bin/xcodebuild -sdk iphoneos -configuration Release -workspace ..../ios/Runner.xcworkspace -scheme Runner archive CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY=iPhone Distribution: My Name (MYTEAMID) PROVISIONING_PROFILE=guid-of-my-provisioning-profile PROVISIONING_PROFILE_SPECIFIER= | /usr/local/lib/ruby/gems/2.6.0/bin/xcpretty -r junit --no-color
## RESULT IS ERROR 65
error: Pods-Runner does not support provisioning profiles. Pods-Runner does not support provisioning profiles, but provisioning profile com.blabla.myapp has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'Pods-Runner' from project 'Pods')
error: shared_preferences does not support provisioning profiles. shared_preferences does not support provisioning profiles, but provisioning profile com.blabla.myapp has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'shared_preferences' from project 'Pods')
With Automatic signing
/usr/bin/xcodebuild -sdk iphoneos -configuration Release -workspace .../ios/Runner.xcworkspace -scheme Runner archive CODE_SIGN_STYLE=Automatic DEVELOPMENT_TEAM=MYTEAMID | /usr/local/lib/ruby/gems/2.6.0/bin/xcpretty -r junit --no-color
## RESULT IS ERROR 65
error: No profiles for 'com.blabla.myapp' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.blabla.myapp'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'Runner' from project 'Runner')
With Automatic signing and -allowProvisioningUpdates
/usr/bin/xcodebuild -sdk iphoneos -configuration Release -workspace .../ios/Runner.xcworkspace -scheme Runner archive -allowProvisioningUpdates CODE_SIGN_STYLE=Automatic DEVELOPMENT_TEAM=MYTEAMID | /usr/local/lib/ruby/gems/2.6.0/bin/xcpretty -r junit --no-color
## RESULT IS ERROR 65
error: There are no accounts registered with Xcode. Add your developer account to Xcode (in target 'Runner' from project 'Runner')
error: No profiles for 'com.blabla.myapp' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.blabla.myapp'. (in target 'Runner' from project 'Runner')
Any idea? And first, should I use Automatic or Manual signing?
EDIT 1
I tried with azure-pipelines.yaml found here and I still have the error:
Starting: Xcode archive and sign
==============================================================================
Task : Xcode
Description : Build, test, or archive an Xcode workspace on macOS. Optionally package an app.
Version : 5.151.2
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/xcode
==============================================================================
/usr/bin/xcodebuild -version
Xcode 11.1
Build version 11A1027
/usr/bin/xcodebuild -sdk iphoneos -configuration Release -workspace /Users/runner/runners/2.160.1/work/1/s/ios/Runner.xcworkspace -scheme Runner clean analyze archive -verbose CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY=iPhone Distribution: XXXXXX (XXXXXXX) PROVISIONING_PROFILE=dd325087-6f6c-467b-93e2-a8c2446711e3 PROVISIONING_PROFILE_SPECIFIER=
Build settings from command line:
CODE_SIGN_IDENTITY = iPhone Distribution: XXXXXX (XXXXXXX)
CODE_SIGN_STYLE = Manual
PROVISIONING_PROFILE = dd325087-6f6c-467b-93e2-a8c2446711e3
PROVISIONING_PROFILE_SPECIFIER =
SDKROOT = iphoneos13.1
note: Using new build system
** CLEAN SUCCEEDED **
note: Using new build system
note: Planning build
note: Constructing build description
error: Pods-Runner does not support provisioning profiles. Pods-Runner does not support provisioning profiles, but provisioning profile com.example.blabla has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'Pods-Runner' from project 'Pods')
error: shared_preferences does not support provisioning profiles. shared_preferences does not support provisioning profiles, but provisioning profile com.example.blabla has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'shared_preferences' from project 'Pods')
** ANALYZE FAILED **
note: Using new build system
note: Planning build
note: Constructing build description
error: shared_preferences does not support provisioning profiles. shared_preferences does not support provisioning profiles, but provisioning profile com.example.blabla has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'shared_preferences' from project 'Pods')
error: Pods-Runner does not support provisioning profiles. Pods-Runner does not support provisioning profiles, but provisioning profile com.example.blabla has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'Pods-Runner' from project 'Pods')
** ARCHIVE FAILED **
PS
I can build and archive an a Macbook with Xcode ;
I can build and archive on AppCenter with this script (but all my other pipelines are on DevOps and I would like to keep one tool for CI/CD).
SOLUTION
As suggested by Levi, I edited the generated Podfile and forced a commit of it.
PS: no need to update install/uninstall cocoapods, package on Azure Pipelines is today on the latest version 1.8.4.

You can use flutter install task and flutter build instead of to run the bash scripts. Check it here.
If your project needs cocoapods, you may need to add Cocoapods task to to your pipeline. Please check the example provided by Microsoft to learn more about how to build xcode apps.
For troubleshooting the profiles not fund error, you can check if the carthage lib was correctly configured into xcode projet. You can also try the solutions provided here.
Update:
For pods-runner not support error, Please try to add below to your pod file.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
end
end
end
And add below script to install the latest version cocoapods before building
echo "uninstalling all cocoapods versions"
sudo gem uninstall cocoapods -ax
echo "installing cocoapods version latest"
sudo gem install cocoapods --pre
For more information you can check this thread.

Related

Error in GitHub Action when Building xArchive

So I am trying to create a pipeline in Github Action that will build the app, and I am stuck at this point on this command (I just changed the team id and uuid and team name into ):
xcodebuild -workspace ios/Runner.xcworkspace -scheme Runner -configuration Release DEVELOPMENT_TEAM=<TEAM> -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive PROVISIONING_PROFILE=<UUID> clean archive CODE_SIGN_IDENTITY="Apple Distribution: <TEAM_NAME>"
I am getting this error:
error: No profile for team '' matching 'Accept AppStore Profile'
found: Xcode couldn't find any provisioning profiles matching
'/Accept AppStore Profile'. 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 'Runner'
from project 'Runner')
So I tried to run this script to install the profile:
https://gist.githubusercontent.com/benvium/2568707/raw/19a4f31db299a30a7b948742deb876ad7bcd0cf4/installMobileProvisionFile.sh
and Also I am using this article as a guide for my pipeline:
https://damienaicheh.github.io/flutter/github/actions/2021/04/22/build-sign-flutter-ios-github-actions-en.html
But still no luck, any help would be appreciated.
Thank you in advance

Deploy the ionic app on ios with github actions

I'm trying to build a project using Gitgub actions on macos, and I can't add an authorization key, the build command in xcode gives me this error:
** ARCHIVE FAILED ** error: There are no accounts registered with Xcode. Add your developer account to Xcode (in target 'App' from project 'App') error: No profiles for '' were found: Xcode couldn't find any iOS App Development provisioning profiles matching ''. (in target 'App' from project 'App')
this is my code:
- name: Build ipa
run: ionic capacitor build ios --release --prod --no-open
- name: Import Codesign Certificate
uses: Apple-Actions/import-codesign-certs#v1
with:
p12-file-base64: ${{secrets.IOS_DISTRIBUTION_P12_CER}}
p12-password: ${{secrets.DIST_CERT_P12_PASSWORD}}
- name: Archive
run: xcodebuild -workspace ios/App/App.xcworkspace
-scheme App clean archive -configuration release
-sdk iphoneos -allowProvisioningUpdates DEVELOPMENT_TEAM=${{secrets.APPLE_TEAM_ID}} -archivePath ios/App/App.xcarchive
You need to first setup the provisioning profiles for your app:
You can use the action for this to automatically download them:
https://github.com/Apple-Actions/download-provisioning-profiles

Ionic 4 with capacitor: xcodebuild fails with manual signing process

I'm trying to build the iOS version of an Ionic app which uses capacitor in my continuous integration system (Azure).
This is the output I get:
/usr/bin/xcodebuild -sdk iphoneos -configuration Release -workspace /Users/runner/runners/2.160.1/work/1/s/ios/App/App.xcworkspace -scheme App build CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY=iPhone Distribution: <not_displayed> (ENT) PROVISIONING_PROFILE=5254b426-4af0-45e7-aeab-ec63a303d250 PROVISIONING_PROFILE_SPECIFIER=
Build settings from command line:
CODE_SIGN_IDENTITY = iPhone Distribution: swiss1mobile ag (ENT)
CODE_SIGN_STYLE = Manual
PROVISIONING_PROFILE = 5254b426-4af0-45e7-aeab-ec63a303d250
PROVISIONING_PROFILE_SPECIFIER =
SDKROOT = iphoneos13.1
note: Using new build system
note: Planning build
note: Constructing build description
error: Capacitor does not support provisioning profiles. Capacitor does not support provisioning profiles, but provisioning profile ent_frontwork has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'Capacitor' from project 'Pods')
error: CapacitorCordova does not support provisioning profiles. CapacitorCordova does not support provisioning profiles, but provisioning profile ent_frontwork has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'CapacitorCordova' from project 'Pods')
error: Pods-App does not support provisioning profiles. Pods-App does not support provisioning profiles, but provisioning profile ent_frontwork has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target 'Pods-App' from project 'Pods')
** BUILD FAILED **
I've been searching a lot but no luck. Any clue?
A little workaround fixes this problem. I found this issue in Github for a similar error caused by an update in cocoapods. I find it a bit hacky, but it works. I'm not sure if Azure should fix its xcode task to avoid these errors, but for now, this is good enough.
So the fix is just adding this code to the Podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
end
end
end
This way the pods don't have to be signed, and the error is not shown anymore and the app is built.

Can't automatically archive Xcode 8 project through command line

I'm trying to archive an Xcode project using xcodebuild archive (Xcode 8.2.1) (command line) and a .xcconfig file with the following content:
CODE_SIGN_IDENTITY = iPhone Developer
DEVELOPMENT_TEAM = [Team name here, removed]
SWIFT_VERSION = 2.3
This is the output I am getting
=== BUILD TARGET Unity-iPhone OF PROJECT Unity-iPhone WITH CONFIGURATION Release ===
Check dependencies No profiles for '[bundle id here, removed]' were
found: Xcode couldn't find a provisioning profile matching
'[bundle id here, removed]'. Code signing is required for product type
'Application' in SDK 'iOS 10.2'
** ARCHIVE FAILED **
The following build commands failed:
Check dependencies (1 failure)
You will need a developer certificate, a developer provisioning profile and the distribution certificate and distribution provisioning profile when archiving through xcodebuild, but that still may not be the cause of the check dependency error.

CodeSign error: code signing is required for product type 'WatchKit Extension' in SDK 'iOS 8.4'

I'm attempting to compile my app with a hosted CI service using xctool. I'm seeing this error during my build:
CodeSign error: code signing is required for product type 'WatchKit Extension' in SDK 'iOS 8.4'
I'm not seeing this when compiling in Xcode (it compiles and code signs perfectly fine).
Here is the command that I'm executing:
xctool ONLY_ACTIVE_ARCH=NO -scheme "ShipIOWatchTest" -sdk "iphoneos" -workspace "ShipIOWatchTest.xcworkspace" clean build CODE_SIGN_IDENTITY="iPhone Distribution: Andrew Page (**********)"
I believe that I have proper configuration within Xcode. Here are my settings:
Main App Team Selection
Project CodeSigning Settings
Main App CodeSigning Settings
Watch Extension CodeSigning Settings
Watch App CodeSigning Settings
This is very frustrating. Does anyone have any ideas?

Resources