1{"version":3,"file":"ios-plugins.js","names":["_obj","data","require","_warnings","_withMod","createInfoPlistPlugin","action","name","withUnknown","config","withInfoPlist","modResults","Object","defineProperty","value","createInfoPlistPluginWithPropertyGuard","settings","_config$modRawConfig$","_config$modRawConfig$2","existingProperty","expoPropertyGetter","get","expoConfigProperty","modRawConfig","ios","infoPlist","infoPlistProperty","undefined","addWarningIOS","createEntitlementsPlugin","withEntitlementsPlist","withAppDelegate","withMod","platform","mod","exports","entitlements","withExpoPlist","withXcodeProject","withPodfileProperties"],"sources":["../../src/plugins/ios-plugins.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\nimport type { JSONObject } from '@expo/json-file';\nimport type { XcodeProject } from 'xcode';\n\nimport type { ConfigPlugin, Mod } from '../Plugin.types';\nimport type { ExpoPlist, InfoPlist } from '../ios/IosConfig.types';\nimport type { AppDelegateProjectFile } from '../ios/Paths';\nimport { get } from '../utils/obj';\nimport { addWarningIOS } from '../utils/warnings';\nimport { withMod } from './withMod';\n\ntype MutateInfoPlistAction = (\n expo: ExpoConfig,\n infoPlist: InfoPlist\n) => Promise<InfoPlist> | InfoPlist;\n\n/**\n * Helper method for creating mods from existing config functions.\n *\n * @param action\n */\nexport function createInfoPlistPlugin(action: MutateInfoPlistAction, name?: string): ConfigPlugin {\n const withUnknown: ConfigPlugin = (config) =>\n withInfoPlist(config, async (config) => {\n config.modResults = await action(config, config.modResults);\n return config;\n });\n if (name) {\n Object.defineProperty(withUnknown, 'name', {\n value: name,\n });\n }\n return withUnknown;\n}\n\nexport function createInfoPlistPluginWithPropertyGuard(\n action: MutateInfoPlistAction,\n settings: {\n infoPlistProperty: string;\n expoConfigProperty: string;\n expoPropertyGetter?: (config: ExpoConfig) => string;\n },\n name?: string\n): ConfigPlugin {\n const withUnknown: ConfigPlugin = (config) =>\n withInfoPlist(config, async (config) => {\n const existingProperty = settings.expoPropertyGetter\n ? settings.expoPropertyGetter(config)\n : get(config, settings.expoConfigProperty);\n // If the user explicitly sets a value in the infoPlist, we should respect that.\n if (config.modRawConfig.ios?.infoPlist?.[settings.infoPlistProperty] === undefined) {\n config.modResults = await action(config, config.modResults);\n } else if (existingProperty !== undefined) {\n // Only warn if there is a conflict.\n addWarningIOS(\n settings.expoConfigProperty,\n `\"ios.infoPlist.${settings.infoPlistProperty}\" is set in the config. Ignoring abstract property \"${settings.expoConfigProperty}\": ${existingProperty}`\n );\n }\n\n return config;\n });\n if (name) {\n Object.defineProperty(withUnknown, 'name', {\n value: name,\n });\n }\n return withUnknown;\n}\n\ntype MutateEntitlementsPlistAction = (expo: ExpoConfig, entitlements: JSONObject) => JSONObject;\n\n/**\n * Helper method for creating mods from existing config functions.\n *\n * @param action\n */\nexport function createEntitlementsPlugin(\n action: MutateEntitlementsPlistAction,\n name: string\n): ConfigPlugin {\n const withUnknown: ConfigPlugin = (config) =>\n withEntitlementsPlist(config, async (config) => {\n config.modResults = await action(config, config.modResults);\n return config;\n });\n if (name) {\n Object.defineProperty(withUnknown, 'name', {\n value: name,\n });\n }\n return withUnknown;\n}\n\n/**\n * Provides the AppDelegate file for modification.\n *\n * @param config\n * @param action\n */\nexport const withAppDelegate: ConfigPlugin<Mod<AppDelegateProjectFile>> = (config, action) => {\n return withMod(config, {\n platform: 'ios',\n mod: 'appDelegate',\n action,\n });\n};\n\n/**\n * Provides the Info.plist file for modification.\n * Keeps the config's expo.ios.infoPlist object in sync with the data.\n *\n * @param config\n * @param action\n */\nexport const withInfoPlist: ConfigPlugin<Mod<InfoPlist>> = (config, action) => {\n return withMod<InfoPlist>(config, {\n platform: 'ios',\n mod: 'infoPlist',\n async action(config) {\n config = await action(config);\n if (!config.ios) {\n config.ios = {};\n }\n config.ios.infoPlist = config.modResults;\n return config;\n },\n });\n};\n\n/**\n * Provides the main .entitlements file for modification.\n * Keeps the config's expo.ios.entitlements object in sync with the data.\n *\n * @param config\n * @param action\n */\nexport const withEntitlementsPlist: ConfigPlugin<Mod<JSONObject>> = (config, action) => {\n return withMod<JSONObject>(config, {\n platform: 'ios',\n mod: 'entitlements',\n async action(config) {\n config = await action(config);\n if (!config.ios) {\n config.ios = {};\n }\n config.ios.entitlements = config.modResults;\n return config;\n },\n });\n};\n\n/**\n * Provides the Expo.plist for modification.\n *\n * @param config\n * @param action\n */\nexport const withExpoPlist: ConfigPlugin<Mod<ExpoPlist>> = (config, action) => {\n return withMod(config, {\n platform: 'ios',\n mod: 'expoPlist',\n action,\n });\n};\n\n/**\n * Provides the main .xcodeproj for modification.\n *\n * @param config\n * @param action\n */\nexport const withXcodeProject: ConfigPlugin<Mod<XcodeProject>> = (config, action) => {\n return withMod(config, {\n platform: 'ios',\n mod: 'xcodeproj',\n action,\n });\n};\n\n/**\n * Provides the Podfile.properties.json for modification.\n *\n * @param config\n * @param action\n */\nexport const withPodfileProperties: ConfigPlugin<Mod<Record<string, string>>> = (\n config,\n action\n) => {\n return withMod(config, {\n platform: 'ios',\n mod: 'podfileProperties',\n action,\n });\n};\n"],"mappings":";;;;;;;;;AAOA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,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,SAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAOA;AACA;AACA;AACA;AACA;AACO,SAASI,qBAAqBA,CAACC,MAA6B,EAAEC,IAAa,EAAgB;EAChG,MAAMC,WAAyB,GAAIC,MAAM,IACvCC,aAAa,CAACD,MAAM,EAAE,MAAOA,MAAM,IAAK;IACtCA,MAAM,CAACE,UAAU,GAAG,MAAML,MAAM,CAACG,MAAM,EAAEA,MAAM,CA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