1{"version":3,"file":"Bitcode.js","names":["withBitcode","config","withXcodeProject","modResults","setBitcodeWithConfig","project","withCustomBitcode","bitcode","setBitcode","getBitcode","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;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;AACA;AACA;AACA;AACO,MAAMA,WAAyB,GAAIC,MAAM,IAAK;EACnD,OAAO,IAAAC,8BAAgB,EAACD,MAAM,EAAE,MAAOA,MAAM,IAAK;IAChDA,MAAM,CAACE,UAAU,GAAG,MAAMC,oBAAoB,CAACH,MAAM,EAAE;MACrDI,OAAO,EAAEJ,MAAM,CAACE;IAClB,CAAC,CAAC;IACF,OAAOF,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALA;AAMO,MAAMK,iBAAwC,GAAG,CAACL,MAAM,EAAEM,OAAO,KAAK;EAC3E,OAAO,IAAAL,8BAAgB,EAACD,MAAM,EAAE,MAAOA,MAAM,IAA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