1"use strict"; 2 3Object.defineProperty(exports, "__esModule", { 4 value: true 5}); 6exports.getBitcode = getBitcode; 7exports.setBitcode = setBitcode; 8exports.setBitcodeWithConfig = setBitcodeWithConfig; 9exports.withCustomBitcode = exports.withBitcode = void 0; 10function _iosPlugins() { 11 const data = require("../plugins/ios-plugins"); 12 _iosPlugins = function () { 13 return data; 14 }; 15 return data; 16} 17function _warnings() { 18 const data = require("../utils/warnings"); 19 _warnings = 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} 31/** 32 * Plugin to set a bitcode preference for the Xcode project 33 * based on the project's Expo config `ios.bitcode` value. 34 */ 35const withBitcode = config => { 36 return (0, _iosPlugins().withXcodeProject)(config, async config => { 37 config.modResults = await setBitcodeWithConfig(config, { 38 project: config.modResults 39 }); 40 return config; 41 }); 42}; 43 44/** 45 * Plugin to set a custom bitcode preference for the Xcode project. 46 * Does not read from the Expo config `ios.bitcode`. 47 * 48 * @param bitcode custom bitcode setting. 49 */ 50exports.withBitcode = withBitcode; 51const withCustomBitcode = (config, bitcode) => { 52 return (0, _iosPlugins().withXcodeProject)(config, async config => { 53 config.modResults = await setBitcode(bitcode, { 54 project: config.modResults 55 }); 56 return config; 57 }); 58}; 59 60/** 61 * Get the bitcode preference from the Expo config. 62 */ 63exports.withCustomBitcode = withCustomBitcode; 64function getBitcode(config) { 65 var _config$ios; 66 return (_config$ios = config.ios) === null || _config$ios === void 0 ? void 0 : _config$ios.bitcode; 67} 68 69/** 70 * Enable or disable the `ENABLE_BITCODE` property of the project configurations. 71 */ 72function setBitcodeWithConfig(config, { 73 project 74}) { 75 const bitcode = getBitcode(config); 76 return setBitcode(bitcode, { 77 project 78 }); 79} 80 81/** 82 * Enable or disable the `ENABLE_BITCODE` property. 83 */ 84function setBitcode(bitcode, { 85 project 86}) { 87 const isDefaultBehavior = bitcode == null; 88 // If the value is undefined, then do nothing. 89 if (isDefaultBehavior) { 90 return project; 91 } 92 const targetName = typeof bitcode === 'string' ? bitcode : undefined; 93 const isBitcodeEnabled = !!bitcode; 94 if (targetName) { 95 // Assert if missing 96 const configs = Object.entries(project.pbxXCBuildConfigurationSection()).filter(_Xcodeproj().isNotComment); 97 const hasConfiguration = configs.find(([, configuration]) => configuration.name === targetName); 98 if (hasConfiguration) { 99 // If targetName is defined then disable bitcode everywhere. 100 project.addBuildProperty('ENABLE_BITCODE', 'NO'); 101 } else { 102 const names = [ 103 // Remove duplicates, wrap in double quotes, and sort alphabetically. 104 ...new Set(configs.map(([, configuration]) => `"${configuration.name}"`))].sort(); 105 (0, _warnings().addWarningIOS)('ios.bitcode', `No configuration named "${targetName}". Expected one of: ${names.join(', ')}.`); 106 } 107 } 108 project.addBuildProperty('ENABLE_BITCODE', isBitcodeEnabled ? 'YES' : 'NO', targetName); 109 return project; 110} 111//# sourceMappingURL=Bitcode.js.map