diff --git a/packages/flagship/src/commands/init.ts b/packages/flagship/src/commands/init.ts index ea0c9f7930..9748d78262 100644 --- a/packages/flagship/src/commands/init.ts +++ b/packages/flagship/src/commands/init.ts @@ -190,6 +190,7 @@ function initIOS( // iOS Specific configuration ios.exceptionDomains(configuration); // Add ATS exception domains for iOS ios.capabilities(configuration); // Add app capabilities + ios.targetedDevice(configuration); // Set targeted device ios.entitlements(configuration); // Add app entitlements ios.usageDescription(configuration); // Add usage descriptions ios.sentryProperties(configuration); diff --git a/packages/flagship/src/lib/ios.ts b/packages/flagship/src/lib/ios.ts index 8f17ffefce..de34d4b6ac 100644 --- a/packages/flagship/src/lib/ios.ts +++ b/packages/flagship/src/lib/ios.ts @@ -50,6 +50,31 @@ export function capabilities(configuration: Config): void { } } +/** + * Sets the app's targeted build devices + * + * @param {object} configuration The project configuration. + */ + +export function targetedDevice(configuration: Config): void { + if (configuration.targetedDevices) { + helpers.logInfo(`selecting targeted devices: ${configuration.targetedDevices}`); + + const devices: {[key: string]: any} = { + iPhone: 1, + iPad: 2, + Universal: `"1,2"` + }; + + fs.update( + path.ios.pbxprojFilePath(configuration), + `PRODUCT_NAME = ${configuration.name}`, + `PRODUCT_NAME = ${configuration.name}; + TARGETED_DEVICE_FAMILY = ${devices[configuration.targetedDevices]}` + ); + } +} + /** * Enables entitlements for the project. * diff --git a/packages/flagship/src/types.ts b/packages/flagship/src/types.ts index 140cd61911..80adf80e9b 100644 --- a/packages/flagship/src/types.ts +++ b/packages/flagship/src/types.ts @@ -3,6 +3,12 @@ export interface CodepushConfig { appKey: string; } +export enum TargetedDevices { + iPhone = 'iPhone', + iPad = 'iPad', + Universal = 'Universal' +} + export interface Config { name: string; displayName: string; @@ -76,6 +82,8 @@ export interface Config { propertiesPath: string; }; + targetedDevices?: TargetedDevices; + webPath?: string; webTitle?: string; webScriptInjectHeader?: string; diff --git a/packages/pirateship/env/common.js b/packages/pirateship/env/common.js index 47672cedfd..7292808d4b 100644 --- a/packages/pirateship/env/common.js +++ b/packages/pirateship/env/common.js @@ -78,5 +78,6 @@ module.exports = { string: '' } ], - associatedDomains: [] + associatedDomains: [], + targetedDevices: 'Universal' };