Skip to content

Conversation

@PanayotCankov
Copy link
Contributor

@PanayotCankov PanayotCankov commented Dec 12, 2016

Upon iOS build for device the user will be prompted to choose between Automatic (the old approach with team id) and Manual (new approach using specific provisioning profile). Once the team id or provisioning profiles are selected, the Xcode project will be updated to match the Xcode 8 behavior where the "Automatically manage signing" checkbox is checked or not.

There are some issues to be resolved in: https://github.com/NativeScript/ios-mobileprovision-finder/issues

@PanayotCankov PanayotCankov changed the title Add initial code for manual and automatic Xcode signing Implement Automatic and Manual Xcode Signing Styles Dec 12, 2016
Copy link
Contributor

@rosen-vladimirov rosen-vladimirov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildForDevice method is way too long, can you try extracting some parts of it in a separate methods

"Manual - Select existing provisioning profile for use",
"Automatic - Select Team ID for signing and let Xcode select managed provisioning profile"
];
let signingStyleIndex = signingStyles.indexOf(this.$prompter.promptForChoice("Select codesiging style", signingStyles).wait());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen in non-interactive terminal? The prompter will wait for input, but there will be no input, so maybe the execution will hang here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was interactive before my intervention, read getDevelopmentTeam

}

switch(signingStyle) {
case "Manual": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you really need the curly brackets { - they seems inconsistent with the other code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I don't.

return result;
}

private getProvisioningProfile(): provision.MobileProvision {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method has async operations (.wait() inside it's body), so it must return IFuture<provision.MobileProvision>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readTeamId was not returning future before my intervention

for (let team of teams) {
choices.push(team.name + " (" + team.id + ")");
}
let choice = this.$prompter.promptForChoice('Found multiple development teams, select one:', choices).wait();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is async operation, the method getDevelopmentTeam must return IFuture

return teamId;
}

private persistProvisioningProfiles(uuid: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method needs return type.

}
}

private persistDevelopmentTeam(teamId: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method needs return type

Copy link
Contributor

@rosen-vladimirov rosen-vladimirov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After green build

@PanayotCankov PanayotCankov merged commit 3e307ba into master Dec 13, 2016
@PanayotCankov
Copy link
Contributor Author

QSF build, as provisioning profiles from xcconfig were propagated as command line args to xcodebuild and as result tried to sign Cocoa pods. This PR: #2356 will resolve this.

@PanayotCankov
Copy link
Contributor Author

When provisioning profile is selected manually it should either be stored in xcconfig or in the pbxproj in the platforms/ios instead of passed as command line arg to xcodebuild, and thus used only for the App build. When it is passed as command line arg xcodebuild will try to sign and add the provisioning profile to the dynamic framework build for Cocoapods, instead they should not be signed.

@PanayotCankov
Copy link
Contributor Author

PanayotCankov commented Jan 5, 2017

On clear project without platforms folder tns run ios (and the like) when trying to build for device will ask for provisioning profiles used for signings as follow:

  • Ask for 'Manual' or 'Automatic' code signing
    • When 'Manual'
      • Ask for a valid provisioning profile supporting the selected device, fail the build with a proper message if there are no matching provisioning profiles.
        • Ask for persistence choice "xccofig in app/App_Resources", "platforms/ios" or "do not persist"
          • When persisted in "xccofig in app/App_Resources" the profile is saved in the build.xcconfig and used to sign the app during the build.
            • On a subsequent tns run ios no dialogs are presented and the provisioning profile from the build.xcconfig is used to sign the app.
            • If the plaforms/ios is deleted and subsequent tns run ios is issued the build.xcconfig will preserve the provisioning profile and it will be used to sign the app for device.
          • When persisted in "platforms/ios" the selected provisioning profile is set in the Xcode project and if the platforms/ios/.xcodeproj is opened in Xcode the App target will have its signing set to "Manual" and the selected provisioning profile will be selected in the comboboxes, just as if this is done in the Xcode itself.
            • On subsequent tns run ios the provisioning profile will be used.
            • It the platforms/ios is deleted and subsequent tns run ios is issued the provisioning profile selection will be lost and the client will be asked to select signing from ground up.
          • When not persisted, the selected provisioning profile will be used.
            • On subsequent tns run ios the provisioning profile selection will be lost and the client amy be asked to select provisioning profile from ground up. (Caching may skip xcodebuild here, you may have to delete platforms/ios/build for the dialogs to be displayed again)
    • When 'Automatic'
      • Ask for a Team, fail with proper error message when there are no teams to select from.
        • Ask for persistence choice "xccofig in app/App_Resources", "platforms/ios" or "do not persist"
          • When persisted in "xccofig in app/App_Resources" the team id is saved in the build.xcconfig
            • On a subsequent tns run ios no dialogs are presented and the team id from the build.xcconfig is used to sign the app.
            • If the plaforms/ios is deleted and subsequent tns run ios is issued the build.xcconfig will preserve the team id and it will be used to sign the app for device.
          • When persisted in "platforms/ios" the selected team id is saved in the Xcode project and if the platforms/ios/.xcodeproj is opened in Xcode the App target will have its signing set to "Automatic" and the selected team will be selected in the team combobox, just as if this is done in the Xcode itself.
            • On subsequent tns run ios the team id will be used.
            • It the platforms/ios is deleted and subsequent tns run ios is issued the team id will be lost and the client will be asked to select signing from ground up.
          • When not persisted, the selected team id will be used with automatic signing to sign the app.
            • On subsequent tns run ios the team id selection will be lost and the client will be asked to select signing from ground up. (Caching may skip xcodebuild here, you may have to delete platforms/ios/build for the dialogs to be displayed again)

Must be able to sign cocoa pods. This is important as at some points signing was passed as command line args and forced all build targets to use the provisioning specified. If the provisioning profile targets org.nativescript.* identifiers it may match the app target but pods are prefixed with different identifier (~org.cocoapods.<podname>) and the build fails to sign the cocoa pod targets.

For the future:

  • Currently switching the iOS device will not trigger validation nor new provisioning profile selection. It may be desirable to do such check.
  • Same provisioning profile will be set for both Debug and Release, it would be preferable to allow the provisioning profile selection to be forced from the command line.
  • We have publish command for iOS but there may be demand for distribution certificates to be selected during iOS build.
  • Aggressive caching may try to reuse previous builds and omit the signing dialogs along with xcodebuild even if the signing choice is not persisted.

@vchimev
Copy link

vchimev commented Jan 5, 2017

We need to cover also build for "generic device".
When we are preparing build for distribution, one of our Mac machines had connected device that is not added to the organization. The tns build ios was trying to pick provisioning profile that will support the device and failed, while we were trying to build the app for other devices.

@PanayotCankov
Copy link
Contributor Author

PanayotCankov commented Jan 6, 2017

Due to high complexity we will try to relax the supported scenarios and narrow the supported paths to:

  • Setting team id in the build.xcconfig should set Automatic signing style in the Xcode project and use the xcconfig team id for builds.
  • Setting provision in the build.xcconfig should set Manual signing style in the Xcode project and use the xcconfig defined provision.
  • Running tns * ios --team-id or tns * ios --provision will set Manual or Automatic signing style and set the team or provision in the native Xcode project. If the --team-id or --provision is not provided a value, the CLI will just list the teams and profiles, (or interactive dialog?) Both display names and UUIDs should be allowed.

@pkoleva pkoleva deleted the manual-provisioning branch January 18, 2017 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants