From cd00be903ca50bbb7acfcaefce2698167e00a68b Mon Sep 17 00:00:00 2001 From: Jon Zgoda Date: Wed, 10 Apr 2019 13:28:37 -0500 Subject: [PATCH] feat: add iCloudContainerEnvironment build option --- docs/man_pages/project/testing/build-ios.md | 1 + lib/commands/appstore-upload.ts | 1 + lib/commands/build.ts | 1 + lib/declarations.d.ts | 1 + lib/definitions/project.d.ts | 6 +++++- lib/helpers/livesync-command-helper.ts | 1 + lib/options.ts | 1 + lib/services/ios-project-service.ts | 13 ++++++++++++- lib/services/livesync/livesync-service.ts | 1 + lib/services/platform-service.ts | 1 + lib/services/test-execution-service.ts | 1 + test/services/android-project-service.ts | 1 + 12 files changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/man_pages/project/testing/build-ios.md b/docs/man_pages/project/testing/build-ios.md index 611436531d..9f5f952fac 100644 --- a/docs/man_pages/project/testing/build-ios.md +++ b/docs/man_pages/project/testing/build-ios.md @@ -23,6 +23,7 @@ General | `$ tns build ios [--for-device] [--release] [--copy-to ] [- * `--release` - If set, produces a release build. Otherwise, produces a debug build. * `--for-device` - If set, produces an application package that you can deploy on device. Otherwise, produces a build that you can run only in the native iOS Simulator. +* `--i-cloud-container-environment` - If set, adds the passed `iCloudContainerEnvironment` when exporting an application package with the `--for-device` option. * `--copy-to` - Specifies the file path where the built `.ipa` will be copied. If it points to a non-existent directory path, it will be created. If the specified value is existing directory, the original file name will be used. * `--team-id` - If used without parameter, lists all team names and ids. If used with team name or id, it will switch to automatic signing mode and configure the .xcodeproj file of your app. In this case .xcconfig should not contain any provisioning/team id flags. This team id will be further used for codesigning the app. For Xcode 9.0+, xcodebuild will be allowed to update and modify automatically managed provisioning profiles. * `--provision` - If used without parameter, lists all eligible provisioning profiles. If used with UUID or name of your provisioning profile, it will switch to manual signing mode and configure the .xcodeproj file of your app. In this case xcconfig should not contain any provisioning/team id flags. This provisioning profile will be further used for codesigning the app. diff --git a/lib/commands/appstore-upload.ts b/lib/commands/appstore-upload.ts index 03168cde65..7b0729dc30 100644 --- a/lib/commands/appstore-upload.ts +++ b/lib/commands/appstore-upload.ts @@ -78,6 +78,7 @@ export class PublishIOS implements ICommand { provision: this.$options.provision, teamId: this.$options.teamId, buildForDevice: true, + iCloudContainerEnvironment: this.$options.iCloudContainerEnvironment, mobileProvisionIdentifier, codeSignIdentity }; diff --git a/lib/commands/build.ts b/lib/commands/build.ts index 0c4f091f19..33d7db7639 100644 --- a/lib/commands/build.ts +++ b/lib/commands/build.ts @@ -33,6 +33,7 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase { await this.$platformService.preparePlatform(platformInfo); const buildConfig: IBuildConfig = { buildForDevice: this.$options.forDevice, + iCloudContainerEnvironment: this.$options.iCloudContainerEnvironment, projectDir: this.$options.path, clean: this.$options.clean, teamId: this.$options.teamId, diff --git a/lib/declarations.d.ts b/lib/declarations.d.ts index e7c4a4456d..49ab41fe42 100644 --- a/lib/declarations.d.ts +++ b/lib/declarations.d.ts @@ -544,6 +544,7 @@ interface IOptions extends IRelease, IDeviceIdentifier, IJustLaunch, IAvd, IAvai copyTo: string; debugTransport: boolean; forDevice: boolean; + iCloudContainerEnvironment: string; framework: string; frameworkName: string; frameworkVersion: string; diff --git a/lib/definitions/project.d.ts b/lib/definitions/project.d.ts index 05d67d21ab..8de8d95e18 100644 --- a/lib/definitions/project.d.ts +++ b/lib/definitions/project.d.ts @@ -304,6 +304,10 @@ interface IBuildForDevice { buildForDevice: boolean; } +interface IiCloudContainerEnvironment { + iCloudContainerEnvironment: string; +} + interface INativePrepare { skipNativePrepare: boolean; } @@ -317,7 +321,7 @@ interface IBuildConfig extends IAndroidBuildOptionsSettings, IiOSBuildConfig, IP /** * Describes iOS-specific build configuration properties */ -interface IiOSBuildConfig extends IBuildForDevice, IDeviceIdentifier, IProvision, ITeamIdentifier, IRelease { +interface IiOSBuildConfig extends IBuildForDevice, IiCloudContainerEnvironment, IDeviceIdentifier, IProvision, ITeamIdentifier, IRelease { /** * Identifier of the mobile provision which will be used for the build. If not set a provision will be selected automatically if possible. */ diff --git a/lib/helpers/livesync-command-helper.ts b/lib/helpers/livesync-command-helper.ts index 2d061a7c10..17c77326f2 100644 --- a/lib/helpers/livesync-command-helper.ts +++ b/lib/helpers/livesync-command-helper.ts @@ -76,6 +76,7 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper { const buildConfig: IBuildConfig = { buildForDevice: !d.isEmulator, + iCloudContainerEnvironment: this.$options.iCloudContainerEnvironment, projectDir: this.$options.path, clean: this.$options.clean, teamId: this.$options.teamId, diff --git a/lib/options.ts b/lib/options.ts index 79931e43e7..f06be1e70b 100644 --- a/lib/options.ts +++ b/lib/options.ts @@ -76,6 +76,7 @@ export class Options { framework: { type: OptionType.String, hasSensitiveValue: false }, frameworkVersion: { type: OptionType.String, hasSensitiveValue: false }, forDevice: { type: OptionType.Boolean, hasSensitiveValue: false }, + iCloudContainerEnvironment: { type: OptionType.String, hasSensitiveValue: false }, provision: { type: OptionType.Object, hasSensitiveValue: true }, client: { type: OptionType.Boolean, default: true, hasSensitiveValue: false }, env: { type: OptionType.Object, hasSensitiveValue: false }, diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 85960e4ec2..3a68c26b91 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -279,6 +279,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ return exportFile; } + private iCloudContainerEnvironment(buildConfig: IBuildConfig): string { + return buildConfig && buildConfig.iCloudContainerEnvironment ? buildConfig.iCloudContainerEnvironment : null; + } + /** * Exports .xcarchive for a development device. */ @@ -287,6 +291,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ const projectRoot = platformData.projectRoot; const archivePath = options.archivePath; const exportOptionsMethod = await this.getExportOptionsMethod(projectData, archivePath); + const iCloudContainerEnvironment = this.iCloudContainerEnvironment(buildConfig); let plistTemplate = ` @@ -304,7 +309,13 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ uploadBitcode compileBitcode - + `; + if (iCloudContainerEnvironment) { + plistTemplate += ` + iCloudContainerEnvironment + ${iCloudContainerEnvironment}`; + } + plistTemplate += ` `; diff --git a/lib/services/livesync/livesync-service.ts b/lib/services/livesync/livesync-service.ts index fa1eb1502b..8f68a793b6 100644 --- a/lib/services/livesync/livesync-service.ts +++ b/lib/services/livesync/livesync-service.ts @@ -858,6 +858,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi private getInstallApplicationBuildConfig(deviceIdentifier: string, projectDir: string, opts: { isEmulator: boolean }): IBuildConfig { const buildConfig: IBuildConfig = { buildForDevice: !opts.isEmulator, + iCloudContainerEnvironment: null, release: false, device: deviceIdentifier, provision: null, diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index e481600407..4129447144 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -548,6 +548,7 @@ export class PlatformService extends EventEmitter implements IPlatformService { const action = async (device: Mobile.IDevice): Promise => { const buildConfig: IBuildConfig = { buildForDevice: !this.$devicesService.isiOSSimulator(device), + iCloudContainerEnvironment: null, projectDir: deployInfo.deployOptions.projectDir, release: deployInfo.deployOptions.release, device: deployInfo.deployOptions.device, diff --git a/lib/services/test-execution-service.ts b/lib/services/test-execution-service.ts index 04f6590be2..2a7a9d7689 100644 --- a/lib/services/test-execution-service.ts +++ b/lib/services/test-execution-service.ts @@ -84,6 +84,7 @@ export class TestExecutionService implements ITestExecutionService { buildAction: async (): Promise => { const buildConfig: IBuildConfig = { buildForDevice: !d.isEmulator, + iCloudContainerEnvironment: this.$options.iCloudContainerEnvironment, projectDir: this.$options.path, clean: this.$options.clean, teamId: this.$options.teamId, diff --git a/test/services/android-project-service.ts b/test/services/android-project-service.ts index aad86d5916..8d33c84642 100644 --- a/test/services/android-project-service.ts +++ b/test/services/android-project-service.ts @@ -43,6 +43,7 @@ const getDefautlBuildConfig = (): IBuildConfig => { return { release: true, buildForDevice: false, + iCloudContainerEnvironment: null, device: "testDevice", provision: null, teamId: "",