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