1"use strict"; 2 3Object.defineProperty(exports, "__esModule", { 4 value: true 5}); 6exports.getApplicationTargetNameForSchemeAsync = getApplicationTargetNameForSchemeAsync; 7exports.getArchiveBuildConfigurationForSchemeAsync = getArchiveBuildConfigurationForSchemeAsync; 8exports.getRunnableSchemesFromXcodeproj = getRunnableSchemesFromXcodeproj; 9exports.getSchemesFromXcodeproj = getSchemesFromXcodeproj; 10function _Paths() { 11 const data = require("./Paths"); 12 _Paths = function () { 13 return data; 14 }; 15 return data; 16} 17function _Target() { 18 const data = require("./Target"); 19 _Target = function () { 20 return data; 21 }; 22 return data; 23} 24function _Xcodeproj() { 25 const data = require("./utils/Xcodeproj"); 26 _Xcodeproj = function () { 27 return data; 28 }; 29 return data; 30} 31function _XML() { 32 const data = require("../utils/XML"); 33 _XML = function () { 34 return data; 35 }; 36 return data; 37} 38function getSchemesFromXcodeproj(projectRoot) { 39 return (0, _Paths().findSchemeNames)(projectRoot); 40} 41function getRunnableSchemesFromXcodeproj(projectRoot, { 42 configuration = 'Debug' 43} = {}) { 44 const project = (0, _Xcodeproj().getPbxproj)(projectRoot); 45 return (0, _Target().findSignableTargets)(project).map(([, target]) => { 46 let osType = 'iOS'; 47 const type = (0, _Xcodeproj().unquote)(target.productType); 48 if (type === _Target().TargetType.WATCH) { 49 osType = 'watchOS'; 50 } else if ( 51 // (apps) com.apple.product-type.application 52 // (app clips) com.apple.product-type.application.on-demand-install-capable 53 // NOTE(EvanBacon): This matches against `watchOS` as well so we check for watch first. 54 type.startsWith(_Target().TargetType.APPLICATION)) { 55 // Attempt to resolve the platform SDK for each target so we can filter devices. 56 const xcConfigurationList = project.hash.project.objects.XCConfigurationList[target.buildConfigurationList]; 57 if (xcConfigurationList) { 58 const buildConfiguration = xcConfigurationList.buildConfigurations.find(value => value.comment === configuration) || xcConfigurationList.buildConfigurations[0]; 59 if (buildConfiguration !== null && buildConfiguration !== void 0 && buildConfiguration.value) { 60 var _project$hash$project; 61 const xcBuildConfiguration = (_project$hash$project = project.hash.project.objects.XCBuildConfiguration) === null || _project$hash$project === void 0 ? void 0 : _project$hash$project[buildConfiguration.value]; 62 const buildSdkRoot = xcBuildConfiguration.buildSettings.SDKROOT; 63 if (buildSdkRoot === 'appletvos' || 'TVOS_DEPLOYMENT_TARGET' in xcBuildConfiguration.buildSettings) { 64 // Is a TV app... 65 osType = 'tvOS'; 66 } else if (buildSdkRoot === 'iphoneos') { 67 osType = 'iOS'; 68 } 69 } 70 } 71 } 72 return { 73 name: (0, _Xcodeproj().unquote)(target.name), 74 osType, 75 type: (0, _Xcodeproj().unquote)(target.productType) 76 }; 77 }); 78} 79async function readSchemeAsync(projectRoot, scheme) { 80 const allSchemePaths = (0, _Paths().findSchemePaths)(projectRoot); 81 const re = new RegExp(`/${scheme}.xcscheme`, 'i'); 82 const schemePath = allSchemePaths.find(i => re.exec(i)); 83 if (schemePath) { 84 return await (0, _XML().readXMLAsync)({ 85 path: schemePath 86 }); 87 } else { 88 throw new Error(`scheme '${scheme}' does not exist, make sure it's marked as shared`); 89 } 90} 91async function getApplicationTargetNameForSchemeAsync(projectRoot, scheme) { 92 var _schemeXML$Scheme, _schemeXML$Scheme$Bui, _schemeXML$Scheme$Bui2, _schemeXML$Scheme$Bui3, _schemeXML$Scheme$Bui4; 93 const schemeXML = await readSchemeAsync(projectRoot, scheme); 94 const buildActionEntry = schemeXML === null || schemeXML === void 0 ? void 0 : (_schemeXML$Scheme = schemeXML.Scheme) === null || _schemeXML$Scheme === void 0 ? void 0 : (_schemeXML$Scheme$Bui = _schemeXML$Scheme.BuildAction) === null || _schemeXML$Scheme$Bui === void 0 ? void 0 : (_schemeXML$Scheme$Bui2 = _schemeXML$Scheme$Bui[0]) === null || _schemeXML$Scheme$Bui2 === void 0 ? void 0 : (_schemeXML$Scheme$Bui3 = _schemeXML$Scheme$Bui2.BuildActionEntries) === null || _schemeXML$Scheme$Bui3 === void 0 ? void 0 : (_schemeXML$Scheme$Bui4 = _schemeXML$Scheme$Bui3[0]) === null || _schemeXML$Scheme$Bui4 === void 0 ? void 0 : _schemeXML$Scheme$Bui4.BuildActionEntry; 95 const targetName = (buildActionEntry === null || buildActionEntry === void 0 ? void 0 : buildActionEntry.length) === 1 ? getBlueprintName(buildActionEntry[0]) : getBlueprintName(buildActionEntry === null || buildActionEntry === void 0 ? void 0 : buildActionEntry.find(entry => { 96 var _entry$BuildableRefer, _entry$BuildableRefer2, _entry$BuildableRefer3, _entry$BuildableRefer4; 97 return (_entry$BuildableRefer = entry.BuildableReference) === null || _entry$BuildableRefer === void 0 ? void 0 : (_entry$BuildableRefer2 = _entry$BuildableRefer[0]) === null || _entry$BuildableRefer2 === void 0 ? void 0 : (_entry$BuildableRefer3 = _entry$BuildableRefer2['$']) === null || _entry$BuildableRefer3 === void 0 ? void 0 : (_entry$BuildableRefer4 = _entry$BuildableRefer3.BuildableName) === null || _entry$BuildableRefer4 === void 0 ? void 0 : _entry$BuildableRefer4.endsWith('.app'); 98 })); 99 if (!targetName) { 100 throw new Error(`${scheme}.xcscheme seems to be corrupted`); 101 } 102 return targetName; 103} 104async function getArchiveBuildConfigurationForSchemeAsync(projectRoot, scheme) { 105 var _schemeXML$Scheme2, _schemeXML$Scheme2$Ar, _schemeXML$Scheme2$Ar2, _schemeXML$Scheme2$Ar3; 106 const schemeXML = await readSchemeAsync(projectRoot, scheme); 107 const buildConfiguration = schemeXML === null || schemeXML === void 0 ? void 0 : (_schemeXML$Scheme2 = schemeXML.Scheme) === null || _schemeXML$Scheme2 === void 0 ? void 0 : (_schemeXML$Scheme2$Ar = _schemeXML$Scheme2.ArchiveAction) === null || _schemeXML$Scheme2$Ar === void 0 ? void 0 : (_schemeXML$Scheme2$Ar2 = _schemeXML$Scheme2$Ar[0]) === null || _schemeXML$Scheme2$Ar2 === void 0 ? void 0 : (_schemeXML$Scheme2$Ar3 = _schemeXML$Scheme2$Ar2['$']) === null || _schemeXML$Scheme2$Ar3 === void 0 ? void 0 : _schemeXML$Scheme2$Ar3.buildConfiguration; 108 if (!buildConfiguration) { 109 throw new Error(`${scheme}.xcscheme seems to be corrupted`); 110 } 111 return buildConfiguration; 112} 113function getBlueprintName(entry) { 114 var _entry$BuildableRefer5, _entry$BuildableRefer6, _entry$BuildableRefer7; 115 return entry === null || entry === void 0 ? void 0 : (_entry$BuildableRefer5 = entry.BuildableReference) === null || _entry$BuildableRefer5 === void 0 ? void 0 : (_entry$BuildableRefer6 = _entry$BuildableRefer5[0]) === null || _entry$BuildableRefer6 === void 0 ? void 0 : (_entry$BuildableRefer7 = _entry$BuildableRefer6['$']) === null || _entry$BuildableRefer7 === void 0 ? void 0 : _entry$BuildableRefer7.BlueprintName; 116} 117//# sourceMappingURL=BuildScheme.js.map