Ionic 4 with capacitor: xcodebuild fails with manual signing process - ios

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.

Related

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.

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.

Manual signing fails for xcode test with embedded library. Can it be decomposed?

I'm trying to run Facebook's WebDriverAgent, for testing on real devices: https://github.com/facebook/WebDriverAgent.
Our admin isn't a fan of Apple's automatic signing, so we're trying manual. When I put
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id='4xxx9' test DEVELOPMENT_TEAM=xxxx PROVISIONING_PROFILE=xxxxx
it says
Testing failed:
WebDriverAgentLib has conflicting provisioning settings. WebDriverAgentLib is automatically signed, but provisioning profile xxxx has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor, or switch to manual signing in the project editor.
I set manual signing on everything (in xcode), and try again:
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id='4xxx9' test DEVELOPMENT_TEAM=xxxx PROVISIONING_PROFILE=xxxxx
Testing failed:
WebDriverAgentLib does not support provisioning profiles. WebDriverAgentLib does not support provisioning profiles, but provisioning profile xxxx has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor.
It seems I need to decompose the 'test' action to build the library without the profile, but everything else with the profile, and then trigger testing.
Can this 'xcodebuild test' command be rewritten as several commands to effect such a build/test? I need a command-line solution because this is part of a continuous integration.
Thanks in advance!
This happened to me using manual signing and including Cocoapods dependencies. This is possibly a known issue with Cocoapods (https://github.com/CocoaPods/CocoaPods/pull/6964). Their workaround is to specify setting PROVISIONING_PROFILE_SPECIFIER to '' in the Podfile's post_install hook, but this didn't work for us because we commit our Pods, so the post_install hook doesn't run when we build.
However, in addition to passing the option PROVISIONING_PROFILE_SPECIFIER=xxxxx to xcodebuild, we were able to build by setting the following options in Pods.xcodeproj/project.pbxproj for each target/build configuration:
CODE_SIGNING_ALLOWED = NO;
CODE_SIGNING_REQUIRED = NO;
PROVISIONING_PROFILE = '';
PROVISIONING_PROFILE_SPECIFIER = '';
I am not primarily an iOS developer by trade, but from my understanding, PROVISIONING_PROFILE is deprecated and specifying both CODE_SIGNING_ALLOWED and CODE_SIGNING_REQUIRED may be redundant, but we do it anyway at the moment in our project.
Try using PROVISIONING_PROFILE_SPECIFIER=xxxxx instead of setting PROVISIONING_PROFILE, which is deprecated starting with Xcode8.
If the error then still occurs, try to set neither DEVELOPMENT_TEAM nor PROVISIONING_PROFILE_SPECIFIER, as these codesigning related buildsettings are only relevant, if you are actually building an app (but you are only executing an xcodebuild test on an already build app bundle).
If you want to build and test the app with one call of xcodebuild, you are encouraged to do a xcodebuild ... clean build test
EDIT
After taking a look at the WebDriverAgent project, the problem is related to the WebDriverAgentLib being a Dynamic Framework and a Target-Dependency of the WebDriverAgentRunner-Bundle. Dynamic Frameworks don't like codesigning during the build phase in Xcode8 at all (they now should be codesigned on the fly when being copied into the build product). With specifying code signing related build settings on the command line (DEVELOPMENT_TEAM etc.), Xcode8 will complain about this for Dynamic Framework targets and fail the build.
Solution 1: remove all codesigning related build settings from your xcodebuild call (PROVISIONING_PROFILE_SPECIFIER, PROVISIONING_PROFILE, DEVELOPMENT_TEAM, CODE_SIGN_IDENTITY) and just set these for the WebDriverAgentRunner-Target (either in the Xcode UI or via Command-Line with plistbuddy on the project.pbxproj).
Solution 2: don't test on a real device and instead just on the Simulator. As there is no need to codesign an Executable and/or Test-Bundle for Simulators, you can safely omit any codesigning related parameters from your xcodebuild call.
Solution 3: just stick with Automatic CodeSigning and assure that there a is valid login for the proper Developer Account in the build machine's Xcode.
I had this error and https://stackoverflow.com/a/39923121/713391 suggested i check "Enable Automatic Signing" then click cancel without doing anything, which did fix it. A code diff showed the change was to add
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
or in Xcode it's called Always Embed Swift Standard Libraries

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?

How to sign for phonegap osx local build

I have just started out with osx to start deploying locally to my iphones.
I have NPM installed, I can create projects with no problem, however I can't deploy to my devices. O, also I have xcode installed.
Build settings from command line:
ARCHS = armv7 armv7s arm64
CONFIGURATION_BUILD_DIR = /Users/hutber/myapp/platforms/ios/build/device
SDKROOT = iphoneos7.1
VALID_ARCHS = armv7 armv7s arm64
Build settings from configuration file '/Users/hutber/myapp/platforms/ios/cordova/build.xcconfig':
CODE_SIGN_IDENTITY = iPhone Developer
=== BUILD TARGET CordovaLib OF PROJECT CordovaLib WITH CONFIGURATION Debug ===
Check dependencies
=== BUILD TARGET Sex Diaries OF PROJECT Sex Diaries WITH CONFIGURATION Debug ===
Check dependencies
Code Sign error: No matching codesigning identity found: No codesigning identities (i.e. certificate and private key pairs) matching “iPhone Developer” were found.
CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 7.1'
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
Really no clue and I can't find anything in the documentation either...
If you don't have Apple Developer Account (paid). You can't deploy app to the phone or .ipa file, just iOS Simulator.
Also try https://github.com/nomad/shenzhen
The easiest way would be to open the Xcode project in Xcode, and let it handle the signing (or at least point out what you're missing; you do have a developer account, right?).
In the platforms/ios directory, there should be an Xcode project file, which you can open from Xcode. Note that any edits you make will be overwritten the next time you build for iOS from phonegap (it takes the common code & writes it to the various platforms), so you'd still have to build the way you have before.

Resources