@expo/config-plugins 4.0.9 → 4.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/build/android/IntentFilters.d.ts +3 -3
  2. package/build/android/IntentFilters.js +44 -48
  3. package/build/android/IntentFilters.js.map +1 -1
  4. package/build/android/Manifest.d.ts +7 -1
  5. package/build/android/Manifest.js.map +1 -1
  6. package/build/android/Permissions.d.ts +2 -0
  7. package/build/android/Permissions.js +88 -3
  8. package/build/android/Permissions.js.map +1 -1
  9. package/build/android/Updates.d.ts +2 -2
  10. package/build/android/Updates.js +20 -4
  11. package/build/android/Updates.js.map +1 -1
  12. package/build/android/Version.d.ts +9 -0
  13. package/build/android/Version.js +37 -1
  14. package/build/android/Version.js.map +1 -1
  15. package/build/index.d.ts +1 -1
  16. package/build/index.js +7 -0
  17. package/build/index.js.map +1 -1
  18. package/build/ios/BundleIdentifier.js +11 -1
  19. package/build/ios/BundleIdentifier.js.map +1 -1
  20. package/build/ios/JsEngine.d.ts +2 -1
  21. package/build/ios/JsEngine.js.map +1 -1
  22. package/build/ios/Maps.js +22 -24
  23. package/build/ios/Maps.js.map +1 -1
  24. package/build/ios/ProvisioningProfile.js +11 -2
  25. package/build/ios/ProvisioningProfile.js.map +1 -1
  26. package/build/ios/Target.js +29 -10
  27. package/build/ios/Target.js.map +1 -1
  28. package/build/ios/Updates.d.ts +2 -2
  29. package/build/ios/Updates.js +20 -4
  30. package/build/ios/Updates.js.map +1 -1
  31. package/build/ios/utils/string.d.ts +1 -0
  32. package/build/ios/utils/string.js +11 -0
  33. package/build/ios/utils/string.js.map +1 -0
  34. package/build/plugins/ios-plugins.d.ts +2 -2
  35. package/build/plugins/ios-plugins.js.map +1 -1
  36. package/build/plugins/withIosBaseMods.d.ts +3 -3
  37. package/build/plugins/withIosBaseMods.js.map +1 -1
  38. package/build/utils/Updates.d.ts +1 -0
  39. package/build/utils/Updates.js +34 -0
  40. package/build/utils/Updates.js.map +1 -1
  41. package/package.json +2 -1
  42. package/build/utils/resolvePackageRootFolder.d.ts +0 -1
  43. package/build/utils/resolvePackageRootFolder.js +0 -57
  44. package/build/utils/resolvePackageRootFolder.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/android/Updates.ts"],"names":["CREATE_MANIFEST_ANDROID_PATH","Config","withUpdates","config","expoUsername","modResults","setUpdatesConfig","getSDKVersion","sdkVersion","getUpdatesEnabled","updates","enabled","getUpdatesTimeout","fallbackToCacheTimeout","getUpdatesCheckOnLaunch","checkAutomatically","androidManifest","username","mainApplication","ENABLED","String","CHECK_ON_LAUNCH","LAUNCH_WAIT_MS","updateUrl","UPDATE_URL","setVersionsConfig","runtimeVersion","SDK_VERSION","RUNTIME_VERSION","ensureBuildGradleContainsConfigurationScript","projectRoot","buildGradleContents","isBuildGradleConfigured","cleanedUpBuildGradleContents","isBuildGradleMisconfigured","split","some","line","includes","replace","RegExp","gradleScriptApply","formatApplyLineForBuildGradle","updatesGradleScriptPath","resolveFrom","silent","Error","relativePath","path","relative","join","posixPath","process","platform","androidBuildScript","isMainApplicationMetaDataSet","Boolean","isMainApplicationMetaDataSynced","areVersionsSynced","expectedRuntimeVersion","expectedSdkVersion","currentRuntimeVersion","currentSdkVersion"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAQA,MAAMA,4BAA4B,GAAG,qDAArC;IAEYC,M;;;WAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;AAAAA,EAAAA,M;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C,SAAlC,CAA/B;AACA,QAAMyD,kBAAkB,GAAGrD,aAAa,CAACJ,MAAD,CAAxC;AAEA,QAAM0D,qBAAqB,GAAG,iDAC5B7C,eAD4B,EAE5Bf,MAAM,CAAC2B,eAFqB,CAA9B;AAIA,QAAMkC,iBAAiB,GAAG,iDAAgC9C,eAAhC,EAAiDf,MAAM,CAAC0B,WAAxD,CAA1B;;AAEA,MAAIgC,sBAAsB,KAAK,IAA/B,EAAqC;AACnC,WAAOE,qBAAqB,KAAKF,sBAA1B,IAAoDG,iBAAiB,KAAK,IAAjF;AACD,GAFD,MAEO,IAAIF,kBAAkB,KAAK,IAA3B,EAAiC;AACtC,WAAOE,iBAAiB,KAAKF,kBAAtB,IAA4CC,qBAAqB,KAAK,IAA7E;AACD,GAFM,MAEA;AACL,WAAO,IAAP;AACD;AACF","sourcesContent":["import path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withAndroidManifest } from '../plugins/android-plugins';\nimport { ExpoConfigUpdates, getRuntimeVersionNullable, getUpdateUrl } from '../utils/Updates';\nimport {\n addMetaDataItemToMainApplication,\n AndroidManifest,\n getMainApplicationMetaDataValue,\n getMainApplicationOrThrow,\n removeMetaDataItemFromMainApplication,\n} from './Manifest';\n\nconst CREATE_MANIFEST_ANDROID_PATH = 'expo-updates/scripts/create-manifest-android.gradle';\n\nexport enum Config {\n ENABLED = 'expo.modules.updates.ENABLED',\n CHECK_ON_LAUNCH = 'expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH',\n LAUNCH_WAIT_MS = 'expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS',\n SDK_VERSION = 'expo.modules.updates.EXPO_SDK_VERSION',\n RUNTIME_VERSION = 'expo.modules.updates.EXPO_RUNTIME_VERSION',\n UPDATE_URL = 'expo.modules.updates.EXPO_UPDATE_URL',\n RELEASE_CHANNEL = 'expo.modules.updates.EXPO_RELEASE_CHANNEL',\n UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY = 'expo.modules.updates.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY',\n}\n\nexport const withUpdates: ConfigPlugin<{ expoUsername: string | null }> = (\n config,\n { expoUsername }\n) => {\n return withAndroidManifest(config, config => {\n config.modResults = setUpdatesConfig(config, config.modResults, expoUsername);\n return config;\n });\n};\n\nexport function getSDKVersion(config: Pick<ExpoConfigUpdates, 'sdkVersion'>): string | null {\n return typeof config.sdkVersion === 'string' ? config.sdkVersion : null;\n}\n\nexport function getUpdatesEnabled(config: Pick<ExpoConfigUpdates, 'updates'>): boolean {\n return config.updates?.enabled !== false;\n}\n\nexport function getUpdatesTimeout(config: Pick<ExpoConfigUpdates, 'updates'>): number {\n return config.updates?.fallbackToCacheTimeout ?? 0;\n}\n\nexport function getUpdatesCheckOnLaunch(\n config: Pick<ExpoConfigUpdates, 'updates'>\n): 'NEVER' | 'ALWAYS' {\n if (config.updates?.checkAutomatically === 'ON_ERROR_RECOVERY') {\n return 'NEVER';\n } else if (config.updates?.checkAutomatically === 'ON_LOAD') {\n return 'ALWAYS';\n }\n return 'ALWAYS';\n}\n\nexport function setUpdatesConfig(\n config: ExpoConfigUpdates,\n androidManifest: AndroidManifest,\n username: string | null\n): AndroidManifest {\n const mainApplication = getMainApplicationOrThrow(androidManifest);\n\n addMetaDataItemToMainApplication(\n mainApplication,\n Config.ENABLED,\n String(getUpdatesEnabled(config))\n );\n addMetaDataItemToMainApplication(\n mainApplication,\n Config.CHECK_ON_LAUNCH,\n getUpdatesCheckOnLaunch(config)\n );\n addMetaDataItemToMainApplication(\n mainApplication,\n Config.LAUNCH_WAIT_MS,\n String(getUpdatesTimeout(config))\n );\n\n const updateUrl = getUpdateUrl(config, username);\n if (updateUrl) {\n addMetaDataItemToMainApplication(mainApplication, Config.UPDATE_URL, updateUrl);\n } else {\n removeMetaDataItemFromMainApplication(mainApplication, Config.UPDATE_URL);\n }\n\n return setVersionsConfig(config, androidManifest);\n}\n\nexport function setVersionsConfig(\n config: Pick<ExpoConfigUpdates, 'sdkVersion' | 'runtimeVersion'>,\n androidManifest: AndroidManifest\n): AndroidManifest {\n const mainApplication = getMainApplicationOrThrow(androidManifest);\n\n const runtimeVersion = getRuntimeVersionNullable(config, 'android');\n const sdkVersion = getSDKVersion(config);\n if (runtimeVersion) {\n removeMetaDataItemFromMainApplication(mainApplication, Config.SDK_VERSION);\n addMetaDataItemToMainApplication(mainApplication, Config.RUNTIME_VERSION, runtimeVersion);\n } else if (sdkVersion) {\n /**\n * runtime version maybe null in projects using classic updates. In that\n * case we use SDK version\n */\n removeMetaDataItemFromMainApplication(mainApplication, Config.RUNTIME_VERSION);\n addMetaDataItemToMainApplication(mainApplication, Config.SDK_VERSION, sdkVersion);\n } else {\n removeMetaDataItemFromMainApplication(mainApplication, Config.RUNTIME_VERSION);\n removeMetaDataItemFromMainApplication(mainApplication, Config.SDK_VERSION);\n }\n\n return androidManifest;\n}\nexport function ensureBuildGradleContainsConfigurationScript(\n projectRoot: string,\n buildGradleContents: string\n): string {\n if (!isBuildGradleConfigured(projectRoot, buildGradleContents)) {\n let cleanedUpBuildGradleContents;\n\n const isBuildGradleMisconfigured = buildGradleContents\n .split('\\n')\n .some(line => line.includes(CREATE_MANIFEST_ANDROID_PATH));\n if (isBuildGradleMisconfigured) {\n cleanedUpBuildGradleContents = buildGradleContents.replace(\n new RegExp(`(\\n// Integration with Expo updates)?\\n.*${CREATE_MANIFEST_ANDROID_PATH}.*\\n`),\n ''\n );\n } else {\n cleanedUpBuildGradleContents = buildGradleContents;\n }\n\n const gradleScriptApply = formatApplyLineForBuildGradle(projectRoot);\n return `${cleanedUpBuildGradleContents}\\n// Integration with Expo updates\\n${gradleScriptApply}\\n`;\n } else {\n return buildGradleContents;\n }\n}\n\nexport function formatApplyLineForBuildGradle(projectRoot: string): string {\n const updatesGradleScriptPath = resolveFrom.silent(projectRoot, CREATE_MANIFEST_ANDROID_PATH);\n\n if (!updatesGradleScriptPath) {\n throw new Error(\n \"Could not find the build script for Android. This could happen in case of outdated 'node_modules'. Run 'npm install' to make sure that it's up-to-date.\"\n );\n }\n\n const relativePath = path.relative(\n path.join(projectRoot, 'android', 'app'),\n updatesGradleScriptPath\n );\n const posixPath = process.platform === 'win32' ? relativePath.replace(/\\\\/g, '/') : relativePath;\n\n return `apply from: \"${posixPath}\"`;\n}\n\nexport function isBuildGradleConfigured(projectRoot: string, buildGradleContents: string): boolean {\n const androidBuildScript = formatApplyLineForBuildGradle(projectRoot);\n\n return (\n buildGradleContents\n .replace(/\\r\\n/g, '\\n')\n .split('\\n')\n // Check for both single and double quotes\n .some(line => line === androidBuildScript || line === androidBuildScript.replace(/\"/g, \"'\"))\n );\n}\n\nexport function isMainApplicationMetaDataSet(androidManifest: AndroidManifest): boolean {\n const updateUrl = getMainApplicationMetaDataValue(androidManifest, Config.UPDATE_URL);\n const runtimeVersion = getMainApplicationMetaDataValue(androidManifest, Config.RUNTIME_VERSION);\n const sdkVersion = getMainApplicationMetaDataValue(androidManifest, Config.SDK_VERSION);\n\n return Boolean(updateUrl && (sdkVersion || runtimeVersion));\n}\n\nexport function isMainApplicationMetaDataSynced(\n config: ExpoConfigUpdates,\n androidManifest: AndroidManifest,\n username: string | null\n): boolean {\n return (\n getUpdateUrl(config, username) ===\n getMainApplicationMetaDataValue(androidManifest, Config.UPDATE_URL) &&\n String(getUpdatesEnabled(config)) ===\n getMainApplicationMetaDataValue(androidManifest, Config.ENABLED) &&\n String(getUpdatesTimeout(config)) ===\n getMainApplicationMetaDataValue(androidManifest, Config.LAUNCH_WAIT_MS) &&\n getUpdatesCheckOnLaunch(config) ===\n getMainApplicationMetaDataValue(androidManifest, Config.CHECK_ON_LAUNCH) &&\n areVersionsSynced(config, androidManifest)\n );\n}\n\nexport function areVersionsSynced(\n config: Pick<ExpoConfigUpdates, 'runtimeVersion' | 'sdkVersion'>,\n androidManifest: AndroidManifest\n): boolean {\n const expectedRuntimeVersion = getRuntimeVersionNullable(config, 'android');\n const expectedSdkVersion = getSDKVersion(config);\n\n const currentRuntimeVersion = getMainApplicationMetaDataValue(\n androidManifest,\n Config.RUNTIME_VERSION\n );\n const currentSdkVersion = getMainApplicationMetaDataValue(androidManifest, Config.SDK_VERSION);\n\n if (expectedRuntimeVersion !== null) {\n return currentRuntimeVersion === expectedRuntimeVersion && currentSdkVersion === null;\n } else if (expectedSdkVersion !== null) {\n return currentSdkVersion === expectedSdkVersion && currentRuntimeVersion === null;\n } else {\n return true;\n }\n}\n"],"file":"Updates.js"}
1
+ {"version":3,"sources":["../../src/android/Updates.ts"],"names":["CREATE_MANIFEST_ANDROID_PATH","Config","withUpdates","config","expoUsername","expoUpdatesPackageVersion","modRequest","projectRoot","modResults","setUpdatesConfig","getSDKVersion","sdkVersion","getUpdatesEnabled","updates","enabled","getUpdatesTimeout","fallbackToCacheTimeout","getUpdatesCheckOnLaunch","checkAutomatically","semver","gte","androidManifest","username","mainApplication","ENABLED","String","CHECK_ON_LAUNCH","LAUNCH_WAIT_MS","updateUrl","UPDATE_URL","setVersionsConfig","runtimeVersion","SDK_VERSION","RUNTIME_VERSION","ensureBuildGradleContainsConfigurationScript","buildGradleContents","isBuildGradleConfigured","cleanedUpBuildGradleContents","isBuildGradleMisconfigured","split","some","line","includes","replace","RegExp","gradleScriptApply","formatApplyLineForBuildGradle","updatesGradleScriptPath","resolveFrom","silent","Error","relativePath","path","relative","join","posixPath","process","platform","androidBuildScript","isMainApplicationMetaDataSet","Boolean","isMainApplicationMetaDataSynced","areVersionsSynced","expectedRuntimeVersion","expectedSdkVersion","currentRuntimeVersion","currentSdkVersion"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;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AArB,MACE,iDAAgCD,eAAhC,EAAiDpB,MAAM,CAAC4B,UAAxD,CADF,IAEAJ,MAAM,CAACb,iBAAiB,CAACT,MAAD,CAAlB,CAAN,KACE,iDAAgCkB,eAAhC,EAAiDpB,MAAM,CAACuB,OAAxD,CAHF,IAIAC,MAAM,CAACV,iBAAiB,CAACZ,MAAD,CAAlB,CAAN,KACE,iDAAgCkB,eAAhC,EAAiDpB,MAAM,CAAC0B,cAAxD,CALF,IAMAV,uBAAuB,CAACd,MAAD,CAAvB,KACE,iDAAgCkB,eAAhC,EAAiDpB,MAAM,CAACyB,eAAxD,CAPF,IAQAoC,iBAAiB,CAAC3D,MAAD,EAASkB,eAAT,CATnB;AAWD;;AAEM,SAASyC,iBAAT,CACL3D,MADK,EAELkB,eAFK,EAGI;AACT,QAAM0C,sBAAsB,GAAG,0CAA0B5D,MAA1B,EAAkC,SAAlC,CAA/B;AACA,QAAM6D,kBAAkB,GAAGtD,aAAa,CAACP,MAAD,CAAxC;AAEA,QAAM8D,qBAAqB,GAAG,iDAC5B5C,eAD4B,EAE5BpB,MAAM,CAACgC,eAFqB,CAA9B;AAIA,QAAMiC,iBAAiB,GAAG,iDAAgC7C,eAAhC,EAAiDpB,MAAM,CAAC+B,WAAxD,CAA1B;;AAEA,MAAI+B,sBAAsB,KAAK,IAA/B,EAAqC;AACnC,WAAOE,qBAAqB,KAAKF,sBAA1B,IAAoDG,iBAAiB,KAAK,IAAjF;AACD,GAFD,MAEO,IAAIF,kBAAkB,KAAK,IAA3B,EAAiC;AACtC,WAAOE,iBAAiB,KAAKF,kBAAtB,IAA4CC,qBAAqB,KAAK,IAA7E;AACD,GAFM,MAEA;AACL,WAAO,IAAP;AACD;AACF","sourcesContent":["import path from 'path';\nimport resolveFrom from 'resolve-from';\nimport semver from 'semver';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withAndroidManifest } from '../plugins/android-plugins';\nimport {\n ExpoConfigUpdates,\n getExpoUpdatesPackageVersion,\n getRuntimeVersionNullable,\n getUpdateUrl,\n} from '../utils/Updates';\nimport {\n addMetaDataItemToMainApplication,\n AndroidManifest,\n getMainApplicationMetaDataValue,\n getMainApplicationOrThrow,\n removeMetaDataItemFromMainApplication,\n} from './Manifest';\n\nconst CREATE_MANIFEST_ANDROID_PATH = 'expo-updates/scripts/create-manifest-android.gradle';\n\nexport enum Config {\n ENABLED = 'expo.modules.updates.ENABLED',\n CHECK_ON_LAUNCH = 'expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH',\n LAUNCH_WAIT_MS = 'expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS',\n SDK_VERSION = 'expo.modules.updates.EXPO_SDK_VERSION',\n RUNTIME_VERSION = 'expo.modules.updates.EXPO_RUNTIME_VERSION',\n UPDATE_URL = 'expo.modules.updates.EXPO_UPDATE_URL',\n RELEASE_CHANNEL = 'expo.modules.updates.EXPO_RELEASE_CHANNEL',\n UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY = 'expo.modules.updates.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY',\n}\n\nexport const withUpdates: ConfigPlugin<{ expoUsername: string | null }> = (\n config,\n { expoUsername }\n) => {\n return withAndroidManifest(config, config => {\n const expoUpdatesPackageVersion = getExpoUpdatesPackageVersion(config.modRequest.projectRoot);\n config.modResults = setUpdatesConfig(\n config,\n config.modResults,\n expoUsername,\n expoUpdatesPackageVersion\n );\n return config;\n });\n};\n\nexport function getSDKVersion(config: Pick<ExpoConfigUpdates, 'sdkVersion'>): string | null {\n return typeof config.sdkVersion === 'string' ? config.sdkVersion : null;\n}\n\nexport function getUpdatesEnabled(config: Pick<ExpoConfigUpdates, 'updates'>): boolean {\n return config.updates?.enabled !== false;\n}\n\nexport function getUpdatesTimeout(config: Pick<ExpoConfigUpdates, 'updates'>): number {\n return config.updates?.fallbackToCacheTimeout ?? 0;\n}\n\nexport function getUpdatesCheckOnLaunch(\n config: Pick<ExpoConfigUpdates, 'updates'>,\n expoUpdatesPackageVersion?: string | null\n): 'NEVER' | 'ERROR_RECOVERY_ONLY' | 'ALWAYS' {\n if (config.updates?.checkAutomatically === 'ON_ERROR_RECOVERY') {\n // native 'ERROR_RECOVERY_ONLY' option was only introduced in 0.11.x\n if (expoUpdatesPackageVersion && semver.gte(expoUpdatesPackageVersion, '0.11.0')) {\n return 'ERROR_RECOVERY_ONLY';\n }\n return 'NEVER';\n } else if (config.updates?.checkAutomatically === 'ON_LOAD') {\n return 'ALWAYS';\n }\n return 'ALWAYS';\n}\n\nexport function setUpdatesConfig(\n config: ExpoConfigUpdates,\n androidManifest: AndroidManifest,\n username: string | null,\n expoUpdatesPackageVersion?: string | null\n): AndroidManifest {\n const mainApplication = getMainApplicationOrThrow(androidManifest);\n\n addMetaDataItemToMainApplication(\n mainApplication,\n Config.ENABLED,\n String(getUpdatesEnabled(config))\n );\n addMetaDataItemToMainApplication(\n mainApplication,\n Config.CHECK_ON_LAUNCH,\n getUpdatesCheckOnLaunch(config, expoUpdatesPackageVersion)\n );\n addMetaDataItemToMainApplication(\n mainApplication,\n Config.LAUNCH_WAIT_MS,\n String(getUpdatesTimeout(config))\n );\n\n const updateUrl = getUpdateUrl(config, username);\n if (updateUrl) {\n addMetaDataItemToMainApplication(mainApplication, Config.UPDATE_URL, updateUrl);\n } else {\n removeMetaDataItemFromMainApplication(mainApplication, Config.UPDATE_URL);\n }\n\n return setVersionsConfig(config, androidManifest);\n}\n\nexport function setVersionsConfig(\n config: Pick<ExpoConfigUpdates, 'sdkVersion' | 'runtimeVersion'>,\n androidManifest: AndroidManifest\n): AndroidManifest {\n const mainApplication = getMainApplicationOrThrow(androidManifest);\n\n const runtimeVersion = getRuntimeVersionNullable(config, 'android');\n const sdkVersion = getSDKVersion(config);\n if (runtimeVersion) {\n removeMetaDataItemFromMainApplication(mainApplication, Config.SDK_VERSION);\n addMetaDataItemToMainApplication(mainApplication, Config.RUNTIME_VERSION, runtimeVersion);\n } else if (sdkVersion) {\n /**\n * runtime version maybe null in projects using classic updates. In that\n * case we use SDK version\n */\n removeMetaDataItemFromMainApplication(mainApplication, Config.RUNTIME_VERSION);\n addMetaDataItemToMainApplication(mainApplication, Config.SDK_VERSION, sdkVersion);\n } else {\n removeMetaDataItemFromMainApplication(mainApplication, Config.RUNTIME_VERSION);\n removeMetaDataItemFromMainApplication(mainApplication, Config.SDK_VERSION);\n }\n\n return androidManifest;\n}\nexport function ensureBuildGradleContainsConfigurationScript(\n projectRoot: string,\n buildGradleContents: string\n): string {\n if (!isBuildGradleConfigured(projectRoot, buildGradleContents)) {\n let cleanedUpBuildGradleContents;\n\n const isBuildGradleMisconfigured = buildGradleContents\n .split('\\n')\n .some(line => line.includes(CREATE_MANIFEST_ANDROID_PATH));\n if (isBuildGradleMisconfigured) {\n cleanedUpBuildGradleContents = buildGradleContents.replace(\n new RegExp(`(\\n// Integration with Expo updates)?\\n.*${CREATE_MANIFEST_ANDROID_PATH}.*\\n`),\n ''\n );\n } else {\n cleanedUpBuildGradleContents = buildGradleContents;\n }\n\n const gradleScriptApply = formatApplyLineForBuildGradle(projectRoot);\n return `${cleanedUpBuildGradleContents}\\n// Integration with Expo updates\\n${gradleScriptApply}\\n`;\n } else {\n return buildGradleContents;\n }\n}\n\nexport function formatApplyLineForBuildGradle(projectRoot: string): string {\n const updatesGradleScriptPath = resolveFrom.silent(projectRoot, CREATE_MANIFEST_ANDROID_PATH);\n\n if (!updatesGradleScriptPath) {\n throw new Error(\n \"Could not find the build script for Android. This could happen in case of outdated 'node_modules'. Run 'npm install' to make sure that it's up-to-date.\"\n );\n }\n\n const relativePath = path.relative(\n path.join(projectRoot, 'android', 'app'),\n updatesGradleScriptPath\n );\n const posixPath = process.platform === 'win32' ? relativePath.replace(/\\\\/g, '/') : relativePath;\n\n return `apply from: \"${posixPath}\"`;\n}\n\nexport function isBuildGradleConfigured(projectRoot: string, buildGradleContents: string): boolean {\n const androidBuildScript = formatApplyLineForBuildGradle(projectRoot);\n\n return (\n buildGradleContents\n .replace(/\\r\\n/g, '\\n')\n .split('\\n')\n // Check for both single and double quotes\n .some(line => line === androidBuildScript || line === androidBuildScript.replace(/\"/g, \"'\"))\n );\n}\n\nexport function isMainApplicationMetaDataSet(androidManifest: AndroidManifest): boolean {\n const updateUrl = getMainApplicationMetaDataValue(androidManifest, Config.UPDATE_URL);\n const runtimeVersion = getMainApplicationMetaDataValue(androidManifest, Config.RUNTIME_VERSION);\n const sdkVersion = getMainApplicationMetaDataValue(androidManifest, Config.SDK_VERSION);\n\n return Boolean(updateUrl && (sdkVersion || runtimeVersion));\n}\n\nexport function isMainApplicationMetaDataSynced(\n config: ExpoConfigUpdates,\n androidManifest: AndroidManifest,\n username: string | null\n): boolean {\n return (\n getUpdateUrl(config, username) ===\n getMainApplicationMetaDataValue(androidManifest, Config.UPDATE_URL) &&\n String(getUpdatesEnabled(config)) ===\n getMainApplicationMetaDataValue(androidManifest, Config.ENABLED) &&\n String(getUpdatesTimeout(config)) ===\n getMainApplicationMetaDataValue(androidManifest, Config.LAUNCH_WAIT_MS) &&\n getUpdatesCheckOnLaunch(config) ===\n getMainApplicationMetaDataValue(androidManifest, Config.CHECK_ON_LAUNCH) &&\n areVersionsSynced(config, androidManifest)\n );\n}\n\nexport function areVersionsSynced(\n config: Pick<ExpoConfigUpdates, 'runtimeVersion' | 'sdkVersion'>,\n androidManifest: AndroidManifest\n): boolean {\n const expectedRuntimeVersion = getRuntimeVersionNullable(config, 'android');\n const expectedSdkVersion = getSDKVersion(config);\n\n const currentRuntimeVersion = getMainApplicationMetaDataValue(\n androidManifest,\n Config.RUNTIME_VERSION\n );\n const currentSdkVersion = getMainApplicationMetaDataValue(androidManifest, Config.SDK_VERSION);\n\n if (expectedRuntimeVersion !== null) {\n return currentRuntimeVersion === expectedRuntimeVersion && currentSdkVersion === null;\n } else if (expectedSdkVersion !== null) {\n return currentSdkVersion === expectedSdkVersion && currentRuntimeVersion === null;\n } else {\n return true;\n }\n}\n"],"file":"Updates.js"}
@@ -1,6 +1,15 @@
1
1
  import { ExpoConfig } from '@expo/config-types';
2
2
  import { ConfigPlugin } from '../Plugin.types';
3
3
  export declare const withVersion: ConfigPlugin;
4
+ /** Sets a numeric version for a value in the project.gradle buildscript.ext object to be at least the provided props.minVersion, if the existing value is greater then no change will be made. */
5
+ export declare const withBuildScriptExtMinimumVersion: ConfigPlugin<{
6
+ name: string;
7
+ minVersion: number;
8
+ }>;
9
+ export declare function setMinBuildScriptExtVersion(buildGradle: string, { name, minVersion }: {
10
+ name: string;
11
+ minVersion: number;
12
+ }): string;
4
13
  export declare function getVersionName(config: Pick<ExpoConfig, 'version'>): string | null;
5
14
  export declare function setVersionName(config: Pick<ExpoConfig, 'version'>, buildGradle: string): string;
6
15
  export declare function getVersionCode(config: Pick<ExpoConfig, 'android'>): number;
@@ -5,9 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getVersionCode = getVersionCode;
7
7
  exports.getVersionName = getVersionName;
8
+ exports.setMinBuildScriptExtVersion = setMinBuildScriptExtVersion;
8
9
  exports.setVersionCode = setVersionCode;
9
10
  exports.setVersionName = setVersionName;
10
- exports.withVersion = void 0;
11
+ exports.withVersion = exports.withBuildScriptExtMinimumVersion = void 0;
11
12
 
12
13
  function _androidPlugins() {
13
14
  const data = require("../plugins/android-plugins");
@@ -41,9 +42,44 @@ const withVersion = config => {
41
42
  return config;
42
43
  });
43
44
  };
45
+ /** Sets a numeric version for a value in the project.gradle buildscript.ext object to be at least the provided props.minVersion, if the existing value is greater then no change will be made. */
46
+
44
47
 
45
48
  exports.withVersion = withVersion;
46
49
 
50
+ const withBuildScriptExtMinimumVersion = (config, props) => {
51
+ return (0, _androidPlugins().withProjectBuildGradle)(config, config => {
52
+ if (config.modResults.language === 'groovy') {
53
+ config.modResults.contents = setMinBuildScriptExtVersion(config.modResults.contents, props);
54
+ } else {
55
+ (0, _warnings().addWarningAndroid)('withBuildScriptExtVersion', `Cannot automatically configure project build.gradle if it's not groovy`);
56
+ }
57
+
58
+ return config;
59
+ });
60
+ };
61
+
62
+ exports.withBuildScriptExtMinimumVersion = withBuildScriptExtMinimumVersion;
63
+
64
+ function setMinBuildScriptExtVersion(buildGradle, {
65
+ name,
66
+ minVersion
67
+ }) {
68
+ var _buildGradle$match;
69
+
70
+ const regex = new RegExp(`(${name}\\s?=\\s?)(\\d+(?:\\.\\d+)?)`);
71
+ const currentVersion = (_buildGradle$match = buildGradle.match(regex)) === null || _buildGradle$match === void 0 ? void 0 : _buildGradle$match[2];
72
+
73
+ if (!currentVersion) {
74
+ (0, _warnings().addWarningAndroid)('withBuildScriptExtVersion', `Cannot set minimum buildscript.ext.${name} version because the property "${name}" cannot be found or does not have a numeric value.`); // TODO: Maybe just add the property...
75
+
76
+ return buildGradle;
77
+ }
78
+
79
+ const currentVersionNum = Number(currentVersion);
80
+ return buildGradle.replace(regex, `$1${Math.max(minVersion, currentVersionNum)}`);
81
+ }
82
+
47
83
  function getVersionName(config) {
48
84
  var _config$version;
49
85
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/android/Version.ts"],"names":["withVersion","config","modResults","language","contents","setVersionCode","setVersionName","getVersionName","version","buildGradle","versionName","pattern","RegExp","replace","getVersionCode","android","versionCode"],"mappings":";;;;;;;;;;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,WAAyB,GAAGC,MAAM,IAAI;AACjD,SAAO,0CAAmBA,MAAnB,EAA2BA,MAAM,IAAI;AAC1C,QAAIA,MAAM,CAACC,UAAP,CAAkBC,QAAlB,KAA+B,QAAnC,EAA6C;AAC3CF,MAAAA,MAAM,CAACC,UAAP,CAAkBE,QAAlB,GAA6BC,cAAc,CAACJ,MAAD,EAASA,MAAM,CAACC,UAAP,CAAkBE,QAA3B,CAA3C;AACAH,MAAAA,MAAM,CAACC,UAAP,CAAkBE,QAAlB,GAA6BE,cAAc,CAACL,MAAD,EAASA,MAAM,CAACC,UAAP,CAAkBE,QAA3B,CAA3C;AACD,KAHD,MAGO;AACL,yCACE,qBADF,EAEG,oEAFH;AAID;;AACD,WAAOH,MAAP;AACD,GAXM,CAAP;AAYD,CAbM;;;;AAeA,SAASM,cAAT,CAAwBN,MAAxB,EAA6D;AAAA;;AAClE,4BAAOA,MAAM,CAACO,OAAd,6DAAyB,IAAzB;AACD;;AAEM,SAASF,cAAT,CAAwBL,MAAxB,EAA6DQ,WAA7D,EAAkF;AACvF,QAAMC,WAAW,GAAGH,cAAc,CAACN,MAAD,CAAlC;;AACA,MAAIS,WAAW,KAAK,IAApB,EAA0B;AACxB,WAAOD,WAAP;AACD;;AAED,QAAME,OAAO,GAAG,IAAIC,MAAJ,CAAY,kBAAZ,CAAhB;AACA,SAAOH,WAAW,CAACI,OAAZ,CAAoBF,OAApB,EAA8B,gBAAeD,WAAY,GAAzD,CAAP;AACD;;AAEM,SAASI,cAAT,CAAwBb,MAAxB,EAA6D;AAAA;;AAClE,qDAAOA,MAAM,CAACc,OAAd,oDAAO,gBAAgBC,WAAvB,yEAAsC,CAAtC;AACD;;AAEM,SAASX,cAAT,CAAwBJ,MAAxB,EAA6DQ,WAA7D,EAAkF;AACvF,QAAMO,WAAW,GAAGF,cAAc,CAACb,MAAD,CAAlC;;AACA,MAAIe,WAAW,KAAK,IAApB,EAA0B;AACxB,WAAOP,WAAP;AACD;;AAED,QAAME,OAAO,GAAG,IAAIC,MAAJ,CAAY,eAAZ,CAAhB;AACA,SAAOH,WAAW,CAACI,OAAZ,CAAoBF,OAApB,EAA8B,eAAcK,WAAY,EAAxD,CAAP;AACD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withAppBuildGradle } from '../plugins/android-plugins';\nimport { addWarningAndroid } from '../utils/warnings';\n\nexport const withVersion: ConfigPlugin = config => {\n return withAppBuildGradle(config, config => {\n if (config.modResults.language === 'groovy') {\n config.modResults.contents = setVersionCode(config, config.modResults.contents);\n config.modResults.contents = setVersionName(config, config.modResults.contents);\n } else {\n addWarningAndroid(\n 'android.versionCode',\n `Cannot automatically configure app build.gradle if it's not groovy`\n );\n }\n return config;\n });\n};\n\nexport function getVersionName(config: Pick<ExpoConfig, 'version'>) {\n return config.version ?? null;\n}\n\nexport function setVersionName(config: Pick<ExpoConfig, 'version'>, buildGradle: string) {\n const versionName = getVersionName(config);\n if (versionName === null) {\n return buildGradle;\n }\n\n const pattern = new RegExp(`versionName \".*\"`);\n return buildGradle.replace(pattern, `versionName \"${versionName}\"`);\n}\n\nexport function getVersionCode(config: Pick<ExpoConfig, 'android'>) {\n return config.android?.versionCode ?? 1;\n}\n\nexport function setVersionCode(config: Pick<ExpoConfig, 'android'>, buildGradle: string) {\n const versionCode = getVersionCode(config);\n if (versionCode === null) {\n return buildGradle;\n }\n\n const pattern = new RegExp(`versionCode.*`);\n return buildGradle.replace(pattern, `versionCode ${versionCode}`);\n}\n"],"file":"Version.js"}
1
+ {"version":3,"sources":["../../src/android/Version.ts"],"names":["withVersion","config","modResults","language","contents","setVersionCode","setVersionName","withBuildScriptExtMinimumVersion","props","setMinBuildScriptExtVersion","buildGradle","name","minVersion","regex","RegExp","currentVersion","match","currentVersionNum","Number","replace","Math","max","getVersionName","version","versionName","pattern","getVersionCode","android","versionCode"],"mappings":";;;;;;;;;;;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,WAAyB,GAAGC,MAAM,IAAI;AACjD,SAAO,0CAAmBA,MAAnB,EAA2BA,MAAM,IAAI;AAC1C,QAAIA,MAAM,CAACC,UAAP,CAAkBC,QAAlB,KAA+B,QAAnC,EAA6C;AAC3CF,MAAAA,MAAM,CAACC,UAAP,CAAkBE,QAAlB,GAA6BC,cAAc,CAACJ,MAAD,EAASA,MAAM,CAACC,UAAP,CAAkBE,QAA3B,CAA3C;AACAH,MAAAA,MAAM,CAACC,U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B,EAA6D;AAAA;;AAClE,4BAAOA,MAAM,CAACsB,OAAd,6DAAyB,IAAzB;AACD;;AAEM,SAASjB,cAAT,CAAwBL,MAAxB,EAA6DS,WAA7D,EAAkF;AACvF,QAAMc,WAAW,GAAGF,cAAc,CAACrB,MAAD,CAAlC;;AACA,MAAIuB,WAAW,KAAK,IAApB,EAA0B;AACxB,WAAOd,WAAP;AACD;;AAED,QAAMe,OAAO,GAAG,IAAIX,MAAJ,CAAY,kBAAZ,CAAhB;AACA,SAAOJ,WAAW,CAACS,OAAZ,CAAoBM,OAApB,EAA8B,gBAAeD,WAAY,GAAzD,CAAP;AACD;;AAEM,SAASE,cAAT,CAAwBzB,MAAxB,EAA6D;AAAA;;AAClE,qDAAOA,MAAM,CAAC0B,OAAd,oDAAO,gBAAgBC,WAAvB,yEAAsC,CAAtC;AACD;;AAEM,SAASvB,cAAT,CAAwBJ,MAAxB,EAA6DS,WAA7D,EAAkF;AACvF,QAAMkB,WAAW,GAAGF,cAAc,CAACzB,MAAD,CAAlC;;AACA,MAAI2B,WAAW,KAAK,IAApB,EAA0B;AACxB,WAAOlB,WAAP;AACD;;AAED,QAAMe,OAAO,GAAG,IAAIX,MAAJ,CAAY,eAAZ,CAAhB;AACA,SAAOJ,WAAW,CAACS,OAAZ,CAAoBM,OAApB,EAA8B,eAAcG,WAAY,EAAxD,CAAP;AACD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withAppBuildGradle, withProjectBuildGradle } from '../plugins/android-plugins';\nimport { addWarningAndroid } from '../utils/warnings';\n\nexport const withVersion: ConfigPlugin = config => {\n return withAppBuildGradle(config, config => {\n if (config.modResults.language === 'groovy') {\n config.modResults.contents = setVersionCode(config, config.modResults.contents);\n config.modResults.contents = setVersionName(config, config.modResults.contents);\n } else {\n addWarningAndroid(\n 'android.versionCode',\n `Cannot automatically configure app build.gradle if it's not groovy`\n );\n }\n return config;\n });\n};\n\n/** Sets a numeric version for a value in the project.gradle buildscript.ext object to be at least the provided props.minVersion, if the existing value is greater then no change will be made. */\nexport const withBuildScriptExtMinimumVersion: ConfigPlugin<{\n name: string;\n minVersion: number;\n}> = (config, props) => {\n return withProjectBuildGradle(config, config => {\n if (config.modResults.language === 'groovy') {\n config.modResults.contents = setMinBuildScriptExtVersion(config.modResults.contents, props);\n } else {\n addWarningAndroid(\n 'withBuildScriptExtVersion',\n `Cannot automatically configure project build.gradle if it's not groovy`\n );\n }\n return config;\n });\n};\n\nexport function setMinBuildScriptExtVersion(\n buildGradle: string,\n { name, minVersion }: { name: string; minVersion: number }\n) {\n const regex = new RegExp(`(${name}\\\\s?=\\\\s?)(\\\\d+(?:\\\\.\\\\d+)?)`);\n const currentVersion = buildGradle.match(regex)?.[2];\n if (!currentVersion) {\n addWarningAndroid(\n 'withBuildScriptExtVersion',\n `Cannot set minimum buildscript.ext.${name} version because the property \"${name}\" cannot be found or does not have a numeric value.`\n );\n // TODO: Maybe just add the property...\n return buildGradle;\n }\n\n const currentVersionNum = Number(currentVersion);\n return buildGradle.replace(regex, `$1${Math.max(minVersion, currentVersionNum)}`);\n}\n\nexport function getVersionName(config: Pick<ExpoConfig, 'version'>) {\n return config.version ?? null;\n}\n\nexport function setVersionName(config: Pick<ExpoConfig, 'version'>, buildGradle: string) {\n const versionName = getVersionName(config);\n if (versionName === null) {\n return buildGradle;\n }\n\n const pattern = new RegExp(`versionName \".*\"`);\n return buildGradle.replace(pattern, `versionName \"${versionName}\"`);\n}\n\nexport function getVersionCode(config: Pick<ExpoConfig, 'android'>) {\n return config.android?.versionCode ?? 1;\n}\n\nexport function setVersionCode(config: Pick<ExpoConfig, 'android'>, buildGradle: string) {\n const versionCode = getVersionCode(config);\n if (versionCode === null) {\n return buildGradle;\n }\n\n const pattern = new RegExp(`versionCode.*`);\n return buildGradle.replace(pattern, `versionCode ${versionCode}`);\n}\n"],"file":"Version.js"}
package/build/index.d.ts CHANGED
@@ -20,7 +20,7 @@ export { withPlugins } from './plugins/withPlugins';
20
20
  export { withRunOnce, createRunOncePlugin } from './plugins/withRunOnce';
21
21
  export { withDangerousMod } from './plugins/withDangerousMod';
22
22
  export { withMod, withBaseMod } from './plugins/withMod';
23
- export { withAppDelegate, withInfoPlist, withEntitlementsPlist, withExpoPlist, withXcodeProject, } from './plugins/ios-plugins';
23
+ export { withAppDelegate, withInfoPlist, withEntitlementsPlist, withExpoPlist, withXcodeProject, withPodfileProperties, } from './plugins/ios-plugins';
24
24
  export { withAndroidManifest, withStringsXml, withAndroidColors, withAndroidColorsNight, withAndroidStyles, withMainActivity, withMainApplication, withProjectBuildGradle, withAppBuildGradle, withSettingsGradle, withGradleProperties, } from './plugins/android-plugins';
25
25
  export { withStaticPlugin } from './plugins/withStaticPlugin';
26
26
  export { compileModsAsync, withDefaultBaseMods, evalModsAsync } from './plugins/mod-compiler';
package/build/index.js CHANGED
@@ -22,6 +22,7 @@ var _exportNames = {
22
22
  withEntitlementsPlist: true,
23
23
  withExpoPlist: true,
24
24
  withXcodeProject: true,
25
+ withPodfileProperties: true,
25
26
  withAndroidManifest: true,
26
27
  withStringsXml: true,
27
28
  withAndroidColors: true,
@@ -167,6 +168,12 @@ Object.defineProperty(exports, "withPlugins", {
167
168
  return _withPlugins().withPlugins;
168
169
  }
169
170
  });
171
+ Object.defineProperty(exports, "withPodfileProperties", {
172
+ enumerable: true,
173
+ get: function () {
174
+ return _iosPlugins().withPodfileProperties;
175
+ }
176
+ });
170
177
  Object.defineProperty(exports, "withProjectBuildGradle", {
171
178
  enumerable: true,
172
179
  get: function () {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["BaseMods","withGeneratedBaseMods","provider","withAndroidBaseMods","getAndroidModFileProviders","withIosBaseMods","getIosModFileProviders"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,EAA1BA,iDAJsB;AAKtBC,EAAAA,eAAe,EAAfA,kCALsB;AAMtBC,EAAAA,sBAAsB,EAAtBA;AANsB,CAAjB","sourcesContent":["/**\n * For internal use in Expo CLI\n */\nimport * as AndroidConfig from './android';\nimport * as IOSConfig from './ios';\nimport { provider, withGeneratedBaseMods } from './plugins/createBaseMod';\nimport { getAndroidModFileProviders, withAndroidBaseMods } from './plugins/withAndroidBaseMods';\nimport { getIosModFileProviders, withIosBaseMods } from './plugins/withIosBaseMods';\nimport * as XML from './utils/XML';\nimport * as History from './utils/history';\nimport * as WarningAggregator from './utils/warnings';\n\n// TODO: Remove\nexport * as Updates from './utils/Updates';\n\nexport { IOSConfig, AndroidConfig };\n\nexport { WarningAggregator, History, XML };\n\n/**\n * These are the \"config-plugins\"\n */\n\nexport * from './Plugin.types';\n\nexport { withPlugins } from './plugins/withPlugins';\n\nexport { withRunOnce, createRunOncePlugin } from './plugins/withRunOnce';\n\nexport { withDangerousMod } from './plugins/withDangerousMod';\nexport { withMod, withBaseMod } from './plugins/withMod';\n\nexport {\n withAppDelegate,\n withInfoPlist,\n withEntitlementsPlist,\n withExpoPlist,\n withXcodeProject,\n} from './plugins/ios-plugins';\n\nexport {\n withAndroidManifest,\n withStringsXml,\n withAndroidColors,\n withAndroidColorsNight,\n withAndroidStyles,\n withMainActivity,\n withMainApplication,\n withProjectBuildGradle,\n withAppBuildGradle,\n withSettingsGradle,\n withGradleProperties,\n} from './plugins/android-plugins';\n\nexport { withStaticPlugin } from './plugins/withStaticPlugin';\n\nexport { compileModsAsync, withDefaultBaseMods, evalModsAsync } from './plugins/mod-compiler';\n\nexport { PluginError } from './utils/errors';\n\nexport const BaseMods = {\n withGeneratedBaseMods,\n provider,\n withAndroidBaseMods,\n getAndroidModFileProviders,\n withIosBaseMods,\n getIosModFileProviders,\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["BaseMods","withGeneratedBaseMods","provider","withAndroidBaseMods","getAndroidModFile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A;AACA;AAwCO,MAAMA,QAAQ,GAAG;AACtBC,EAAAA,qBAAqB,EAArBA,sCADsB;AAEtBC,EAAAA,QAAQ,EAARA,yBAFsB;AAGtBC,EAAAA,mBAAmB,EAAnBA,0CAHsB;AAItBC,EAAAA,0BAA0B,EAA1BA,iDAJsB;AAKtBC,EAAAA,eAAe,EAAfA,kCALsB;AAMtBC,EAAAA,sBAAsB,EAAtBA;AANsB,CAAjB","sourcesContent":["/**\n * For internal use in Expo CLI\n */\nimport * as AndroidConfig from './android';\nimport * as IOSConfig from './ios';\nimport { provider, withGeneratedBaseMods } from './plugins/createBaseMod';\nimport { getAndroidModFileProviders, withAndroidBaseMods } from './plugins/withAndroidBaseMods';\nimport { getIosModFileProviders, withIosBaseMods } from './plugins/withIosBaseMods';\nimport * as XML from './utils/XML';\nimport * as History from './utils/history';\nimport * as WarningAggregator from './utils/warnings';\n\n// TODO: Remove\nexport * as Updates from './utils/Updates';\n\nexport { IOSConfig, AndroidConfig };\n\nexport { WarningAggregator, History, XML };\n\n/**\n * These are the \"config-plugins\"\n */\n\nexport * from './Plugin.types';\n\nexport { withPlugins } from './plugins/withPlugins';\n\nexport { withRunOnce, createRunOncePlugin } from './plugins/withRunOnce';\n\nexport { withDangerousMod } from './plugins/withDangerousMod';\nexport { withMod, withBaseMod } from './plugins/withMod';\n\nexport {\n withAppDelegate,\n withInfoPlist,\n withEntitlementsPlist,\n withExpoPlist,\n withXcodeProject,\n withPodfileProperties,\n} from './plugins/ios-plugins';\n\nexport {\n withAndroidManifest,\n withStringsXml,\n withAndroidColors,\n withAndroidColorsNight,\n withAndroidStyles,\n withMainActivity,\n withMainApplication,\n withProjectBuildGradle,\n withAppBuildGradle,\n withSettingsGradle,\n withGradleProperties,\n} from './plugins/android-plugins';\n\nexport { withStaticPlugin } from './plugins/withStaticPlugin';\n\nexport { compileModsAsync, withDefaultBaseMods, evalModsAsync } from './plugins/mod-compiler';\n\nexport { PluginError } from './utils/errors';\n\nexport const BaseMods = {\n withGeneratedBaseMods,\n provider,\n withAndroidBaseMods,\n getAndroidModFileProviders,\n withIosBaseMods,\n getIosModFileProviders,\n};\n"],"file":"index.js"}
@@ -92,6 +92,16 @@ function _Xcodeproj() {
92
92
  return data;
93
93
  }
94
94
 
95
+ function _string() {
96
+ const data = require("./utils/string");
97
+
98
+ _string = function () {
99
+ return data;
100
+ };
101
+
102
+ return data;
103
+ }
104
+
95
105
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
96
106
 
97
107
  const withBundleIdentifier = (config, {
@@ -179,7 +189,7 @@ function getProductBundleIdentifierFromBuildConfiguration(xcBuildConfiguration)
179
189
  const bundleIdentifierRaw = xcBuildConfiguration.buildSettings.PRODUCT_BUNDLE_IDENTIFIER;
180
190
 
181
191
  if (bundleIdentifierRaw) {
182
- const bundleIdentifier = bundleIdentifierRaw[0] === '"' ? bundleIdentifierRaw.slice(1, -1) : bundleIdentifierRaw; // it's possible to use interpolation for the bundle identifier
192
+ const bundleIdentifier = (0, _string().trimQuotes)(bundleIdentifierRaw); // it's possible to use interpolation for the bundle identifier
183
193
  // the most common case is when the last part of the id is set to `$(PRODUCT_NAME:rfc1034identifier)`
184
194
  // in this case, PRODUCT_NAME should be replaced with its value
185
195
  // the `rfc1034identifier` modifier replaces all non-alphanumeric characters with dashes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ios/BundleIdentifier.ts"],"names":["withBundleIdentifier","config","bundleIdentifier","bundleId","ios","setBundleIdentifierForPbxproj","modRequest","projectRoot","getBundleIdentifier","setBundleIdentifier","infoPlist","CFBundleIdentifier","getBundleIdentifierFromPbxproj","targetName","buildConfiguration","pbxprojPath","project","xcode","parseSync","xcBuildConfiguration","getProductBundleIdentifierFromBuildConfiguration","bundleIdentifierRaw","buildSettings","PRODUCT_BUNDLE_IDENTIFIER","slice","bundleIdentifierParts","split","length","PRODUCT_NAME","replace","join","updateBundleIdentifierForPbxproj","updateProductName","nativeTarget","buildConfigurationList","forEach","item","productName","pop","includes","fs","writeFileSync","writeSync","pbxprojPaths","defaultBundleId","resetAllPlistBundleIdentifiers","infoPlistPaths","plistPath","resetPlistBundleIdentifier","rawPlist","readFileSync","plistObject","plist","parse","format","pretty","indent","xml","build"],"mappings":";;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEO,MAAMA,oBAAiE,GAAG,CAC/EC,MAD+E,EAE/E;AAAEC,EAAAA;AAAF,CAF+E,KAG5E;AACH,SAAO,0CAAiBD,MAAjB,EAAyB,CAC9B,KAD8B,EAE9B,MAAMA,MAAN,IAAgB;AAAA;;AACd,UAAME,QAAQ,GAAGD,gBAAH,aAAGA,gBAAH,cAAGA,gBAAH,kBAAuBD,MAAM,CAACG,GAA9B,gDAAuB,YAAYF,gBAAjD;AACA,2BACEC,QADF,EAEE,oIAFF;AAIA,UAAME,6BAA6B,CAACJ,MAAM,CAACK,UAAP,CAAkBC,WAAnB,EAAgCJ,QAAhC,CAAnC;AACA,WAAOF,MAAP;AACD,GAV6B,CAAzB,CAAP;AAYD,CAhBM;;;;AAkBP,SAASO,mBAAT,CAA6BP,MAA7B,EAA6E;AAAA;;AAC3E,kDAAOA,MAAM,CAACG,GAAd,iDAAO,aAAYF,gBAAnB,yEAAuC,IAAvC;AACD;AAED;AACA;AACA;AACA;;;AACA,SAASO,mBAAT,CAA6BR,MAA7B,EAAiDS,SAAjD,EAAkF;AAChF,QAAMR,gBAAgB,GAAGM,mB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AAGC,aAAH,CAAiBM,SAAjB,EAA4BU,GAA5B;AACD;AACF;AACF","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport plist, { PlistObject } from '@expo/plist';\nimport assert from 'assert';\nimport fs from 'fs-extra';\nimport xcode, { XCBuildConfiguration } from 'xcode';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { InfoPlist } from './IosConfig.types';\nimport { getAllInfoPlistPaths, getAllPBXProjectPaths, getPBXProjectPath } from './Paths';\nimport { findFirstNativeTarget, getXCBuildConfigurationFromPbxproj } from './Target';\nimport { ConfigurationSectionEntry, getBuildConfigurationsForListId } from './utils/Xcodeproj';\n\nexport const withBundleIdentifier: ConfigPlugin<{ bundleIdentifier?: string }> = (\n config,\n { bundleIdentifier }\n) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const bundleId = bundleIdentifier ?? config.ios?.bundleIdentifier;\n assert(\n bundleId,\n '`bundleIdentifier` must be defined in the app config (`expo.ios.bundleIdentifier`) or passed to the plugin `withBundleIdentifier`.'\n );\n await setBundleIdentifierForPbxproj(config.modRequest.projectRoot, bundleId!);\n return config;\n },\n ]);\n};\n\nfunction getBundleIdentifier(config: Pick<ExpoConfig, 'ios'>): string | null {\n return config.ios?.bundleIdentifier ?? null;\n}\n\n/**\n * In Turtle v1 we set the bundleIdentifier directly on Info.plist rather\n * than in pbxproj\n */\nfunction setBundleIdentifier(config: ExpoConfig, infoPlist: InfoPlist): InfoPlist {\n const bundleIdentifier = getBundleIdentifier(config);\n\n if (!bundleIdentifier) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n CFBundleIdentifier: bundleIdentifier,\n };\n}\n\n/**\n * Gets the bundle identifier defined in the Xcode project found in the project directory.\n *\n * A bundle identifier is stored as a value in XCBuildConfiguration entry.\n * Those entries exist for every pair (build target, build configuration).\n * Unless target name is passed, the first target defined in the pbxproj is used\n * (to keep compatibility with the inaccurate legacy implementation of this function).\n * The build configuration is usually 'Release' or 'Debug'. However, it could be any arbitrary string.\n * Defaults to 'Release'.\n *\n * @param {string} projectRoot Path to project root containing the ios directory\n * @param {string} targetName Target name\n * @param {string} buildConfiguration Build configuration. Defaults to 'Release'.\n * @returns {string | null} bundle identifier of the Xcode project or null if the project is not configured\n */\nfunction getBundleIdentifierFromPbxproj(\n projectRoot: string,\n {\n targetName,\n buildConfiguration = 'Release',\n }: { targetName?: string; buildConfiguration?: string } = {}\n): string | null {\n let pbxprojPath: string;\n try {\n pbxprojPath = getPBXProjectPath(projectRoot);\n } catch {\n return null;\n }\n const project = xcode.project(pbxprojPath);\n project.parseSync();\n\n const xcBuildConfiguration = getXCBuildConfigurationFromPbxproj(project, {\n targetName,\n buildConfiguration,\n });\n if (!xcBuildConfiguration) {\n return null;\n }\n return getProductBundleIdentifierFromBuildConfiguration(xcBuildConfiguration);\n}\n\nfunction getProductBundleIdentifierFromBuildConfiguration(\n xcBuildConfiguration: XCBuildConfiguration\n): string | null {\n const bundleIdentifierRaw = xcBuildConfiguration.buildSettings.PRODUCT_BUNDLE_IDENTIFIER;\n if (bundleIdentifierRaw) {\n const bundleIdentifier =\n bundleIdentifierRaw[0] === '\"' ? bundleIdentifierRaw.slice(1, -1) : bundleIdentifierRaw;\n // it's possible to use interpolation for the bundle identifier\n // the most common case is when the last part of the id is set to `$(PRODUCT_NAME:rfc1034identifier)`\n // in this case, PRODUCT_NAME should be replaced with its value\n // the `rfc1034identifier` modifier replaces all non-alphanumeric characters with dashes\n const bundleIdentifierParts = bundleIdentifier.split('.');\n if (\n bundleIdentifierParts[bundleIdentifierParts.length - 1] ===\n '$(PRODUCT_NAME:rfc1034identifier)' &&\n xcBuildConfiguration.buildSettings.PRODUCT_NAME\n ) {\n bundleIdentifierParts[\n bundleIdentifierParts.length - 1\n ] = xcBuildConfiguration.buildSettings.PRODUCT_NAME.replace(/[^a-zA-Z0-9]/g, '-');\n }\n return bundleIdentifierParts.join('.');\n } else {\n return null;\n }\n}\n\n/**\n * Updates the bundle identifier for a given pbxproj\n *\n * @param {string} pbxprojPath Path to pbxproj file\n * @param {string} bundleIdentifier Bundle identifier to set in the pbxproj\n * @param {boolean} [updateProductName=true] Whether to update PRODUCT_NAME\n */\nfunction updateBundleIdentifierForPbxproj(\n pbxprojPath: string,\n bundleIdentifier: string,\n updateProductName: boolean = true\n): void {\n const project = xcode.project(pbxprojPath);\n project.parseSync();\n\n const [, nativeTarget] = findFirstNativeTarget(project);\n\n getBuildConfigurationsForListId(project, nativeTarget.buildConfigurationList).forEach(\n ([, item]: ConfigurationSectionEntry) => {\n if (item.buildSettings.PRODUCT_BUNDLE_IDENTIFIER === bundleIdentifier) {\n return;\n }\n\n item.buildSettings.PRODUCT_BUNDLE_IDENTIFIER = `\"${bundleIdentifier}\"`;\n\n if (updateProductName) {\n const productName = bundleIdentifier.split('.').pop();\n if (!productName?.includes('$')) {\n item.buildSettings.PRODUCT_NAME = productName;\n }\n }\n }\n );\n fs.writeFileSync(pbxprojPath, project.writeSync());\n}\n\n/**\n * Updates the bundle identifier for pbx projects inside the ios directory of the given project root\n *\n * @param {string} projectRoot Path to project root containing the ios directory\n * @param {string} bundleIdentifier Desired bundle identifier\n * @param {boolean} [updateProductName=true] Whether to update PRODUCT_NAME\n */\nfunction setBundleIdentifierForPbxproj(\n projectRoot: string,\n bundleIdentifier: string,\n updateProductName: boolean = true\n): void {\n // Get all pbx projects in the ${projectRoot}/ios directory\n let pbxprojPaths: string[] = [];\n try {\n pbxprojPaths = getAllPBXProjectPaths(projectRoot);\n } catch {}\n\n for (const pbxprojPath of pbxprojPaths) {\n updateBundleIdentifierForPbxproj(pbxprojPath, bundleIdentifier, updateProductName);\n }\n}\n\n/**\n * Reset bundle identifier field in Info.plist to use PRODUCT_BUNDLE_IDENTIFIER, as recommended by Apple.\n */\n\nconst defaultBundleId = '$(PRODUCT_BUNDLE_IDENTIFIER)';\n\nfunction resetAllPlistBundleIdentifiers(projectRoot: string): void {\n const infoPlistPaths = getAllInfoPlistPaths(projectRoot);\n\n for (const plistPath of infoPlistPaths) {\n resetPlistBundleIdentifier(plistPath);\n }\n}\n\nfunction resetPlistBundleIdentifier(plistPath: string): void {\n const rawPlist = fs.readFileSync(plistPath, 'utf8');\n const plistObject = plist.parse(rawPlist) as PlistObject;\n\n if (plistObject.CFBundleIdentifier) {\n if (plistObject.CFBundleIdentifier === defaultBundleId) return;\n\n // attempt to match default Info.plist format\n const format = { pretty: true, indent: `\\t` };\n\n const xml = plist.build(\n {\n ...plistObject,\n CFBundleIdentifier: defaultBundleId,\n },\n format\n );\n\n if (xml !== rawPlist) {\n fs.writeFileSync(plistPath, xml);\n }\n }\n}\n\nexport {\n getBundleIdentifier,\n setBundleIdentifier,\n getBundleIdentifierFromPbxproj,\n updateBundleIdentifierForPbxproj,\n setBundleIdentifierForPbxproj,\n resetAllPlistBundleIdentifiers,\n resetPlistBundleIdentifier,\n};\n"],"file":"BundleIdentifier.js"}
1
+ {"version":3,"sources":["../../src/ios/BundleIdentifier.ts"],"names":["withBundleIdentifier","config","bundleIdentifier","bundleId","ios","setBundleIdentifierForPbxproj","modRequest","projectRoot","getBundleIdentifier","setBundleIdentifier","infoPlist","CFBundleIdentifier","getBundleIdentifierFromPbxproj","targetName","buildConfiguration","pbxprojPath","project","xcode","parseSync","xcBuildConfiguration","getProductBundleIdentifierFromBuildConfiguration","bundleIdentifierRaw","buildSettings","PRODUCT_BUNDLE_IDENTIFIER","bundleIdentifierParts","split","length","PRODUCT_NAME","replace","join","updateBundleIdentifierForPbxproj","updateProductName","nativeTarget","buildConfigurationList","forEach","item","productName","pop","includes","fs","writeFileSync","writeSync","pbxprojPaths","defaultBundleId","resetAllPlistBundleIdentifiers","infoPlistPaths","plistPath","resetPlistBundleIdentifier","rawPlist","readFileSync","plistObject","plist","parse","format","pretty","indent","xml","build"],"mappings":";;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;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AwC;AACtCZ,IAAAA,gCAAgC,CAACf,WAAD,EAAcb,gBAAd,EAAgC6B,iBAAhC,CAAhC;AACD;AACF;AAED;AACA;AACA;;;AAEA,MAAMY,eAAe,GAAG,8BAAxB;;AAEA,SAASC,8BAAT,CAAwCrC,WAAxC,EAAmE;AACjE,QAAMsC,cAAc,GAAG,mCAAqBtC,WAArB,CAAvB;;AAEA,OAAK,MAAMuC,SAAX,IAAwBD,cAAxB,EAAwC;AACtCE,IAAAA,0BAA0B,CAACD,SAAD,CAA1B;AACD;AACF;;AAED,SAASC,0BAAT,CAAoCD,SAApC,EAA6D;AAC3D,QAAME,QAAQ,GAAGT,mBAAGU,YAAH,CAAgBH,SAAhB,EAA2B,MAA3B,CAAjB;;AACA,QAAMI,WAAW,GAAGC,iBAAMC,KAAN,CAAYJ,QAAZ,CAApB;;AAEA,MAAIE,WAAW,CAACvC,kBAAhB,EAAoC;AAClC,QAAIuC,WAAW,CAACvC,kBAAZ,KAAmCgC,eAAvC,EAAwD,OADtB,CAGlC;;AACA,UAAMU,MAAM,GAAG;AAAEC,MAAAA,MAAM,EAAE,IAAV;AAAgBC,MAAAA,MAAM,EAAG;AAAzB,KAAf;;AAEA,UAAMC,GAAG,GAAGL,iBAAMM,KAAN,CACV,EACE,GAAGP,WADL;AAEEvC,MAAAA,kBAAkB,EAAEgC;AAFtB,KADU,EAKVU,MALU,CAAZ;;AAQA,QAAIG,GAAG,KAAKR,QAAZ,EAAsB;AACpBT,yBAAGC,aAAH,CAAiBM,SAAjB,EAA4BU,GAA5B;AACD;AACF;AACF","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport plist, { PlistObject } from '@expo/plist';\nimport assert from 'assert';\nimport fs from 'fs-extra';\nimport xcode, { XCBuildConfiguration } from 'xcode';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { InfoPlist } from './IosConfig.types';\nimport { getAllInfoPlistPaths, getAllPBXProjectPaths, getPBXProjectPath } from './Paths';\nimport { findFirstNativeTarget, getXCBuildConfigurationFromPbxproj } from './Target';\nimport { ConfigurationSectionEntry, getBuildConfigurationsForListId } from './utils/Xcodeproj';\nimport { trimQuotes } from './utils/string';\n\nexport const withBundleIdentifier: ConfigPlugin<{ bundleIdentifier?: string }> = (\n config,\n { bundleIdentifier }\n) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const bundleId = bundleIdentifier ?? config.ios?.bundleIdentifier;\n assert(\n bundleId,\n '`bundleIdentifier` must be defined in the app config (`expo.ios.bundleIdentifier`) or passed to the plugin `withBundleIdentifier`.'\n );\n await setBundleIdentifierForPbxproj(config.modRequest.projectRoot, bundleId!);\n return config;\n },\n ]);\n};\n\nfunction getBundleIdentifier(config: Pick<ExpoConfig, 'ios'>): string | null {\n return config.ios?.bundleIdentifier ?? null;\n}\n\n/**\n * In Turtle v1 we set the bundleIdentifier directly on Info.plist rather\n * than in pbxproj\n */\nfunction setBundleIdentifier(config: ExpoConfig, infoPlist: InfoPlist): InfoPlist {\n const bundleIdentifier = getBundleIdentifier(config);\n\n if (!bundleIdentifier) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n CFBundleIdentifier: bundleIdentifier,\n };\n}\n\n/**\n * Gets the bundle identifier defined in the Xcode project found in the project directory.\n *\n * A bundle identifier is stored as a value in XCBuildConfiguration entry.\n * Those entries exist for every pair (build target, build configuration).\n * Unless target name is passed, the first target defined in the pbxproj is used\n * (to keep compatibility with the inaccurate legacy implementation of this function).\n * The build configuration is usually 'Release' or 'Debug'. However, it could be any arbitrary string.\n * Defaults to 'Release'.\n *\n * @param {string} projectRoot Path to project root containing the ios directory\n * @param {string} targetName Target name\n * @param {string} buildConfiguration Build configuration. Defaults to 'Release'.\n * @returns {string | null} bundle identifier of the Xcode project or null if the project is not configured\n */\nfunction getBundleIdentifierFromPbxproj(\n projectRoot: string,\n {\n targetName,\n buildConfiguration = 'Release',\n }: { targetName?: string; buildConfiguration?: string } = {}\n): string | null {\n let pbxprojPath: string;\n try {\n pbxprojPath = getPBXProjectPath(projectRoot);\n } catch {\n return null;\n }\n const project = xcode.project(pbxprojPath);\n project.parseSync();\n\n const xcBuildConfiguration = getXCBuildConfigurationFromPbxproj(project, {\n targetName,\n buildConfiguration,\n });\n if (!xcBuildConfiguration) {\n return null;\n }\n return getProductBundleIdentifierFromBuildConfiguration(xcBuildConfiguration);\n}\n\nfunction getProductBundleIdentifierFromBuildConfiguration(\n xcBuildConfiguration: XCBuildConfiguration\n): string | null {\n const bundleIdentifierRaw = xcBuildConfiguration.buildSettings.PRODUCT_BUNDLE_IDENTIFIER;\n if (bundleIdentifierRaw) {\n const bundleIdentifier = trimQuotes(bundleIdentifierRaw);\n // it's possible to use interpolation for the bundle identifier\n // the most common case is when the last part of the id is set to `$(PRODUCT_NAME:rfc1034identifier)`\n // in this case, PRODUCT_NAME should be replaced with its value\n // the `rfc1034identifier` modifier replaces all non-alphanumeric characters with dashes\n const bundleIdentifierParts = bundleIdentifier.split('.');\n if (\n bundleIdentifierParts[bundleIdentifierParts.length - 1] ===\n '$(PRODUCT_NAME:rfc1034identifier)' &&\n xcBuildConfiguration.buildSettings.PRODUCT_NAME\n ) {\n bundleIdentifierParts[\n bundleIdentifierParts.length - 1\n ] = xcBuildConfiguration.buildSettings.PRODUCT_NAME.replace(/[^a-zA-Z0-9]/g, '-');\n }\n return bundleIdentifierParts.join('.');\n } else {\n return null;\n }\n}\n\n/**\n * Updates the bundle identifier for a given pbxproj\n *\n * @param {string} pbxprojPath Path to pbxproj file\n * @param {string} bundleIdentifier Bundle identifier to set in the pbxproj\n * @param {boolean} [updateProductName=true] Whether to update PRODUCT_NAME\n */\nfunction updateBundleIdentifierForPbxproj(\n pbxprojPath: string,\n bundleIdentifier: string,\n updateProductName: boolean = true\n): void {\n const project = xcode.project(pbxprojPath);\n project.parseSync();\n\n const [, nativeTarget] = findFirstNativeTarget(project);\n\n getBuildConfigurationsForListId(project, nativeTarget.buildConfigurationList).forEach(\n ([, item]: ConfigurationSectionEntry) => {\n if (item.buildSettings.PRODUCT_BUNDLE_IDENTIFIER === bundleIdentifier) {\n return;\n }\n\n item.buildSettings.PRODUCT_BUNDLE_IDENTIFIER = `\"${bundleIdentifier}\"`;\n\n if (updateProductName) {\n const productName = bundleIdentifier.split('.').pop();\n if (!productName?.includes('$')) {\n item.buildSettings.PRODUCT_NAME = productName;\n }\n }\n }\n );\n fs.writeFileSync(pbxprojPath, project.writeSync());\n}\n\n/**\n * Updates the bundle identifier for pbx projects inside the ios directory of the given project root\n *\n * @param {string} projectRoot Path to project root containing the ios directory\n * @param {string} bundleIdentifier Desired bundle identifier\n * @param {boolean} [updateProductName=true] Whether to update PRODUCT_NAME\n */\nfunction setBundleIdentifierForPbxproj(\n projectRoot: string,\n bundleIdentifier: string,\n updateProductName: boolean = true\n): void {\n // Get all pbx projects in the ${projectRoot}/ios directory\n let pbxprojPaths: string[] = [];\n try {\n pbxprojPaths = getAllPBXProjectPaths(projectRoot);\n } catch {}\n\n for (const pbxprojPath of pbxprojPaths) {\n updateBundleIdentifierForPbxproj(pbxprojPath, bundleIdentifier, updateProductName);\n }\n}\n\n/**\n * Reset bundle identifier field in Info.plist to use PRODUCT_BUNDLE_IDENTIFIER, as recommended by Apple.\n */\n\nconst defaultBundleId = '$(PRODUCT_BUNDLE_IDENTIFIER)';\n\nfunction resetAllPlistBundleIdentifiers(projectRoot: string): void {\n const infoPlistPaths = getAllInfoPlistPaths(projectRoot);\n\n for (const plistPath of infoPlistPaths) {\n resetPlistBundleIdentifier(plistPath);\n }\n}\n\nfunction resetPlistBundleIdentifier(plistPath: string): void {\n const rawPlist = fs.readFileSync(plistPath, 'utf8');\n const plistObject = plist.parse(rawPlist) as PlistObject;\n\n if (plistObject.CFBundleIdentifier) {\n if (plistObject.CFBundleIdentifier === defaultBundleId) return;\n\n // attempt to match default Info.plist format\n const format = { pretty: true, indent: `\\t` };\n\n const xml = plist.build(\n {\n ...plistObject,\n CFBundleIdentifier: defaultBundleId,\n },\n format\n );\n\n if (xml !== rawPlist) {\n fs.writeFileSync(plistPath, xml);\n }\n }\n}\n\nexport {\n getBundleIdentifier,\n setBundleIdentifier,\n getBundleIdentifierFromPbxproj,\n updateBundleIdentifierForPbxproj,\n setBundleIdentifierForPbxproj,\n resetAllPlistBundleIdentifiers,\n resetPlistBundleIdentifier,\n};\n"],"file":"BundleIdentifier.js"}
@@ -1,7 +1,8 @@
1
1
  import type { ExpoConfig } from '@expo/config-types';
2
+ import { JSONValue } from '@expo/json-file';
2
3
  import type { ConfigPlugin } from '../Plugin.types';
3
4
  export declare const JS_ENGINE_PROP_KEY = "expo.jsEngine";
4
5
  export declare const DEFAULT_JS_ENGINE = "jsc";
5
6
  export declare const withJsEnginePodfileProps: ConfigPlugin;
6
7
  export declare function getJsEngine(config: Pick<ExpoConfig, 'ios' | 'jsEngine'>): "hermes" | "jsc";
7
- export declare function setJsEngine(config: Pick<ExpoConfig, 'ios' | 'jsEngine'>, podfileProperties: Record<string, string>): Record<string, string>;
8
+ export declare function setJsEngine(config: Pick<ExpoConfig, 'ios' | 'jsEngine'>, podfileProperties: Record<string, JSONValue>): Record<string, JSONValue>;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ios/JsEngine.ts"],"names":["JS_ENGINE_PROP_KEY","DEFAULT_JS_ENGINE","withJsEnginePodfileProps","config","modResults","setJsEngine","getJsEngine","ios","jsEngine","podfileProperties"],"mappings":";;;;;;;;;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,kBAAkB,GAAG,eAA3B;;AACA,MAAMC,iBAAiB,GAAG,KAA1B;;;AAEA,MAAMC,wBAAsC,GAAGC,MAAM,IAAI;AAC9D,SAAO,yCAAsBA,MAAtB,EAA8BA,MAAM,IAAI;AAC7CA,IAAAA,MAAM,CAACC,UAAP,GAAoBC,WAAW,CAACF,MAAD,EAASA,MAAM,CAACC,UAAhB,CAA/B;AACA,WAAOD,MAAP;AACD,GAHM,CAAP;AAID,CALM;;;;AAOA,SAASG,WAAT,CAAqBH,MAArB,EAAmE;AAAA;;AACxE,wDAAOA,MAAM,CAACI,GAAd,gDAAO,YAAYC,QAAnB,uEAA+BL,MAAM,CAACK,QAAtC,uCAAkDP,iBAAlD;AACD;;AAEM,SAASI,WAAT,CACLF,MADK,EAELM,iBAFK,EAGmB;AAAA;;AACxBA,EAAAA,iBAAiB,CAACT,kBAAD,CAAjB,qDACEG,MAAM,CAACI,GADT,iDACE,aAAYC,QADd,yEAC0BL,MAAM,CAACK,QADjC,yCAC6CP,iBAD7C;AAEA,SAAOQ,iBAAP;AACD","sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { ConfigPlugin } from '../Plugin.types';\nimport { withPodfileProperties } from '../plugins/ios-plugins';\n\nexport const JS_ENGINE_PROP_KEY = 'expo.jsEngine';\nexport const DEFAULT_JS_ENGINE = 'jsc';\n\nexport const withJsEnginePodfileProps: ConfigPlugin = config => {\n return withPodfileProperties(config, config => {\n config.modResults = setJsEngine(config, config.modResults);\n return config;\n });\n};\n\nexport function getJsEngine(config: Pick<ExpoConfig, 'ios' | 'jsEngine'>) {\n return config.ios?.jsEngine ?? config.jsEngine ?? DEFAULT_JS_ENGINE;\n}\n\nexport function setJsEngine(\n config: Pick<ExpoConfig, 'ios' | 'jsEngine'>,\n podfileProperties: Record<string, string>\n): Record<string, string> {\n podfileProperties[JS_ENGINE_PROP_KEY] =\n config.ios?.jsEngine ?? config.jsEngine ?? DEFAULT_JS_ENGINE;\n return podfileProperties;\n}\n"],"file":"JsEngine.js"}
1
+ {"version":3,"sources":["../../src/ios/JsEngine.ts"],"names":["JS_ENGINE_PROP_KEY","DEFAULT_JS_ENGINE","withJsEnginePodfileProps","config","modResults","setJsEngine","getJsEngine","ios","jsEngine","podfileProperties"],"mappings":";;;;;;;;;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,kBAAkB,GAAG,eAA3B;;AACA,MAAMC,iBAAiB,GAAG,KAA1B;;;AAEA,MAAMC,wBAAsC,GAAGC,MAAM,IAAI;AAC9D,SAAO,yCAAsBA,MAAtB,EAA8BA,MAAM,IAAI;AAC7CA,IAAAA,MAAM,CAACC,UAAP,GAAoBC,WAAW,CAACF,MAAD,EAASA,MAAM,CAACC,UAAhB,CAA/B;AACA,WAAOD,MAAP;AACD,GAHM,CAAP;AAID,CALM;;;;AAOA,SAASG,WAAT,CAAqBH,MAArB,EAAmE;AAAA;;AACxE,wDAAOA,MAAM,CAACI,GAAd,gDAAO,YAAYC,QAAnB,uEAA+BL,MAAM,CAACK,QAAtC,uCAAkDP,iBAAlD;AACD;;AAEM,SAASI,WAAT,CACLF,MADK,EAELM,iBAFK,EAGsB;AAAA;;AAC3BA,EAAAA,iBAAiB,CAACT,kBAAD,CAAjB,qDACEG,MAAM,CAACI,GADT,iDACE,aAAYC,QADd,yEAC0BL,MAAM,CAACK,QADjC,yCAC6CP,iBAD7C;AAEA,SAAOQ,iBAAP;AACD","sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\nimport { JSONValue } from '@expo/json-file';\n\nimport type { ConfigPlugin } from '../Plugin.types';\nimport { withPodfileProperties } from '../plugins/ios-plugins';\n\nexport const JS_ENGINE_PROP_KEY = 'expo.jsEngine';\nexport const DEFAULT_JS_ENGINE = 'jsc';\n\nexport const withJsEnginePodfileProps: ConfigPlugin = config => {\n return withPodfileProperties(config, config => {\n config.modResults = setJsEngine(config, config.modResults);\n return config;\n });\n};\n\nexport function getJsEngine(config: Pick<ExpoConfig, 'ios' | 'jsEngine'>) {\n return config.ios?.jsEngine ?? config.jsEngine ?? DEFAULT_JS_ENGINE;\n}\n\nexport function setJsEngine(\n config: Pick<ExpoConfig, 'ios' | 'jsEngine'>,\n podfileProperties: Record<string, JSONValue>\n): Record<string, JSONValue> {\n podfileProperties[JS_ENGINE_PROP_KEY] =\n config.ios?.jsEngine ?? config.jsEngine ?? DEFAULT_JS_ENGINE;\n return podfileProperties;\n}\n"],"file":"JsEngine.js"}
package/build/ios/Maps.js CHANGED
@@ -14,30 +14,30 @@ exports.removeMapsCocoaPods = removeMapsCocoaPods;
14
14
  exports.setGoogleMapsApiKey = setGoogleMapsApiKey;
15
15
  exports.withMaps = void 0;
16
16
 
17
- function _debug() {
18
- const data = _interopRequireDefault(require("debug"));
17
+ function _fsExtra() {
18
+ const data = _interopRequireDefault(require("fs-extra"));
19
19
 
20
- _debug = function () {
20
+ _fsExtra = function () {
21
21
  return data;
22
22
  };
23
23
 
24
24
  return data;
25
25
  }
26
26
 
27
- function _fsExtra() {
28
- const data = _interopRequireDefault(require("fs-extra"));
27
+ function _path() {
28
+ const data = _interopRequireDefault(require("path"));
29
29
 
30
- _fsExtra = function () {
30
+ _path = function () {
31
31
  return data;
32
32
  };
33
33
 
34
34
  return data;
35
35
  }
36
36
 
37
- function _path() {
38
- const data = _interopRequireDefault(require("path"));
37
+ function _resolveFrom() {
38
+ const data = _interopRequireDefault(require("resolve-from"));
39
39
 
40
- _path = function () {
40
+ _resolveFrom = function () {
41
41
  return data;
42
42
  };
43
43
 
@@ -74,21 +74,12 @@ function _generateCode() {
74
74
  return data;
75
75
  }
76
76
 
77
- function _resolvePackageRootFolder() {
78
- const data = require("../utils/resolvePackageRootFolder");
79
-
80
- _resolvePackageRootFolder = function () {
81
- return data;
82
- };
83
-
84
- return data;
85
- }
86
-
87
77
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
88
78
 
89
- const debug = (0, _debug().default)('expo:config-plugins:ios:maps'); // Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules).
79
+ const debug = require('debug')('expo:config-plugins:ios:maps'); // Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules), and SDK +44 React AppDelegate subscriber.
80
+
90
81
 
91
- const MATCH_INIT = /(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[\[RCTBridge alloc\])/g;
82
+ const MATCH_INIT = /(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[\[RCTBridge alloc\])|(\[self\.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions\])/g;
92
83
  exports.MATCH_INIT = MATCH_INIT;
93
84
  const withGoogleMapsKey = (0, _iosPlugins().createInfoPlistPlugin)(setGoogleMapsApiKey, 'withGoogleMapsKey');
94
85
 
@@ -196,12 +187,19 @@ function removeMapsCocoaPods(src) {
196
187
  }
197
188
 
198
189
  function isReactNativeMapsInstalled(projectRoot) {
199
- return (0, _resolvePackageRootFolder().resolvePackageRootFolder)(projectRoot, 'react-native-maps');
190
+ const resolved = _resolveFrom().default.silent(projectRoot, 'react-native-maps/package.json');
191
+
192
+ return resolved ? _path().default.dirname(resolved) : null;
200
193
  }
201
194
 
202
195
  function isReactNativeMapsAutolinked(config) {
203
- // TODO: Detect autolinking
204
- return true;
196
+ var _config$_internal;
197
+
198
+ // Only add the native code changes if we know that the package is going to be linked natively.
199
+ // This is specifically for monorepo support where one app might have react-native-maps (adding it to the node_modules)
200
+ // but another app will not have it installed in the package.json, causing it to not be linked natively.
201
+ // This workaround only exists because react-native-maps doesn't have a config plugin vendored in the package.
202
+ return !((_config$_internal = config._internal) !== null && _config$_internal !== void 0 && _config$_internal.autolinkedModules) || config._internal.autolinkedModules.includes('react-native-maps');
205
203
  }
206
204
 
207
205
  const withMapsCocoaPods = (config, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ios/Maps.ts"],"names":["debug","MATCH_INIT","withGoogleMapsKey","setGoogleMapsApiKey","withMaps","config","apiKey","getGoogleMapsApiKey","withMapsCocoaPods","useGoogleMaps","withGoogleMapsAppDelegate","ios","googleMapsApiKey","GMSApiKey","infoPlist","addGoogleMapsAppDelegateImport","src","newSrc","push","tag","join","anchor","offset","comment","removeGoogleMapsAppDelegateImport","addGoogleMapsAppDelegateInit","removeGoogleMapsAppDelegateInit","addMapsCocoaPods","googleMapsPath","removeMapsCocoaPods","isReactNativeMapsInstalled","projectRoot","isReactNativeMapsAutolinked","filePath","path","modRequest","platformProjectRoot","contents","fs","readFile","results","isLinked","googleMapsPodPath","relative","error","code","Error","didMerge","didClear","writeFile","modResults","language"],"mappings":";;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA,MAAMA,KAAK,GAAG,sBAAM,8BAAN,CAAd,C,CAEA;;AACO,MAAMC,UAAU,GAAG,uHAAnB;;AAEP,MAAMC,iBAAiB,GAAG,yCAAsBC,mBAAtB,EAA2C,mBAA3C,CAA1B;;AAEO,MAAMC,QAAsB,GAAGC,MAAM,IAAI;AAC9CA,EAAAA,MAAM,GAAGH,iBAAiB,CAACG,MAAD,CAA1B;AAEA,QAAMC,MAAM,GAAGC,mBAAmB,CAACF,MAAD,CAAlC,CAH8C,CAI9C;;AAEAL,EAAAA,KAAK,CAAC,sBAAD,EAAyBM,MAAzB,CAAL;AACAD,EAAAA,MAAM,GAAGG,iBAAiB,CAACH,MAAD,EAAS;AAAEI,IAAAA,aAAa,EAAE,CAAC,CAACH;AAAnB,GAAT,CAA1B,CAP8C,CAS9C;;AACAD,EAAAA,MAAM,GAAGK,yBAAyB,CAACL,MAAD,EAAS;AAAEC,IAAAA;AAAF,GAAT,CAAlC;AAEA,SAAOD,MAAP;AACD,CAbM;;;;AAeA,SAASE,mBAAT,CAA6BF,MAA7B,EAA8D;AAAA;;A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0B,2BAA2B,CAAC3B,MAAD,CAD3B,IAEAyB,0BAA0B,CAACzB,MAAM,CAAC8B,UAAP,CAAkBJ,WAAnB,CAH5B,EAIE;AACA,YAAI;AACF1B,UAAAA,MAAM,CAAC6C,UAAP,CAAkBb,QAAlB,GAA6BtB,8BAA8B,CACzDV,MAAM,CAAC6C,UAAP,CAAkBb,QADuC,CAA9B,CAE3BA,QAFF;AAGAhC,UAAAA,MAAM,CAAC6C,UAAP,CAAkBb,QAAlB,GAA6BZ,4BAA4B,CACvDpB,MAAM,CAAC6C,UAAP,CAAkBb,QADqC,EAEvD/B,MAFuD,CAA5B,CAG3B+B,QAHF;AAID,SARD,CAQE,OAAOO,KAAP,EAAc;AACd,cAAIA,KAAK,CAACC,IAAN,KAAe,cAAnB,EAAmC;AACjC,kBAAM,IAAIC,KAAJ,CACH,yIADG,CAAN;AAGD;;AACD,gBAAMF,KAAN;AACD;AACF,OArBD,MAqBO;AACLvC,QAAAA,MAAM,CAAC6C,UAAP,CAAkBb,QAAlB,GAA6Bb,iCAAiC,CAC5DnB,MAAM,CAAC6C,UAAP,CAAkBb,QAD0C,CAAjC,CAE3BA,QAFF;AAGAhC,QAAAA,MAAM,CAAC6C,UAAP,CAAkBb,QAAlB,GAA6BX,+BAA+B,CAC1DrB,MAAM,CAAC6C,UAAP,CAAkBb,QADwC,CAA/B,CAE3BA,QAFF;AAGD;AACF,KA9BD,MA8BO;AACL,YAAM,IAAIS,KAAJ,CAAU,qEAAV,CAAN;AACD;;AACD,WAAOzC,MAAP;AACD,GAnCM,CAAP;AAoCD,CArCD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport Debug from 'debug';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { ConfigPlugin, InfoPlist } from '../Plugin.types';\nimport { createInfoPlistPlugin, withAppDelegate } from '../plugins/ios-plugins';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { mergeContents, MergeResults, removeContents } from '../utils/generateCode';\nimport { resolvePackageRootFolder } from '../utils/resolvePackageRootFolder';\n\nconst debug = Debug('expo:config-plugins:ios:maps');\n\n// Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules).\nexport const MATCH_INIT = /(?:(self\\.|_)(\\w+)\\s?=\\s?\\[\\[UMModuleRegistryAdapter alloc\\])|(?:RCTBridge\\s?\\*\\s?(\\w+)\\s?=\\s?\\[\\[RCTBridge alloc\\])/g;\n\nconst withGoogleMapsKey = createInfoPlistPlugin(setGoogleMapsApiKey, 'withGoogleMapsKey');\n\nexport const withMaps: ConfigPlugin = config => {\n config = withGoogleMapsKey(config);\n\n const apiKey = getGoogleMapsApiKey(config);\n // Technically adds react-native-maps (Apple maps) and google maps.\n\n debug('Google Maps API Key:', apiKey);\n config = withMapsCocoaPods(config, { useGoogleMaps: !!apiKey });\n\n // Adds/Removes AppDelegate setup for Google Maps API on iOS\n config = withGoogleMapsAppDelegate(config, { apiKey });\n\n return config;\n};\n\nexport function getGoogleMapsApiKey(config: Pick<ExpoConfig, 'ios'>) {\n return config.ios?.config?.googleMapsApiKey ?? null;\n}\n\nexport function setGoogleMapsApiKey(\n config: Pick<ExpoConfig, 'ios'>,\n { GMSApiKey, ...infoPlist }: InfoPlist\n): InfoPlist {\n const apiKey = getGoogleMapsApiKey(config);\n\n if (apiKey === null) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n GMSApiKey: apiKey,\n };\n}\n\nexport function addGoogleMapsAppDelegateImport(src: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n '#import <GoogleMaps/GoogleMaps.h>',\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-import',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: /#import \"AppDelegate\\.h\"/,\n offset: 1,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateImport(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-import',\n src,\n });\n}\n\nexport function addGoogleMapsAppDelegateInit(src: string, apiKey: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n ` [GMSServices provideAPIKey:@\"${apiKey}\"];`,\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-init',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: MATCH_INIT,\n offset: 0,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateInit(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-init',\n src,\n });\n}\n\n/**\n * @param src\n * @param useGoogleMaps\n * @param googleMapsPath '../node_modules/react-native-maps'\n * @returns\n */\nexport function addMapsCocoaPods(src: string, googleMapsPath: string): MergeResults {\n return mergeContents({\n tag: 'react-native-maps',\n src,\n newSrc: ` pod 'react-native-google-maps', path: '${googleMapsPath}'`,\n anchor: /use_native_modules/,\n offset: 0,\n comment: '#',\n });\n}\n\nexport function removeMapsCocoaPods(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps',\n src,\n });\n}\n\nfunction isReactNativeMapsInstalled(projectRoot: string): string | null {\n return resolvePackageRootFolder(projectRoot, 'react-native-maps');\n}\n\nfunction isReactNativeMapsAutolinked(config: Pick<ExpoConfig, '_internal'>): boolean {\n // TODO: Detect autolinking\n return true;\n}\n\nconst withMapsCocoaPods: ConfigPlugin<{ useGoogleMaps: boolean }> = (config, { useGoogleMaps }) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');\n const contents = await fs.readFile(filePath, 'utf-8');\n let results: MergeResults;\n // Only add the block if react-native-maps is installed in the project (best effort).\n // Generally prebuild runs after a yarn install so this should always work as expected.\n const googleMapsPath = isReactNativeMapsInstalled(config.modRequest.projectRoot);\n const isLinked = isReactNativeMapsAutolinked(config);\n debug('Is Expo Autolinked:', isLinked);\n debug('react-native-maps path:', googleMapsPath);\n if (isLinked && googleMapsPath && useGoogleMaps) {\n // Make the pod path relative to the ios folder.\n const googleMapsPodPath = path.relative(\n config.modRequest.platformProjectRoot,\n googleMapsPath\n );\n try {\n results = addMapsCocoaPods(contents, googleMapsPodPath);\n } catch (error: any) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add react-native-maps to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.`\n );\n }\n throw error;\n }\n } else {\n // If the package is no longer installed, then remove the block.\n results = removeMapsCocoaPods(contents);\n }\n if (results.didMerge || results.didClear) {\n await fs.writeFile(filePath, results.contents);\n }\n return config;\n },\n ]);\n};\n\nconst withGoogleMapsAppDelegate: ConfigPlugin<{ apiKey: string | null }> = (config, { apiKey }) => {\n return withAppDelegate(config, config => {\n if (config.modResults.language === 'objc') {\n if (\n apiKey &&\n isReactNativeMapsAutolinked(config) &&\n isReactNativeMapsInstalled(config.modRequest.projectRoot)\n ) {\n try {\n config.modResults.contents = addGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = addGoogleMapsAppDelegateInit(\n config.modResults.contents,\n apiKey\n ).contents;\n } catch (error) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add Google Maps to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.`\n );\n }\n throw error;\n }\n } else {\n config.modResults.contents = removeGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = removeGoogleMapsAppDelegateInit(\n config.modResults.contents\n ).contents;\n }\n } else {\n throw new Error('Cannot setup Google Maps because the AppDelegate is not Objective C');\n }\n return config;\n });\n};\n"],"file":"Maps.js"}
1
+ {"version":3,"sources":["../../src/ios/Maps.ts"],"names":["debug","require","MATCH_INIT","withGoogleMapsKey","setGoogleMapsApiKey","withMaps","config","apiKey","getGoogleMapsApiKey","withMapsCocoaPods","useGoogleMaps","withGoogleMapsAppDelegate","ios","googleMapsApiKey","GMSApiKey","infoPlist","addGoogleMapsAppDelegateImport","src","newSrc","push","tag","join","anchor","offset","comment","removeGoogleMapsAppDelegateImport","addGoogleMapsAppDelegateInit","removeGoogleMapsAppDelegateInit","addMapsCocoaPods","googleMapsPath","removeMapsCocoaPods","isReactNativeMapsInstalled","projectRoot","resolved","resolveFrom","silent","path","dirname","isReactNativeMapsAutolinked","_internal","autolinkedModules","includes","filePath","modRequest","platformProjectRoot","contents","fs","readFile","results","isLinked","googleMapsPodPath","relative","error","code","Error","didMerge","didClear","writeFile","modResults","language"],"mappings":";;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAD,CAAP,CAAiB,8BAAjB,CAAd,C,CAEA;;;AACO,MAAMC,UAAU,GAAG,2MAAnB;;AAEP,MAAMC,iBAAiB,GAAG,yCAAsBC,mBAAtB,EAA2C,mBAA3C,CAA1B;;AAEO,MAAMC,QAAsB,GAAGC,MAAM,IAAI;AAC9CA,EAAAA,MAAM,GAAGH,iBAAiB,CAACG,MAAD,CAA1B;AAEA,QAAMC,MAAM,GAAGC,mBAAmB,CAACF,MAAD,CAAlC,CAH8C,CAI9C;;AAEAN,EAAAA,KAAK,CAAC,sBAAD,EAAyBO,MAAzB,CAAL;AACAD,EAAAA,MAAM,GAAGG,iBAAiB,CAACH,MAAD,EAAS;AAAEI,IAAAA,aAAa,EAAE,CAAC,CAACH;AAAnB,GAAT,CAA1B,CAP8C,CAS9C;;AACAD,EAAAA,MAAM,GAAGK,yBAAyB,CAACL,MAAD,EAAS;AAAEC,IAAAA;AAAF,GAAT,CAAlC;AAEA,SAAOD,MAAP;AACD,CAbM;;;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AAOhD,MAAP;AACD,GAnCM,CAAP;AAoCD,CArCD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { ConfigPlugin, InfoPlist } from '../Plugin.types';\nimport { createInfoPlistPlugin, withAppDelegate } from '../plugins/ios-plugins';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { mergeContents, MergeResults, removeContents } from '../utils/generateCode';\n\nconst debug = require('debug')('expo:config-plugins:ios:maps') as typeof console.log;\n\n// Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules), and SDK +44 React AppDelegate subscriber.\nexport const MATCH_INIT = /(?:(self\\.|_)(\\w+)\\s?=\\s?\\[\\[UMModuleRegistryAdapter alloc\\])|(?:RCTBridge\\s?\\*\\s?(\\w+)\\s?=\\s?\\[\\[RCTBridge alloc\\])|(\\[self\\.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions\\])/g;\n\nconst withGoogleMapsKey = createInfoPlistPlugin(setGoogleMapsApiKey, 'withGoogleMapsKey');\n\nexport const withMaps: ConfigPlugin = config => {\n config = withGoogleMapsKey(config);\n\n const apiKey = getGoogleMapsApiKey(config);\n // Technically adds react-native-maps (Apple maps) and google maps.\n\n debug('Google Maps API Key:', apiKey);\n config = withMapsCocoaPods(config, { useGoogleMaps: !!apiKey });\n\n // Adds/Removes AppDelegate setup for Google Maps API on iOS\n config = withGoogleMapsAppDelegate(config, { apiKey });\n\n return config;\n};\n\nexport function getGoogleMapsApiKey(config: Pick<ExpoConfig, 'ios'>) {\n return config.ios?.config?.googleMapsApiKey ?? null;\n}\n\nexport function setGoogleMapsApiKey(\n config: Pick<ExpoConfig, 'ios'>,\n { GMSApiKey, ...infoPlist }: InfoPlist\n): InfoPlist {\n const apiKey = getGoogleMapsApiKey(config);\n\n if (apiKey === null) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n GMSApiKey: apiKey,\n };\n}\n\nexport function addGoogleMapsAppDelegateImport(src: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n '#import <GoogleMaps/GoogleMaps.h>',\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-import',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: /#import \"AppDelegate\\.h\"/,\n offset: 1,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateImport(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-import',\n src,\n });\n}\n\nexport function addGoogleMapsAppDelegateInit(src: string, apiKey: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n ` [GMSServices provideAPIKey:@\"${apiKey}\"];`,\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-init',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: MATCH_INIT,\n offset: 0,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateInit(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-init',\n src,\n });\n}\n\n/**\n * @param src\n * @param useGoogleMaps\n * @param googleMapsPath '../node_modules/react-native-maps'\n * @returns\n */\nexport function addMapsCocoaPods(src: string, googleMapsPath: string): MergeResults {\n return mergeContents({\n tag: 'react-native-maps',\n src,\n newSrc: ` pod 'react-native-google-maps', path: '${googleMapsPath}'`,\n anchor: /use_native_modules/,\n offset: 0,\n comment: '#',\n });\n}\n\nexport function removeMapsCocoaPods(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps',\n src,\n });\n}\n\nfunction isReactNativeMapsInstalled(projectRoot: string): string | null {\n const resolved = resolveFrom.silent(projectRoot, 'react-native-maps/package.json');\n return resolved ? path.dirname(resolved) : null;\n}\n\nfunction isReactNativeMapsAutolinked(config: Pick<ExpoConfig, '_internal'>): string | null {\n // Only add the native code changes if we know that the package is going to be linked natively.\n // This is specifically for monorepo support where one app might have react-native-maps (adding it to the node_modules)\n // but another app will not have it installed in the package.json, causing it to not be linked natively.\n // This workaround only exists because react-native-maps doesn't have a config plugin vendored in the package.\n return (\n !config._internal?.autolinkedModules ||\n config._internal.autolinkedModules.includes('react-native-maps')\n );\n}\n\nconst withMapsCocoaPods: ConfigPlugin<{ useGoogleMaps: boolean }> = (config, { useGoogleMaps }) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');\n const contents = await fs.readFile(filePath, 'utf-8');\n let results: MergeResults;\n // Only add the block if react-native-maps is installed in the project (best effort).\n // Generally prebuild runs after a yarn install so this should always work as expected.\n const googleMapsPath = isReactNativeMapsInstalled(config.modRequest.projectRoot);\n const isLinked = isReactNativeMapsAutolinked(config);\n debug('Is Expo Autolinked:', isLinked);\n debug('react-native-maps path:', googleMapsPath);\n if (isLinked && googleMapsPath && useGoogleMaps) {\n // Make the pod path relative to the ios folder.\n const googleMapsPodPath = path.relative(\n config.modRequest.platformProjectRoot,\n googleMapsPath\n );\n try {\n results = addMapsCocoaPods(contents, googleMapsPodPath);\n } catch (error: any) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add react-native-maps to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.`\n );\n }\n throw error;\n }\n } else {\n // If the package is no longer installed, then remove the block.\n results = removeMapsCocoaPods(contents);\n }\n if (results.didMerge || results.didClear) {\n await fs.writeFile(filePath, results.contents);\n }\n return config;\n },\n ]);\n};\n\nconst withGoogleMapsAppDelegate: ConfigPlugin<{ apiKey: string | null }> = (config, { apiKey }) => {\n return withAppDelegate(config, config => {\n if (config.modResults.language === 'objc') {\n if (\n apiKey &&\n isReactNativeMapsAutolinked(config) &&\n isReactNativeMapsInstalled(config.modRequest.projectRoot)\n ) {\n try {\n config.modResults.contents = addGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = addGoogleMapsAppDelegateInit(\n config.modResults.contents,\n apiKey\n ).contents;\n } catch (error) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add Google Maps to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.`\n );\n }\n throw error;\n }\n } else {\n config.modResults.contents = removeGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = removeGoogleMapsAppDelegateInit(\n config.modResults.contents\n ).contents;\n }\n } else {\n throw new Error('Cannot setup Google Maps because the AppDelegate is not Objective C');\n }\n return config;\n });\n};\n"],"file":"Maps.js"}
@@ -46,17 +46,26 @@ function setProvisioningProfileForPbxproj(projectRoot, {
46
46
  const project = (0, _Xcodeproj().getPbxproj)(projectRoot);
47
47
  const nativeTargetEntry = targetName ? (0, _Target().findNativeTargetByName)(project, targetName) : (0, _Target().findFirstNativeTarget)(project);
48
48
  const [nativeTargetId, nativeTarget] = nativeTargetEntry;
49
+ const quotedAppleTeamId = ensureQuotes(appleTeamId);
49
50
  (0, _Xcodeproj().getBuildConfigurationsForListId)(project, nativeTarget.buildConfigurationList).filter(([, item]) => item.name === buildConfiguration).forEach(([, item]) => {
50
51
  item.buildSettings.PROVISIONING_PROFILE_SPECIFIER = `"${profileName}"`;
51
- item.buildSettings.DEVELOPMENT_TEAM = appleTeamId;
52
+ item.buildSettings.DEVELOPMENT_TEAM = quotedAppleTeamId;
52
53
  item.buildSettings.CODE_SIGN_IDENTITY = '"iPhone Distribution"';
53
54
  item.buildSettings.CODE_SIGN_STYLE = 'Manual';
54
55
  });
55
56
  Object.entries((0, _Xcodeproj().getProjectSection)(project)).filter(_Xcodeproj().isNotComment).forEach(([, item]) => {
56
- item.attributes.TargetAttributes[nativeTargetId].DevelopmentTeam = appleTeamId;
57
+ item.attributes.TargetAttributes[nativeTargetId].DevelopmentTeam = quotedAppleTeamId;
57
58
  item.attributes.TargetAttributes[nativeTargetId].ProvisioningStyle = 'Manual';
58
59
  });
59
60
 
60
61
  _fsExtra().default.writeFileSync(project.filepath, project.writeSync());
61
62
  }
63
+
64
+ const ensureQuotes = value => {
65
+ if (!value.match(/^['"]/)) {
66
+ return `"${value}"`;
67
+ }
68
+
69
+ return value;
70
+ };
62
71
  //# sourceMappingURL=ProvisioningProfile.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ios/ProvisioningProfile.ts"],"names":["setProvisioningProfileForPbxproj","projectRoot","targetName","profileName","appleTeamId","buildConfiguration","project","nativeTargetEntry","nativeTargetId","nativeTarget","buildConfigurationList","filter","item","name","forEach","buildSettings","PROVISIONING_PROFILE_SPECIFIER","DEVELOPMENT_TEAM","CODE_SIGN_IDENTITY","CODE_SIGN_STYLE","Object","entries","isNotComment","attributes","TargetAttributes","DevelopmentTeam","ProvisioningStyle","fs","writeFileSync","filepath","writeSync"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAgBO,SAASA,gCAAT,CACLC,WADK,EAEL;AACEC,EAAAA,UADF;AAEEC,EAAAA,WAFF;AAGEC,EAAAA,WAHF;AAIEC,EAAAA,kBAAkB,GAAG;AAJvB,CAFK,EAQC;AACN,QAAMC,OAAO,GAAG,6BAAWL,WAAX,CAAhB;AAEA,QAAMM,iBAAiB,GAAGL,UAAU,GAChC,sCAAuBI,OAAvB,EAAgCJ,UAAhC,CADgC,GAEhC,qCAAsBI,OAAtB,CAFJ;AAGA,QAAM,CAACE,cAAD,EAAiBC,YAAjB,IAAiCF,iBAAvC;AAEA,oDAAgCD,OAAhC,EAAyCG,YAAY,CAACC,sBAAtD,EACGC,MADH,CACU,CAAC,GAAGC,IAAH,CAAD,KAAyCA,IAAI,CAACC,IAAL,KAAcR,kBADjE,EAEGS,OAFH,CAEW,CAAC,GAAGF,IAAH,CAAD,KAAyC;AAChDA,IAAAA,IAAI,CAACG,aAAL,CAAmBC,8BAAnB,GAAqD,IAAGb,WAAY,GAApE;AACAS,IAAAA,IAAI,CAACG,aAAL,CAAmBE,gBAAnB,GAAsCb,WAAtC;AACAQ,IAAAA,IAAI,CAACG,aAAL,CAAmBG,kBAAnB,GAAwC,uBAAxC;AACAN,IAAAA,IAAI,CAACG,aAAL,CAAmBI,eAAnB,GAAqC,QAArC;AACD,GAPH;AASAC,EAAAA,MAAM,CAACC,OAAP,CAAe,oCAAkBf,OAAlB,CAAf,EACGK,MADH,CACUW,yBADV,EAEGR,OAFH,CAEW,CAAC,GAAGF,IAAH,CAAD,KAAmC;AAC1CA,IAAAA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiChB,cAAjC,EAAiDiB,eAAjD,GAAmErB,WAAnE;AACAQ,IAAAA,IAAI,CAACW,UAAL,CAAgBC,gBAAhB,CAAiChB,cAAjC,EAAiDkB,iBAAjD,GAAqE,QAArE;AACD,GALH;;AAOAC,qBAAGC,aAAH,CAAiBtB,OAAO,CAACuB,QAAzB,EAAmCvB,OAAO,CAACwB,SAAR,EAAnC;AACD","sourcesContent":["import fs from 'fs-extra';\n\nimport { findFirstNativeTarget, findNativeTargetByName } from './Target';\nimport {\n ConfigurationSectionEntry,\n getBuildConfigurationsForListId,\n getPbxproj,\n getProjectSection,\n isNotComment,\n ProjectSectionEntry,\n} from './utils/Xcodeproj';\n\ntype ProvisioningProfileSettings = {\n targetName?: string;\n appleTeamId: string;\n profileName: string;\n buildConfiguration?: string;\n};\n\nexport function setProvisioningProfileForPbxproj(\n projectRoot: string,\n {\n targetName,\n profileName,\n appleTeamId,\n buildConfiguration = 'Release',\n }: ProvisioningProfileSettings\n): void {\n const project = getPbxproj(projectRoot);\n\n const nativeTargetEntry = targetName\n ? findNativeTargetByName(project, targetName)\n : findFirstNativeTarget(project);\n const [nativeTargetId, nativeTarget] = nativeTargetEntry;\n\n getBuildConfigurationsForListId(project, nativeTarget.buildConfigurationList)\n .filter(([, item]: ConfigurationSectionEntry) => item.name === buildConfiguration)\n .forEach(([, item]: ConfigurationSectionEntry) => {\n item.buildSettings.PROVISIONING_PROFILE_SPECIFIER = `\"${profileName}\"`;\n item.buildSettings.DEVELOPMENT_TEAM = appleTeamId;\n item.buildSettings.CODE_SIGN_IDENTITY = '\"iPhone Distribution\"';\n item.buildSettings.CODE_SIGN_STYLE = 'Manual';\n });\n\n Object.entries(getProjectSection(project))\n .filter(isNotComment)\n .forEach(([, item]: ProjectSectionEntry) => {\n item.attributes.TargetAttributes[nativeTargetId].DevelopmentTeam = appleTeamId;\n item.attributes.TargetAttributes[nativeTargetId].ProvisioningStyle = 'Manual';\n });\n\n fs.writeFileSync(project.filepath, project.writeSync());\n}\n"],"file":"ProvisioningProfile.js"}
1
+ {"version":3,"sources":["../../src/ios/ProvisioningProfile.ts"],"names":["setProvisioningProfileForPbxproj","projectRoot","targetName","profileName","appleTeamId","buildConfiguration","project","nativeTargetEntry","nativeTargetId","nativeTarget","quotedAppleTeamId","ensureQuotes","buildConfigurationList","filter","item","name","forEach","buildSettings","PROVISIONING_PROFILE_SPECIFIER","DEVELOPMENT_TEAM","CODE_SIGN_IDENTITY","CODE_SIGN_STYLE","Object","entries","isNotComment","attributes","TargetAttributes","DevelopmentTeam","ProvisioningStyle","fs","writeFileSync","filepath","writeSync","value","match"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAgBO,SAASA,gCAAT,CACLC,WADK,EAEL;AACEC,EAAAA,UADF;AAEEC,EAAAA,WAFF;AAGEC,EAAAA,WAHF;AAIEC,EAAAA,kBAAkB,GAAG;AAJvB,CAFK,EAQC;AACN,QAAMC,OAAO,GAAG,6BAAWL,WAAX,CAAhB;AAEA,QAAMM,iBAAiB,GAAGL,UAAU,GAChC,sCAAuBI,OAAvB,EAAgCJ,UAAhC,CADgC,GAEhC,qCAAsBI,OAAtB,CAFJ;A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etByName } from './Target';\nimport {\n ConfigurationSectionEntry,\n getBuildConfigurationsForListId,\n getPbxproj,\n getProjectSection,\n isNotComment,\n ProjectSectionEntry,\n} from './utils/Xcodeproj';\n\ntype ProvisioningProfileSettings = {\n targetName?: string;\n appleTeamId: string;\n profileName: string;\n buildConfiguration?: string;\n};\n\nexport function setProvisioningProfileForPbxproj(\n projectRoot: string,\n {\n targetName,\n profileName,\n appleTeamId,\n buildConfiguration = 'Release',\n }: ProvisioningProfileSettings\n): void {\n const project = getPbxproj(projectRoot);\n\n const nativeTargetEntry = targetName\n ? findNativeTargetByName(project, targetName)\n : findFirstNativeTarget(project);\n const [nativeTargetId, nativeTarget] = nativeTargetEntry;\n\n const quotedAppleTeamId = ensureQuotes(appleTeamId);\n\n getBuildConfigurationsForListId(project, nativeTarget.buildConfigurationList)\n .filter(([, item]: ConfigurationSectionEntry) => item.name === buildConfiguration)\n .forEach(([, item]: ConfigurationSectionEntry) => {\n item.buildSettings.PROVISIONING_PROFILE_SPECIFIER = `\"${profileName}\"`;\n item.buildSettings.DEVELOPMENT_TEAM = quotedAppleTeamId;\n item.buildSettings.CODE_SIGN_IDENTITY = '\"iPhone Distribution\"';\n item.buildSettings.CODE_SIGN_STYLE = 'Manual';\n });\n\n Object.entries(getProjectSection(project))\n .filter(isNotComment)\n .forEach(([, item]: ProjectSectionEntry) => {\n item.attributes.TargetAttributes[nativeTargetId].DevelopmentTeam = quotedAppleTeamId;\n item.attributes.TargetAttributes[nativeTargetId].ProvisioningStyle = 'Manual';\n });\n\n fs.writeFileSync(project.filepath, project.writeSync());\n}\n\nconst ensureQuotes = (value: string) => {\n if (!value.match(/^['\"]/)) {\n return `\"${value}\"`;\n }\n return value;\n};\n"],"file":"ProvisioningProfile.js"}