bitrise-steplib / steps-xcode-archive

Xcode Archive for iOS step
MIT License
68 stars 56 forks source link

Automatic code signing not working for cordova generated projects #54

Closed patrickbussmann closed 7 years ago

patrickbussmann commented 8 years ago

After I read the answer of @viktorbenei I tested around some settings. https://github.com/bitrise-io/steps-xcode-archive/issues/53#issuecomment-254035694

The problem here is that the automatic signing does not work and so my build process fails each time. http://blog.bitrise.io/2016/09/21/xcode-8-and-automatic-code-signing.html

Here are the error messages with the xcode-archive configuration.

If I build something via xCode I'm disabling the "automatically manage signing" and selecting an AdHoc provisioning profile.

Because I'm using a cordova generated xCode project the default settings of the project are the default development profile.

Thanks in Advance for ideas.

TestApp has conflicting provisioning settings. TestApp 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. Code signing is required for product type 'Application' in SDK 'iOS 10.1'

- xcode-archive:
    title: TestApp xCode Archive for iOS
    inputs:
    - workdir: "$BITRISE_SOURCE_DIR/platforms/ios"
    - project_path: "$BITRISE_SOURCE_DIR/platforms/ios/TestApp.xcodeproj"
    - scheme: TestApp
    - force_team_id: AY2H9C3YC1
    - force_code_sign_identity: ''
    - output_tool: xcodebuild
    - is_export_xcarchive_zip: 'yes'
    - custom_export_options_plist_content: ad-hoc

Signing for "TestApp" requires a development team. Select a development team in the project editor. Code signing is required for product type 'Application' in SDK 'iOS 10.1'

- xcode-archive:
    title: TestApp xCode Archive for iOS
    inputs:
    - workdir: "$BITRISE_SOURCE_DIR/platforms/ios"
    - project_path: "$BITRISE_SOURCE_DIR/platforms/ios/TestApp.xcodeproj"
    - scheme: TestApp
    - force_team_id: ''
    - force_code_sign_identity: ''
    - output_tool: xcodebuild
    - is_export_xcarchive_zip: 'yes'
    - custom_export_options_plist_content: ad-hoc

Signing for "TestApp" requires a development team. Select a development team in the project editor. Code signing is required for product type 'Application' in SDK 'iOS 10.1'

- xcode-archive:
    title: TestApp xCode Archive for iOS
    inputs:
    - workdir: "$BITRISE_SOURCE_DIR/platforms/ios"
    - project_path: "$BITRISE_SOURCE_DIR/platforms/ios/TestApp.xcodeproj"
    - scheme: TestApp
    - force_team_id: ''
    - force_code_sign_identity: ''
    - force_provisioning_profile: b284373b-9b5f-4e01-9af0-6442b6bb5222
    - output_tool: xcodebuild
    - is_export_xcarchive_zip: 'yes'
    - custom_export_options_plist_content: ad-hoc

Signing for "TestApp" requires a development team. Select a development team in the project editor. Code signing is required for product type 'Application' in SDK 'iOS 10.1'

- xcode-archive:
    title: TestApp xCode Archive for iOS
    inputs:
    - workdir: "$BITRISE_SOURCE_DIR/platforms/ios"
    - project_path: "$BITRISE_SOURCE_DIR/platforms/ios/TestApp.xcodeproj"
    - output_tool: xcodebuild
    - is_export_xcarchive_zip: 'yes'
    - custom_export_options_plist_content: ad-hoc
viktorbenei commented 8 years ago

Can you share a project / repo we could use for reproduction?

viktorbenei commented 8 years ago

Also, can't you commit the generated Xcode project into your repo? Is there a specific reason why you'd rather generate it for every build?

viktorbenei commented 8 years ago

Another thing: force_team_id: '' means that it will force an empty team ID for code signing - which, in Xcode 8 is an invalid configuration (worked in Xcode 7)

So I guess force_team_id: should be fine, but you have to specify a Team ID if you want to use this option, or delete this option from your config completely to not to force an empty value.

Same thing applies for force_code_sign_identity too, if you specify it with an empty string that means you want to force an empty code signing id.

patrickbussmann commented 8 years ago

Hmm @viktorbenei. Pushing everything to the git repository is too easy :-D

I tried again with your ideas. Now I get:

TestApp has conflicting provisioning settings. TestApp 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 try to solve this problem by using "Set Xcode Plist Value" or "Change value in file" steps. After I tried I'll inform you here about results.

A second reason why I don't go the easy way is because I'm interested in know how this works and why this isn't working. The good thing is that the project is clean and fresh each time. Nobody can't change something. Everything is controlled via Cordova. 👍

viktorbenei commented 8 years ago

A second reason why I don't go the easy way is because I'm interested in know how this works and why this isn't working.

That's a great thing, I would never argue against learning how things work! That said, if your last config (which doesn't include any force_ option) still generates a "Signing for "TestApp" requires a development team" error, that means Cordova generates an Xcode project which is not compatible with Xcode 8 out of the box. Since Xcode 8 a team ID have to be specified in the Xcode project. Xcode 7 worked without any issue if you did not specify the team ID in the project, but this is a new requirement in Xcode 8.

Re error TestApp has conflicting provisioning settings. TestApp is automatically signed for development, but a conflicting code signing identity iPhone Distribution has been manually specified... : you most likely still have force_provisioning_profile in your config. New in Xcode 8, if auto code signing is enabled in the Xcode project you no longer can force provisioning profiles, nor signing identities, only Team ID.

As you can see in the blog post http://blog.bitrise.io/2016/09/21/xcode-8-and-automatic-code-signing.html Xcode 8 (in auto code signing mode) always does an initial signing with Development code signing, and only after that it resigns with the Distribution code signing.

Also, custom_export_options_plist_content: ad-hoc is not a valid Plist content - you should not specify custom export options unless you check the docs of Xcode archive an specify a Plist according to the docs. Instead, usually you should simply set the "Export Method" option of the Xcode Archive step (as mentioned in the blog post), and the Xcode Archive step will generate a valid Plist content accordingly.

patrickbussmann commented 8 years ago

Hmm ok @viktorbenei. After reading your post I re-checked my settings.

The custom_export_options_plist_content: ad-hoc is generated from setting Custom export options plist content which description seems not to be up to date Used for Xcode version 7 and above.

Then I removed everything except the team specification. So that I'm now getting this error (again).

TestApp has conflicting provisioning settings. TestApp 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.

There is no force_provisioning_profile configured.

Configuration

- xcode-archive:
    title: TestApp xCode Archive for iOS
    inputs:
    - workdir: "$BITRISE_SOURCE_DIR/platforms/ios"
    - project_path: "$BITRISE_SOURCE_DIR/platforms/ios/TestApp.xcodeproj"
    - force_team_id: AY2H9C3YC1
    - output_tool: xcodebuild
    - is_export_xcarchive_zip: 'yes'

I think I must use this plist change step because I must enable push notifications by myself. I found out that Cordova not enables this switch, too. So I must do it manually somewhere.

For example, this is how it looks like in xCode if I created the project.

Example how a new project looks in xCode

viktorbenei commented 8 years ago

You should also check the Code Signing settings in Build Settings - if you get "conflicting code signing settings" that usually means that although you enabled Automatic Code Signing, you still have Code Signing settings in Build Settings which is incompatible with auto code sign (e.g. something's set to use Distribution instead of Development - auto code sign requires that only Development is set in Build Settings - Code Signing)

screen shot 2016-10-17 at 10 48 00
viktorbenei commented 7 years ago

Hi,

We now have Cordova scanners on bitrise.io - can you please register the app again, using the scanner? It should generate a proper base config.

I'll close this issue, but feel free to comment and we'll reopen it.

Thanks for reporting @patrickbussmann ;)

MattDHill commented 7 years ago

I'm having the same issue. I've checked and rechecked to make sure that automatic code signing is enabled and that under "build settings" (both on the project level and target level) are set to iosDeveloper.

Getting the error: "AppName has conflicting provisioning settings. AppName 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."

Any idea what the problem might be?

viktorbenei commented 7 years ago

@MattDHill is that a Cordova project? If not, please open a new issue with the details

MattDHill commented 7 years ago

Yes, it is a Cordova project. Currently, I've switched over to manual setting and have it working, but it would be nice to discover why the automatic signing is failing.

viktorbenei commented 7 years ago

@MattDHill can you please register the project again on bitrise.io, so that bitrise.io can generate an appropriate base config as I mentioned here https://github.com/bitrise-io/steps-xcode-archive/issues/54#issuecomment-301498594

kentoj commented 7 years ago

This answer solved it for me: https://stackoverflow.com/a/46823492/2084253

Here is the bash script I use to fix my iOS platform:

#!/usr/bin/env bash
sed -i "" "s/iPhone Distribution/iPhone Developer/g" platforms/ios/cordova/build-release.xcconfig
exit 0;
viktorbenei commented 7 years ago

Thanks for reporting @kentoj ! :)