Error in GitHub Action when Building xArchive - ios

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

Related

how to properly archive an ios app xcode 13

Well there are lots of articles/blog on archiving an iOS app, i've tried several of them, but i end up getting one error or the other, I'm setting up CI/CD, and I'm at the stage of archiving my app.
These are the most promising errors i've gotten so far, i say promising cause other errors encountered seem to be dead ends, but the below commands seems to be a step in the right direction.
1st Command
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -sdk iphoneos -configuration AppStoreDistribution -archivePath $PWD/build/MyApp.xcarchive clean archive
Output
error: Signing for "MyApp" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'Decred Wallet' from project 'MyApp')
2nd Command
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -sdk iphoneos -configuration MyApp\ Release -archivePath $PWD/build/MyApp.xcarchive clean archive
Output
error: No profiles for 'com.mydomian.myapp.test' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.mydomian.myapp.test'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'MyApp' from project 'MyApp')
has anyone done this recently, I need some insight please.
also a few steps to this
i already created a direcory mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles and copied my mobile provisioning file there, i also created a keychain and imported my .p12 file into it

CircleCI build fails because of CODE_SIGN_IDENTITY in xcodebuild command

I have inherited a project that uses Fastlane and CircleCI to generate builds. It has been broken for a while but I managed to get most of it working again. However the actual build keeps failing on the build server, locally all of my lanes already finish successfully.
I've been comparing what happens locally versus on the CI server and the difference seems to be in the way Circle archives the project. I've changed it so it will run locally and the errors remain the same:
xcodebuild -workspace ./App.xcworkspace -scheme App -configuration AdHoc -destination generic/platform=iOS -archivePath "/Users/me/Library/Developer/Xcode/Archives/2020-08-14/App 2020-08-14 13.08.37.xcarchive" archive "CODE_SIGN_IDENTITY=iPhone Distribution: ACME"
Results in:
error: No certificate for team '123ABC4DEF' matching 'iPhone Distribution: ACME' found: Select a different signing certificate for CODE_SIGN_IDENTITY, a team that matches your selected certificate, or switch to automatic provisioning. (in target '***********-SomeLibrary' from project '***********')
It looks like it wants to sign not only the main application using the CODE_SIGN_IDENTITY, expects 'iPhone Distribution: ACME' to be explicitly there and fails when it doesn't.
As soon as I remove the CODE_SIGN_IDENTITY part at the end it starts working locally:
xcodebuild -workspace ./App.xcworkspace -scheme App -configuration AdHoc -destination generic/platform=iOS -archivePath "/Users/me/Library/Developer/Xcode/Archives/2020-08-14/App 2020-08-14 13.08.37.xcarchive" archive"
I've been combing over all of the settings where this might be specified hardcoded but I couldn't find anything. GYM_CODE_SIGN_IDENTITY hasn't been added for example. So how is it possible that it doesn't add that CODE_SIGN_IDENTITY flag locally using Fastlane but yes remote on the server?
I've found out that it was a variable set up in the configuration of CircleCI:
https://app.circleci.com/settings/project/github/[your_org]/[your_app]/environment-variables

Sign iOS Flutter application in Azure Pipelines

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.

xcode 8 xcodebuild manual code signing from command line for multiple provision profiles

In Xcode 7 I was building project through command line for multiple provision profiles by using following commands. I have multiple provision profiles and multiple code signing certificate linked to those profiles so I need to sign the IPA file with appropriate provision profile.
PROVISION_PROFILE="My Provision profile name"
xcodebuild -workspace ../ProjectName.xcworkspace -scheme "${PRODUCT_NAME}" -sdk iphoneos -configuration "${CONFIGURATION}" archive -archivePath "${TARGET_BUILD_DIR}/${PRODUCT_NAME}.xcarchive"
xcodebuild -exportArchive -archivePath "${TARGET_BUILD_DIR}/${PRODUCT_NAME}.xcarchive" -exportPath "${BINDIR}/${PACKAGE_NAME}-${CURVERSION}.ipa" -exportProvisioningProfile "${PROVISION_PROFILE}"
Now these commands not working for Xcode 8. I uncheck the automatically manage signing after that it gives below error
"someProjectName" requires a provisioning profile. Select a provisioning profile for the "Debug" build configuration in the project editor.
Code signing is required for product type 'Application' in SDK 'iOS 10.1'
Anybody please help me in this.
You are only specifying the provisioning profile in your -exportArchive command. In the -workspace command, Xcodebuild is reaching into the -scheme you specify, which looks at the project.pbxproj file and grabs the provisioning profiles you placed from the project editor for the configurations specified by the scheme being built.
If you open your project.pbxproj file in a text editor, you'll see that the Debug configuration has no provisioning profile listed, which is why Xcodebuild is throwing this error. To fix this, add your provisioning profiles in the project editor (or in project.pbxproj) for the configurations being built by your scheme.
Edit: Now that I better understand the requirements, editing my answer with another option. You can also do this to manually specify the provisioning profile in your build step:
xcodebuild -workspace ../ProjectName.xcworkspace -scheme "${PRODUCT_NAME}" -sdk iphoneos -configuration "${CONFIGURATION}" archive -archivePath "${TARGET_BUILD_DIR}/${PRODUCT_NAME}.xcarchive" PROVISIONING_PROFILE="${PROVISION_PROFILE}"

xctool build with today extension

we have an app integrated with today extension, we use xctool and Jenkins to do continuous build and in-house distribution.
In command line, before we use
xctool -workspace our_workspace.xcworkspace -scheme app_schme -xcconfig path_to_xcconfig -configuration Release build archive -archivePath path_to_archive
to generate archive and then export to .ipa, it works fine.
But right now with today extension, we have to build it with another scheme and xcconfig, we put certificate and provisioning profile in xcconfig, as today extension is a new target and should built with its own certificate and provisioning profile, I'm wondering how to achieve using xctool.
Any help is appreciated.
I finally managed to export ipa files via xcodebuild. Since the xctool is built upon xcodebuild, this answer might help.
First of all, when you create an extension, the extension's target will be embedded into your main app's scheme.
So, there is no need to use two schemes.
Then, in your project settings page, create a new configuration, say AdHoc. And then you can set a new Provisioning Profile in both of your target's build settings.
(project settings)
(the build settings of one target)
Then set the right provisioning profiles for your targets (And you'd better set the code sign identity to automatic, so that Xcode can determine which code sign identity is to be used).
Next step, you can archive your app using xcodebuild with the new configuration you just created above:
xcodebuild -project Extension\ Demo.xcodeproj -scheme Extension\ Demo -sdk iphoneos -archivePath ./Build/extension-demo.xcarchive -configuration AdHoc archive
In this step, the codesign will sign two of your targets separately by the provisioning profiles you specified.
Finally, export the .xcarchive file to ipa, again using xcodebuild;
xcodebuild -exportArchive -archivePath ./Build/extension-demo.xcarchive -exportPath ./Build/extension-demo.ipa -exportWithOriginalSigningIdentity
Notice that -exportWithOriginalSigningIdentity is set, so that xcodebuild will not re-sign your ipa, and the code signature in the xcarchive file is preserved.

Resources