Skip to content

Commit

Permalink
feat(flagship): add targeted device prop to ios config
Browse files Browse the repository at this point in the history
  • Loading branch information
sdenaci authored and skyeckstrom committed Sep 7, 2018
1 parent be87dd0 commit 3f287a0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/flagship/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 25 additions & 0 deletions packages/flagship/src/lib/ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
8 changes: 8 additions & 0 deletions packages/flagship/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,6 +82,8 @@ export interface Config {
propertiesPath: string;
};

targetedDevices?: TargetedDevices;

webPath?: string;
webTitle?: string;
webScriptInjectHeader?: string;
Expand Down
3 changes: 2 additions & 1 deletion packages/pirateship/env/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ module.exports = {
string: ''
}
],
associatedDomains: []
associatedDomains: [],
targetedDevices: 'Universal'
};

0 comments on commit 3f287a0

Please sign in to comment.