1{"version":3,"file":"Bitcode.js","names":["_iosPlugins","data","require","_warnings","_Xcodeproj","withBitcode","config","withXcodeProject","modResults","setBitcodeWithConfig","project","exports","withCustomBitcode","bitcode","setBitcode","getBitcode","_config$ios","ios","isDefaultBehavior","targetName","undefined","isBitcodeEnabled","configs","Object","entries","pbxXCBuildConfigurationSection","filter","isNotComment","hasConfiguration","find","configuration","name","addBuildProperty","names","Set","map","sort","addWarningIOS","join"],"sources":["../../src/ios/Bitcode.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport { XcodeProject } from 'xcode';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withXcodeProject } from '../plugins/ios-plugins';\nimport { addWarningIOS } from '../utils/warnings';\nimport { isNotComment } from './utils/Xcodeproj';\n\ntype Bitcode = NonNullable<ExpoConfig['ios']>['bitcode'];\n\n/**\n * Plugin to set a bitcode preference for the Xcode project\n * based on the project's Expo config `ios.bitcode` value.\n */\nexport const withBitcode: ConfigPlugin = (config) => {\n  return withXcodeProject(config, async (config) => {\n    config.modResults = await setBitcodeWithConfig(config, {\n      project: config.modResults,\n    });\n    return config;\n  });\n};\n\n/**\n * Plugin to set a custom bitcode preference for the Xcode project.\n * Does not read from the Expo config `ios.bitcode`.\n *\n * @param bitcode custom bitcode setting.\n */\nexport const withCustomBitcode: ConfigPlugin<Bitcode> = (config, bitcode) => {\n  return withXcodeProject(config, async (config) => {\n    config.modResults = await setBitcode(bitcode, {\n      project: config.modResults,\n    });\n    return config;\n  });\n};\n\n/**\n * Get the bitcode preference from the Expo config.\n */\nexport function getBitcode(config: Pick<ExpoConfig, 'ios'>): Bitcode {\n  return config.ios?.bitcode;\n}\n\n/**\n * Enable or disable the `ENABLE_BITCODE` property of the project configurations.\n */\nexport function setBitcodeWithConfig(\n  config: Pick<ExpoConfig, 'ios'>,\n  { project }: { project: XcodeProject }\n): XcodeProject {\n  const bitcode = getBitcode(config);\n  return setBitcode(bitcode, { project });\n}\n\n/**\n * Enable or disable the `ENABLE_BITCODE` property.\n */\nexport function setBitcode(bitcode: Bitcode, { project }: { project: XcodeProject }): XcodeProject {\n  const isDefaultBehavior = bitcode == null;\n  // If the value is undefined, then do nothing.\n  if (isDefaultBehavior) {\n    return project;\n  }\n\n  const targetName = typeof bitcode === 'string' ? bitcode : undefined;\n  const isBitcodeEnabled = !!bitcode;\n  if (targetName) {\n    // Assert if missing\n    const configs = Object.entries(project.pbxXCBuildConfigurationSection()).filter(isNotComment);\n    const hasConfiguration = configs.find(([, configuration]) => configuration.name === targetName);\n    if (hasConfiguration) {\n      // If targetName is defined then disable bitcode everywhere.\n      project.addBuildProperty('ENABLE_BITCODE', 'NO');\n    } else {\n      const names = [\n        // Remove duplicates, wrap in double quotes, and sort alphabetically.\n        ...new Set(configs.map(([, configuration]) => `\"${configuration.name}\"`)),\n      ].sort();\n      addWarningIOS(\n        'ios.bitcode',\n        `No configuration named \"${targetName}\". Expected one of: ${names.join(', ')}.`\n      );\n    }\n  }\n\n  project.addBuildProperty('ENABLE_BITCODE', isBitcodeEnabled ? 'YES' : 'NO', targetName);\n\n  return project;\n}\n"],"mappings":";;;;;;;;;AAIA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,UAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA;AACA;AACA;AACA;AACO,MAAMI,WAAyB,GAAIC,MAAM,IAAK;EACnD,OAAO,IAAAC,8BAAgB,EAACD,MAAM,EAAE,MAAOA,MAAM,IAAK;IAChDA,MAAM,CAACE,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