Codemagic iOS Flutter deploy fails on archive - ios

I have a question where and how to add allowProvisioningUpdates in Xcode? My Codemagic account is connected with App Store Connect, bundle id and app are also created.
Build process fails on the app archive, but Xcode build is successfully done.
Can I somehow add allowProvisioningUpdates to this command?
Execute "xcodebuild -workspace /Users/builder/clone/ios/Runner.xcworkspace -scheme Runner -config Release -archivePath build/ios/xcarchive/Runner_1pxkp9aq.xcarchive archive COMPILER_INDEX_STORE_ENABLE=NO"
Every time build process returns me this message after fail:
Error: No profiles for 'com.xxx.xxx' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.xxx.xxx'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'Runner' from project 'Runner')
Do you have some suggestions, on how to resolve this?
Thanks.

The error itself is probably actually unrelated, and adding the flag will not change much.
If you're using .yaml and are trying to set up automatic code signing I would encourage you to add xcode-project use-profiles before your build step.
For automatic .yaml code signing with Flutter iOS the workflow should include:
a) keychain initialize
b) app-store-connect fetch-signing-files "your.bundle.id" --type IOS_APP_STORE --create
If you wish to use development certificate then IOS_APP_DEVELOPMENT as type.
d) keychain add-certificates
e) xcode-project use-profiles
f) flutter build ios
g) xcode-project build-ipa --workspace "ios/Runner.xcworkspace" --scheme "Runner" (change to your workspace and scheme)
In addition you should implement versioning, if you do not want to do it manually for each build.
If you're not using automatic code signing, then you will need to upload your provisioning profile and the process will be a bit different. But the process is somewhat similar, you can take a look at the documentation: https://docs.codemagic.io/code-signing-yaml/signing-ios/

Related

Flutter - Codemagic - iOS Code signing issues with Custom scheme

My iOS builds are failing on CodeMagic after implementing Flavors. Here is the major error I can see in xcodebuild.log
Runner has conflicting provisioning settings. Runner is automatically signed for development, but a conflicting code signing identity iPhone Distribution has been manually specified. Set the code signing identity value to "iPhone Developer" in the build settings editor, or switch to manual signing in the project editor.
I did changed Code signing identity to iOS Developer as many stackoverflow questions lead to, but didn’t help.
First line in XCodebuild.log from failed build artifacts in CodeMagic has Runner scheme instead of my custom scheme uat.
From XCodebuild.log - /Applications/Xcode-10.3.app/Contents/Developer/usr/bin/xcodebuild -workspace /Users/builder/clone/ios/Runner.xcworkspace -scheme Runner -archivePath /Users/builder/build.xcarchive -config Release archive DEVELOPMENT_TEAM=xxxxx CODE_SIGN_IDENTITY='iPhone Distribution'
With the help of CodeMagic team I was able to figure out that FCI_FLUTTER_SCHEME environment variable should be configured in CI Job to the custom scheme. For me it's uat.
Reference - https://docs.codemagic.io/troubleshooting/common-ios-issues/

Xcode signing using Jenkins

I am trying to sign and archive my Unity application with Jenkins. I have the Xcode jenkins plugin installed and everything seems to run well except for a strange problem.
During the xcodebuild phase, when the archive should be signed, I get the following error:
error: No signing certificate "iOS Development" found: No "iOS
Development" signing certificate matching team ID "QF6V2M666X" with a
private key was found. (in target 'Unity-iPhone')
Now the problem is that I am not trying to build for development, but for production. I have a production provisioning profile used, which is pointing the production certificate. The team id is the production team id (changed here for security reasons). Here is another part of the build output:
Going to invoke xcodebuild:, scheme: Unity-iPhone, sdk: DEFAULT,
project: DEFAULT, configuration: Release, clean: NO, archive:YES,
consolelog:YES, symRoot: DEFAULT, buildDir: DEFAULT,
developmentTeamID: QF6V2M666X
[sr-ios] $ /usr/bin/xcodebuild -scheme
Unity-iPhone -configuration Release archive -archivePath
When I open the project in Xcode, I can see that for some reason Xcode selects "IOSDeveloper" in the code signing identities part and not "IOSDistribution" (or the actual certificate in the provisioning profile):
I don't know if this can be changed from Jenkins, but I think Xcode should pick this up from the provisioning profile.
So I managed to find the problem and solve it, here is the solution for others.
In Unity 2018 they added a new option to the iOS player settings, in the "Other settings" section, called IOS Provisioning Profile->Profile type:
This option is used to select the signing identity. I guess you can use "Automatic" but in my case, since I am using Jenkins, I am setting it on a build script like this:
PlayerSettings.iOS.iOSManualProvisioningProfileType =
ProvisioningProfileType.Distribution;
When this option is set, xcode is able to sign the app correctly for distribution.

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

building xcode project from jenkins fails. when building in command line runs just fine. why?

building xcode project from jenkins fails.
when building in command line runs just fine.
why?
this is is the error I get:
[BEROR]Code Sign error: No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “_UUID_”, however, no such provisioning profile was found.
[BEROR]CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 7.1'
this is the command line used:
xcodebuild -project PROJECTNAME.xcodeproj/ -target TARGETNAME -configuration Release -sdk iphoneos7.1 clean build
ps: anything with OBJECT was censored so this question can appear online, there was real data there before.
Are you using the login key-chain or did you create a different key-chain for jenkins builds app signing?
If you are just using the login key-chain make sure you unlock the key-chain during the build.
If you are using a different key-chain make sure you swap key-chains and then unlock it.
Jenkins - Xcode build works codesign fails - this thread is quite informative.
Also adding these 2 commands to your build can help you debug it:
/usr/bin/security list-keychains
/usr/bin/security find-identity

Can't generate release build for Cordova iOS App

I am using Phonegap CLI 3.1 and XCode5. I want to generate the release build for iPhone Application through command line, I have valid distribution certificate and mobile provisioning profile. I want to generate the release build totally through command and don't want to use XCode GUI or Phonegap Build. I have tried too much with xcodebuild, xcrun and even corodva build command but none of them provide me the release build file (either in .app format or .ipa).
Method 1 (Use xcodebuild)
a) xcodebuild -project MyApp.xcodeproj -alltargets -sdk iphoneos7.0 PROVISIONING_PROFILE="PROFILE_UUID.mobileprovision" -configuration Release
** BUILD FAILED **
The following build commands failed:
CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7/AppDelegate.o MyApp/Classes/AppDelegate.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7/MainViewController.o MyApp/Classes/MainViewController.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC build/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7s/AppDelegate.o MyApp/Classes/AppDelegate.m normal armv7s objective-c com.apple.compilers.llvm.clang.1_0.compiler
(3 failures)
Method 2 (Use corodova build and xcrun to sign the app)
a) cordova build ios -release
Compiling app on platform "ios" via command "/Users/Macuser/Desktop/MyApp/platforms/ios/cordova/build" --release Platform "ios" compiled successfully.
b) xcrun -sdk iphoneos PackageApplication -v "build/Release-iphoneos/MyApp.app" -o "build/Release-iphoneos/MyApp.ipa" --sign "iPhone Distribution: NAME (ID)" --embed "PROFILE_UUID.mobileprovision"
error: Failed to read entitlements from '/tmp/iyibGn3aUv/Payload/MyApp.app
The problem is that you do not have proper schemes. When phonegap project is generated it does not contain any schemes and thus linking to the phonegap files is incorrect.
Go to the phonegap generated project in console and put 'xcodebuild -list'
in the output you will get that there is no schemes in the project.
Open generated by phonegap project in the xcode - this will generate schemes.
Now you can build this using xcodebuild(Remember to fill up the proper scheme name):
xcodebuild -scheme YOURSCHEMENAME -project MyApp.xcodeproj -alltargets -sdk iphoneos7.0 PROVISIONING_PROFILE="PROFILE_UUID.mobileprovision" -configuration Release
For continous integration this is bad solution because you have to launch the xcode GUI to generate the schemes but I did not found any other solution for this problem. If someone know how to generate scheme using command line it would be nice of him to write it down.
First, you need to create your app in iTunes Connect (This is in the member center of your iOS developer account). If you've already created your profiles and certificates, then you can select the correct one in iTunes Connect. Here is where you name your app, set a price, write a description, and upload screen shots and a large icon. Make sure you fill in all information and upload all images for your app. You will know when you are done the status of your app changes to 'Waiting for Upload".
After you've created your app successfully in iTunes Connect, to generate an .IPA file for distribution (either for the AppStore or Ad-Hoc) in Xcode you need to select your Project in the file tree (at the top of the tree). Then make sure your 'Targets' is selected to the right.
Choose 'Build Settings". Then go to the section where is says Code Signing. For 'Release', make sure that the correct iPhone Distribution identity or profile is selected.
Below 'Release' it should say 'Any iOS SDK'. Make sure that it says 'IOS Distribution' next to it.
If you have the correct certificates and profiles in the keychain, you can now in the menu at the top choose Product > Archive.
If it doesn't build, then press the run button to build your project. Xcode should say that it is archiving.
After it archive's successfully, go to the Organizer. In the menu at the top choose Window > Organizer. Now click Archives.
If your project successfully archived you will see it here. First you need to Validate your project with iTunes Connect. You will need to enter your iOS Developer login info. Xcode 5 does a pretty good job of detecting the correct profiles so you should see it in there.
If your app validates then you can then distribute either to the App Store or as an Ad-Hoc distribution. Depending on which profile you have.
This is the process for distributing apps either Native or Phonegap. It doesn't matter, I've built both.
I would suggest doing it this way, in case your app doesn't validate. Xcode will then tell you what you need to do to fix. Then once you fix everything. Create a new archive and try until it validates.

Resources