1"use strict"; 2 3Object.defineProperty(exports, "__esModule", { 4 value: true 5}); 6exports.getName = getName; 7exports.setDisplayName = setDisplayName; 8exports.setName = setName; 9exports.setProductName = setProductName; 10exports.withProductName = exports.withName = exports.withDisplayName = void 0; 11function _Target() { 12 const data = require("./Target"); 13 _Target = function () { 14 return data; 15 }; 16 return data; 17} 18function _Xcodeproj() { 19 const data = require("./utils/Xcodeproj"); 20 _Xcodeproj = function () { 21 return data; 22 }; 23 return data; 24} 25function _iosPlugins() { 26 const data = require("../plugins/ios-plugins"); 27 _iosPlugins = function () { 28 return data; 29 }; 30 return data; 31} 32const withDisplayName = (0, _iosPlugins().createInfoPlistPluginWithPropertyGuard)(setDisplayName, { 33 infoPlistProperty: 'CFBundleDisplayName', 34 expoConfigProperty: 'name' 35}, 'withDisplayName'); 36exports.withDisplayName = withDisplayName; 37const withName = (0, _iosPlugins().createInfoPlistPluginWithPropertyGuard)(setName, { 38 infoPlistProperty: 'CFBundleName', 39 expoConfigProperty: 'name' 40}, 'withName'); 41 42/** Set the PRODUCT_NAME variable in the xcproj file based on the app.json name property. */ 43exports.withName = withName; 44const withProductName = config => { 45 return (0, _iosPlugins().withXcodeProject)(config, config => { 46 config.modResults = setProductName(config, config.modResults); 47 return config; 48 }); 49}; 50exports.withProductName = withProductName; 51function getName(config) { 52 return typeof config.name === 'string' ? config.name : null; 53} 54 55/** 56 * CFBundleDisplayName is used for most things: the name on the home screen, in 57 * notifications, and others. 58 */ 59function setDisplayName(configOrName, { 60 CFBundleDisplayName, 61 ...infoPlist 62}) { 63 let name = null; 64 if (typeof configOrName === 'string') { 65 name = configOrName; 66 } else { 67 name = getName(configOrName); 68 } 69 if (!name) { 70 return infoPlist; 71 } 72 return { 73 ...infoPlist, 74 CFBundleDisplayName: name 75 }; 76} 77 78/** 79 * CFBundleName is recommended to be 16 chars or less and is used in lists, eg: 80 * sometimes on the App Store 81 */ 82function setName(config, { 83 CFBundleName, 84 ...infoPlist 85}) { 86 const name = getName(config); 87 if (!name) { 88 return infoPlist; 89 } 90 return { 91 ...infoPlist, 92 CFBundleName: name 93 }; 94} 95function setProductName(config, project) { 96 var _getName; 97 const name = (0, _Xcodeproj().sanitizedName)((_getName = getName(config)) !== null && _getName !== void 0 ? _getName : ''); 98 if (!name) { 99 return project; 100 } 101 const quotedName = ensureQuotes(name); 102 const [, nativeTarget] = (0, _Target().findFirstNativeTarget)(project); 103 (0, _Xcodeproj().getBuildConfigurationsForListId)(project, nativeTarget.buildConfigurationList).forEach(([, item]) => { 104 item.buildSettings.PRODUCT_NAME = quotedName; 105 }); 106 return project; 107} 108const ensureQuotes = value => { 109 if (!value.match(/^['"]/)) { 110 return `"${value}"`; 111 } 112 return value; 113}; 114//# sourceMappingURL=Name.js.map