UNPKG

2.3 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const WarningAggregator_1 = require("../WarningAggregator");
4function getSupportsTablet(config) {
5 var _a, _b;
6 if ((_a = config.ios) === null || _a === void 0 ? void 0 : _a.supportsTablet) {
7 return (_b = config.ios) === null || _b === void 0 ? void 0 : _b.supportsTablet;
8 }
9 return false;
10}
11exports.getSupportsTablet = getSupportsTablet;
12function getIsTabletOnly(config) {
13 var _a;
14 if ((_a = config.ios) === null || _a === void 0 ? void 0 : _a.isTabletOnly) {
15 return config.ios.isTabletOnly;
16 }
17 return false;
18}
19exports.getIsTabletOnly = getIsTabletOnly;
20function getDeviceFamilies(config) {
21 let supportsTablet = getSupportsTablet(config);
22 let isTabletOnly = getIsTabletOnly(config);
23 // 1 is iPhone, 2 is iPad
24 if (isTabletOnly) {
25 return [2];
26 }
27 else if (supportsTablet) {
28 return [1, 2];
29 }
30 else {
31 return [1];
32 }
33}
34exports.getDeviceFamilies = getDeviceFamilies;
35/**
36 * Add to pbxproj under TARGETED_DEVICE_FAMILY
37 */
38function setDeviceFamily(config, projectRoot) {
39 const deviceFamilies = getDeviceFamilies(config);
40 let supportsTablet = getSupportsTablet(config);
41 let isTabletOnly = getIsTabletOnly(config);
42 if (isTabletOnly) {
43 WarningAggregator_1.addWarningIOS('isTabletOnly', 'You will need to configure this in the "General" tab for your project target in Xcode.');
44 }
45 else if (supportsTablet) {
46 WarningAggregator_1.addWarningIOS('supportsTablet', 'You will need to configure this in the "General" tab for your project target in Xcode.');
47 }
48 // TODO: we might need to actually fork the "xcode" package to make this work
49 // See: https://github.com/apache/cordova-node-xcode/issues/86
50 //
51 // const project = getPbxproj(projectRoot);
52 // Object.entries(project.pbxXCBuildConfigurationSection())
53 // .filter(removeComments)
54 // .filter(isBuildConfig)
55 // .filter(removeTestHosts)
56 // .forEach(({ 1: { buildSettings } }: any) => {
57 // buildSettings.TARGETED_DEVICE_FAMILY = '1';
58 // });
59 // fs.writeFileSync(project.filepath, project.writeSync());
60}
61exports.setDeviceFamily = setDeviceFamily;
62//# sourceMappingURL=DeviceFamily.js.map
\No newline at end of file