@expo/config-plugins 4.0.18 → 4.1.2

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 (84) hide show
  1. package/README.md +17 -2
  2. package/build/android/BuildProperties.d.ts +28 -0
  3. package/build/android/BuildProperties.js +96 -0
  4. package/build/android/BuildProperties.js.map +1 -0
  5. package/build/android/EasBuild.js +8 -8
  6. package/build/android/EasBuild.js.map +1 -1
  7. package/build/android/GoogleServices.js +16 -14
  8. package/build/android/GoogleServices.js.map +1 -1
  9. package/build/android/Manifest.js +7 -5
  10. package/build/android/Manifest.js.map +1 -1
  11. package/build/android/Package.js +27 -15
  12. package/build/android/Package.js.map +1 -1
  13. package/build/android/Paths.js +6 -6
  14. package/build/android/Paths.js.map +1 -1
  15. package/build/android/Scheme.d.ts +5 -2
  16. package/build/android/Scheme.js +26 -15
  17. package/build/android/Scheme.js.map +1 -1
  18. package/build/android/index.d.ts +2 -2
  19. package/build/android/index.js +18 -18
  20. package/build/android/index.js.map +1 -1
  21. package/build/ios/BuildProperties.d.ts +27 -0
  22. package/build/ios/BuildProperties.js +83 -0
  23. package/build/ios/BuildProperties.js.map +1 -0
  24. package/build/ios/BuildScheme.js +6 -3
  25. package/build/ios/BuildScheme.js.map +1 -1
  26. package/build/ios/BundleIdentifier.js +6 -6
  27. package/build/ios/BundleIdentifier.js.map +1 -1
  28. package/build/ios/Entitlements.d.ts +5 -1
  29. package/build/ios/Entitlements.js +63 -52
  30. package/build/ios/Entitlements.js.map +1 -1
  31. package/build/ios/Google.d.ts +5 -5
  32. package/build/ios/Google.js +62 -12
  33. package/build/ios/Google.js.map +1 -1
  34. package/build/ios/Locales.js +14 -14
  35. package/build/ios/Locales.js.map +1 -1
  36. package/build/ios/Maps.js +7 -7
  37. package/build/ios/Maps.js.map +1 -1
  38. package/build/ios/Paths.d.ts +4 -5
  39. package/build/ios/Paths.js +33 -25
  40. package/build/ios/Paths.js.map +1 -1
  41. package/build/ios/ProvisioningProfile.js +4 -4
  42. package/build/ios/ProvisioningProfile.js.map +1 -1
  43. package/build/ios/Swift.js +5 -5
  44. package/build/ios/Swift.js.map +1 -1
  45. package/build/ios/Target.d.ts +1 -0
  46. package/build/ios/Target.js +11 -1
  47. package/build/ios/Target.js.map +1 -1
  48. package/build/ios/XcodeProjectFile.js +5 -5
  49. package/build/ios/XcodeProjectFile.js.map +1 -1
  50. package/build/ios/index.d.ts +2 -2
  51. package/build/ios/index.js +19 -19
  52. package/build/ios/index.js.map +1 -1
  53. package/build/ios/utils/Xcodeproj.d.ts +2 -1
  54. package/build/ios/utils/Xcodeproj.js +4 -1
  55. package/build/ios/utils/Xcodeproj.js.map +1 -1
  56. package/build/plugins/ios-plugins.d.ts +3 -3
  57. package/build/plugins/ios-plugins.js.map +1 -1
  58. package/build/plugins/withAndroidBaseMods.js +0 -3
  59. package/build/plugins/withAndroidBaseMods.js.map +1 -1
  60. package/build/plugins/withIosBaseMods.js +27 -7
  61. package/build/plugins/withIosBaseMods.js.map +1 -1
  62. package/build/utils/BuildProperties.types.d.ts +25 -0
  63. package/build/utils/BuildProperties.types.js +2 -0
  64. package/build/utils/BuildProperties.types.js.map +1 -0
  65. package/build/utils/Updates.d.ts +1 -1
  66. package/build/utils/Updates.js +15 -7
  67. package/build/utils/Updates.js.map +1 -1
  68. package/build/utils/XML.d.ts +1 -0
  69. package/build/utils/XML.js +33 -11
  70. package/build/utils/XML.js.map +1 -1
  71. package/build/utils/fs.d.ts +4 -0
  72. package/build/utils/fs.js +56 -0
  73. package/build/utils/fs.js.map +1 -0
  74. package/build/utils/modules.js +1 -1
  75. package/build/utils/modules.js.map +1 -1
  76. package/build/utils/versions.js +2 -2
  77. package/build/utils/versions.js.map +1 -1
  78. package/package.json +3 -5
  79. package/build/android/JsEngine.d.ts +0 -8
  80. package/build/android/JsEngine.js +0 -59
  81. package/build/android/JsEngine.js.map +0 -1
  82. package/build/ios/JsEngine.d.ts +0 -8
  83. package/build/ios/JsEngine.js +0 -47
  84. package/build/ios/JsEngine.js.map +0 -1
@@ -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","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;;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,a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E,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
+ {"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;;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;;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,GAA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AAIG,GAAG,KAAKR,QAAZ,EAAsB;AACpBT,oBAAGC,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';\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"}
@@ -2,4 +2,8 @@ import { ExpoConfig } from '@expo/config-types';
2
2
  import { JSONObject } from '@expo/json-file';
3
3
  export declare const withAssociatedDomains: import("..").ConfigPlugin<void>;
4
4
  export declare function setAssociatedDomains(config: ExpoConfig, { 'com.apple.developer.associated-domains': _, ...entitlementsPlist }: JSONObject): JSONObject;
5
- export declare function getEntitlementsPath(projectRoot: string): string;
5
+ export declare function getEntitlementsPath(projectRoot: string, { targetName, buildConfiguration, }?: {
6
+ targetName?: string;
7
+ buildConfiguration?: string;
8
+ }): string | null;
9
+ export declare function ensureApplicationTargetEntitlementsFileConfigured(projectRoot: string): void;
@@ -3,14 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.ensureApplicationTargetEntitlementsFileConfigured = ensureApplicationTargetEntitlementsFileConfigured;
6
7
  exports.getEntitlementsPath = getEntitlementsPath;
7
8
  exports.setAssociatedDomains = setAssociatedDomains;
8
9
  exports.withAssociatedDomains = void 0;
9
10
 
10
- function _fsExtra() {
11
- const data = _interopRequireDefault(require("fs-extra"));
11
+ function _fs() {
12
+ const data = _interopRequireDefault(require("fs"));
12
13
 
13
- _fsExtra = function () {
14
+ _fs = function () {
14
15
  return data;
15
16
  };
16
17
 
@@ -47,10 +48,10 @@ function _iosPlugins() {
47
48
  return data;
48
49
  }
49
50
 
50
- function Paths() {
51
- const data = _interopRequireWildcard(require("./Paths"));
51
+ function _Target() {
52
+ const data = require("./Target");
52
53
 
53
- Paths = function () {
54
+ _Target = function () {
54
55
  return data;
55
56
  };
56
57
 
@@ -67,9 +68,15 @@ function _Xcodeproj() {
67
68
  return data;
68
69
  }
69
70
 
70
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
71
+ function _string() {
72
+ const data = require("./utils/string");
71
73
 
72
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
74
+ _string = function () {
75
+ return data;
76
+ };
77
+
78
+ return data;
79
+ }
73
80
 
74
81
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
75
82
 
@@ -91,66 +98,70 @@ function setAssociatedDomains(config, {
91
98
  return entitlementsPlist;
92
99
  }
93
100
 
94
- function getEntitlementsPath(projectRoot) {
95
- const paths = Paths().getAllEntitlementsPaths(projectRoot);
96
- let targetPath = null;
97
- /**
98
- * Add file to pbxproj under CODE_SIGN_ENTITLEMENTS
99
- */
100
-
101
+ function getEntitlementsPath(projectRoot, {
102
+ targetName,
103
+ buildConfiguration = 'Release'
104
+ } = {}) {
101
105
  const project = (0, _Xcodeproj().getPbxproj)(projectRoot);
102
- const projectName = (0, _Xcodeproj().getProjectName)(projectRoot);
103
- const productName = (0, _Xcodeproj().getProductName)(project); // Use posix formatted path, even on Windows
106
+ const xcBuildConfiguration = (0, _Target().getXCBuildConfigurationFromPbxproj)(project, {
107
+ targetName,
108
+ buildConfiguration
109
+ });
104
110
 
105
- const entitlementsRelativePath = (0, _slash().default)(_path().default.join(projectName, `${productName}.entitlements`));
106
- const entitlementsPath = (0, _slash().default)(_path().default.normalize(_path().default.join(projectRoot, 'ios', entitlementsRelativePath)));
107
- const pathsToDelete = [];
111
+ if (!xcBuildConfiguration) {
112
+ return null;
113
+ }
108
114
 
109
- while (paths.length) {
110
- const last = (0, _slash().default)(_path().default.normalize(paths.pop()));
115
+ const entitlementsPath = getEntitlementsPathFromBuildConfiguration(projectRoot, xcBuildConfiguration);
116
+ return entitlementsPath && _fs().default.existsSync(entitlementsPath) ? entitlementsPath : null;
117
+ }
111
118
 
112
- if (last !== entitlementsPath) {
113
- pathsToDelete.push(last);
114
- } else {
115
- targetPath = last;
116
- }
117
- } // Create a new entitlements file
119
+ function getEntitlementsPathFromBuildConfiguration(projectRoot, xcBuildConfiguration) {
120
+ var _xcBuildConfiguration;
118
121
 
122
+ const entitlementsPathRaw = xcBuildConfiguration === null || xcBuildConfiguration === void 0 ? void 0 : (_xcBuildConfiguration = xcBuildConfiguration.buildSettings) === null || _xcBuildConfiguration === void 0 ? void 0 : _xcBuildConfiguration.CODE_SIGN_ENTITLEMENTS;
119
123
 
120
- if (!targetPath) {
121
- targetPath = entitlementsPath; // Use the default template
124
+ if (entitlementsPathRaw) {
125
+ return _path().default.normalize(_path().default.join(projectRoot, 'ios', (0, _string().trimQuotes)(entitlementsPathRaw)));
126
+ } else {
127
+ return null;
128
+ }
129
+ }
130
+
131
+ function ensureApplicationTargetEntitlementsFileConfigured(projectRoot) {
132
+ const project = (0, _Xcodeproj().getPbxproj)(projectRoot);
133
+ const projectName = (0, _Xcodeproj().getProjectName)(projectRoot);
134
+ const productName = (0, _Xcodeproj().getProductName)(project);
135
+ const [, applicationTarget] = (0, _Target().findFirstNativeTarget)(project);
136
+ const buildConfigurations = (0, _Xcodeproj().getBuildConfigurationsForListId)(project, applicationTarget.buildConfigurationList);
137
+ let hasChangesToWrite = false;
122
138
 
123
- let template = ENTITLEMENTS_TEMPLATE; // If an old entitlements file exists, copy it's contents into the new file.
139
+ for (const [, xcBuildConfiguration] of buildConfigurations) {
140
+ const oldEntitlementPath = getEntitlementsPathFromBuildConfiguration(projectRoot, xcBuildConfiguration);
124
141
 
125
- if (pathsToDelete.length) {
126
- // Get the last entitlements file and use it as the template
127
- const last = pathsToDelete[pathsToDelete.length - 1];
128
- template = _fsExtra().default.readFileSync(last, 'utf8');
142
+ if (oldEntitlementPath && _fs().default.existsSync(oldEntitlementPath)) {
143
+ return;
129
144
  }
130
145
 
131
- _fsExtra().default.ensureDirSync(_path().default.dirname(entitlementsPath));
146
+ hasChangesToWrite = true; // Use posix formatted path, even on Windows
132
147
 
133
- _fsExtra().default.writeFileSync(entitlementsPath, template);
148
+ const entitlementsRelativePath = (0, _slash().default)(_path().default.join(projectName, `${productName}.entitlements`));
134
149
 
135
- Object.entries(project.pbxXCBuildConfigurationSection()).filter(_Xcodeproj().isNotComment).filter(_Xcodeproj().isBuildConfig).filter(_Xcodeproj().isNotTestHost).forEach(({
136
- 1: {
137
- buildSettings
138
- }
139
- }) => {
140
- buildSettings.CODE_SIGN_ENTITLEMENTS = `"${entitlementsRelativePath}"`;
141
- });
150
+ const entitlementsPath = _path().default.normalize(_path().default.join(projectRoot, 'ios', entitlementsRelativePath));
142
151
 
143
- _fsExtra().default.writeFileSync(project.filepath, project.writeSync());
144
- } // Clean up others
152
+ _fs().default.mkdirSync(_path().default.dirname(entitlementsPath), {
153
+ recursive: true
154
+ });
145
155
 
156
+ if (!_fs().default.existsSync(entitlementsPath)) {
157
+ _fs().default.writeFileSync(entitlementsPath, ENTITLEMENTS_TEMPLATE);
158
+ }
146
159
 
147
- deleteEntitlementsFiles(pathsToDelete);
148
- return entitlementsPath;
149
- }
160
+ xcBuildConfiguration.buildSettings.CODE_SIGN_ENTITLEMENTS = entitlementsRelativePath;
161
+ }
150
162
 
151
- function deleteEntitlementsFiles(entitlementsPaths) {
152
- for (const path of entitlementsPaths) {
153
- _fsExtra().default.removeSync(path);
163
+ if (hasChangesToWrite) {
164
+ _fs().default.writeFileSync(project.filepath, project.writeSync());
154
165
  }
155
166
  }
156
167
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ios/Entitlements.ts"],"names":["withAssociatedDomains","setAssociatedDomains","config","_","entitlementsPlist","ios","associatedDomains","getEntitlementsPath","projectRoot","paths","Paths","getAllEntitlementsPaths","targetPath","project","projectName","productName","entitlementsRelativePath","path","join","entitlementsPath","normalize","pathsToDelete","length","last","pop","push","template","ENTITLEMENTS_TEMPLATE","fs","readFileSync","ensureDirSync","dirname","writeFileSync","Object","entries","pbxXCBuildConfigurationSection","filter","isNotComment","isBuildConfig","isNotTestHost","forEach","buildSettings","CODE_SIGN_ENTITLEMENTS","filepath","writeSync","deleteEntitlementsFiles","entitlementsPaths","removeSync"],"mappings":";;;;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;A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AACF,GA1B8D,CA4B/D;;;AACA,MAAI,CAACX,UAAL,EAAiB;AACfA,IAAAA,UAAU,GAAGO,gBAAb,CADe,CAGf;;AACA,QAAIO,QAAQ,GAAGC,qBAAf,CAJe,CAMf;;AACA,QAAIN,aAAa,CAACC,MAAlB,EAA0B;AACxB;AACA,YAAMC,IAAI,GAAGF,aAAa,CAACA,aAAa,CAACC,MAAd,GAAuB,CAAxB,CAA1B;AACAI,MAAAA,QAAQ,GAAGE,mBAAGC,YAAH,CAAgBN,IAAhB,EAAsB,MAAtB,CAAX;AACD;;AAEDK,uBAAGE,aAAH,CAAiBb,gBAAKc,OAAL,CAAaZ,gBAAb,CAAjB;;AACAS,uBAAGI,aAAH,CAAiBb,gBAAjB,EAAmCO,QAAnC;;AAEAO,IAAAA,MAAM,CAACC,OAAP,CAAerB,OAAO,CAACsB,8BAAR,EAAf,EACGC,MADH,CACUC,yBADV,EAEGD,MAFH,CAEUE,0BAFV,EAGGF,MAHH,CAGUG,0BAHV,EAIGC,OAJH,CAIW,CAAC;AAAE,SAAG;AAAEC,QAAAA;AAAF;AAAL,KAAD,KAAmC;AAC1CA,MAAAA,aAAa,CAACC,sBAAd,GAAwC,IAAG1B,wBAAyB,GAApE;AACD,KANH;;AAOAY,uBAAGI,aAAH,CAAiBnB,OAAO,CAAC8B,QAAzB,EAAmC9B,OAAO,CAAC+B,SAAR,EAAnC;AACD,GArD8D,CAuD/D;;;AACAC,EAAAA,uBAAuB,CAACxB,aAAD,CAAvB;AAEA,SAAOF,gBAAP;AACD;;AAED,SAAS0B,uBAAT,CAAiCC,iBAAjC,EAA8D;AAC5D,OAAK,MAAM7B,IAAX,IAAmB6B,iBAAnB,EAAsC;AACpClB,uBAAGmB,UAAH,CAAc9B,IAAd;AACD;AACF;;AAED,MAAMU,qBAAqB,GAAI;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA,CAPA","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport { JSONObject } from '@expo/json-file';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport slash from 'slash';\n\nimport { createEntitlementsPlugin } from '../plugins/ios-plugins';\nimport * as Paths from './Paths';\nimport {\n getPbxproj,\n getProductName,\n getProjectName,\n isBuildConfig,\n isNotComment,\n isNotTestHost,\n} from './utils/Xcodeproj';\n\nexport const withAssociatedDomains = createEntitlementsPlugin(\n setAssociatedDomains,\n 'withAssociatedDomains'\n);\n\nexport function setAssociatedDomains(\n config: ExpoConfig,\n { 'com.apple.developer.associated-domains': _, ...entitlementsPlist }: JSONObject\n): JSONObject {\n if (config.ios?.associatedDomains) {\n return {\n ...entitlementsPlist,\n 'com.apple.developer.associated-domains': config.ios.associatedDomains,\n };\n }\n\n return entitlementsPlist;\n}\n\nexport function getEntitlementsPath(projectRoot: string): string {\n const paths = Paths.getAllEntitlementsPaths(projectRoot);\n let targetPath: string | null = null;\n\n /**\n * Add file to pbxproj under CODE_SIGN_ENTITLEMENTS\n */\n const project = getPbxproj(projectRoot);\n const projectName = getProjectName(projectRoot);\n const productName = getProductName(project);\n\n // Use posix formatted path, even on Windows\n const entitlementsRelativePath = slash(path.join(projectName, `${productName}.entitlements`));\n const entitlementsPath = slash(\n path.normalize(path.join(projectRoot, 'ios', entitlementsRelativePath))\n );\n\n const pathsToDelete: string[] = [];\n\n while (paths.length) {\n const last = slash(path.normalize(paths.pop()!));\n if (last !== entitlementsPath) {\n pathsToDelete.push(last);\n } else {\n targetPath = last;\n }\n }\n\n // Create a new entitlements file\n if (!targetPath) {\n targetPath = entitlementsPath;\n\n // Use the default template\n let template = ENTITLEMENTS_TEMPLATE;\n\n // If an old entitlements file exists, copy it's contents into the new file.\n if (pathsToDelete.length) {\n // Get the last entitlements file and use it as the template\n const last = pathsToDelete[pathsToDelete.length - 1]!;\n template = fs.readFileSync(last, 'utf8');\n }\n\n fs.ensureDirSync(path.dirname(entitlementsPath));\n fs.writeFileSync(entitlementsPath, template);\n\n Object.entries(project.pbxXCBuildConfigurationSection())\n .filter(isNotComment)\n .filter(isBuildConfig)\n .filter(isNotTestHost)\n .forEach(({ 1: { buildSettings } }: any) => {\n buildSettings.CODE_SIGN_ENTITLEMENTS = `\"${entitlementsRelativePath}\"`;\n });\n fs.writeFileSync(project.filepath, project.writeSync());\n }\n\n // Clean up others\n deleteEntitlementsFiles(pathsToDelete);\n\n return entitlementsPath;\n}\n\nfunction deleteEntitlementsFiles(entitlementsPaths: string[]) {\n for (const path of entitlementsPaths) {\n fs.removeSync(path);\n }\n}\n\nconst ENTITLEMENTS_TEMPLATE = `\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n</dict>\n</plist>\n`;\n"],"file":"Entitlements.js"}
1
+ {"version":3,"sources":["../../src/ios/Entitlements.ts"],"names":["withAssociatedDomains","setAssociatedDomains","config","_","entitlementsPlist","ios","associatedDomains","getEntitlementsPath","projectRoot","targetName","buildConfiguration","project","xcBuildConfiguration","entitlementsPath","getEntitlementsPathFromBuildConfiguration","fs","existsSync","entitlementsPathRaw","buildSettings","CODE_SIGN_ENTITLEMENTS","path","normalize","join","ensureApplicationTargetEntitlementsFileConfigured","projectName","productName","applicationTarget","buildConfigurations","buildConfigurationList","hasChangesToWrite","oldEntitlementPath","entitlementsRelativePath","mkdirSync","dirname","recursive","writeFileSync","ENTITLEMENTS_TEMPLATE","filepath","writeSync"],"mappings":";;;;;;;;;;AAEA;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;;AAMA;AAAA;;AAAA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OAAO,CAAC0B,QAAzB,EAAmC1B,OAAO,CAAC2B,SAAR,EAAnC;AACD;AACF;;AAED,MAAMF,qBAAqB,GAAI;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA,CAPA","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport { JSONObject } from '@expo/json-file';\nimport fs from 'fs';\nimport path from 'path';\nimport slash from 'slash';\nimport { XCBuildConfiguration } from 'xcode';\n\nimport { createEntitlementsPlugin } from '../plugins/ios-plugins';\nimport { findFirstNativeTarget, getXCBuildConfigurationFromPbxproj } from './Target';\nimport {\n getBuildConfigurationsForListId,\n getPbxproj,\n getProductName,\n getProjectName,\n} from './utils/Xcodeproj';\nimport { trimQuotes } from './utils/string';\n\nexport const withAssociatedDomains = createEntitlementsPlugin(\n setAssociatedDomains,\n 'withAssociatedDomains'\n);\n\nexport function setAssociatedDomains(\n config: ExpoConfig,\n { 'com.apple.developer.associated-domains': _, ...entitlementsPlist }: JSONObject\n): JSONObject {\n if (config.ios?.associatedDomains) {\n return {\n ...entitlementsPlist,\n 'com.apple.developer.associated-domains': config.ios.associatedDomains,\n };\n }\n\n return entitlementsPlist;\n}\n\nexport function getEntitlementsPath(\n projectRoot: string,\n {\n targetName,\n buildConfiguration = 'Release',\n }: { targetName?: string; buildConfiguration?: string } = {}\n): string | null {\n const project = getPbxproj(projectRoot);\n const xcBuildConfiguration = getXCBuildConfigurationFromPbxproj(project, {\n targetName,\n buildConfiguration,\n });\n if (!xcBuildConfiguration) {\n return null;\n }\n const entitlementsPath = getEntitlementsPathFromBuildConfiguration(\n projectRoot,\n xcBuildConfiguration\n );\n return entitlementsPath && fs.existsSync(entitlementsPath) ? entitlementsPath : null;\n}\n\nfunction getEntitlementsPathFromBuildConfiguration(\n projectRoot: string,\n xcBuildConfiguration: XCBuildConfiguration\n): string | null {\n const entitlementsPathRaw = xcBuildConfiguration?.buildSettings?.CODE_SIGN_ENTITLEMENTS as\n | string\n | undefined;\n if (entitlementsPathRaw) {\n return path.normalize(path.join(projectRoot, 'ios', trimQuotes(entitlementsPathRaw)));\n } else {\n return null;\n }\n}\n\nexport function ensureApplicationTargetEntitlementsFileConfigured(projectRoot: string): void {\n const project = getPbxproj(projectRoot);\n const projectName = getProjectName(projectRoot);\n const productName = getProductName(project);\n\n const [, applicationTarget] = findFirstNativeTarget(project);\n const buildConfigurations = getBuildConfigurationsForListId(\n project,\n applicationTarget.buildConfigurationList\n );\n let hasChangesToWrite = false;\n for (const [, xcBuildConfiguration] of buildConfigurations) {\n const oldEntitlementPath = getEntitlementsPathFromBuildConfiguration(\n projectRoot,\n xcBuildConfiguration\n );\n if (oldEntitlementPath && fs.existsSync(oldEntitlementPath)) {\n return;\n }\n hasChangesToWrite = true;\n // Use posix formatted path, even on Windows\n const entitlementsRelativePath = slash(path.join(projectName, `${productName}.entitlements`));\n const entitlementsPath = path.normalize(\n path.join(projectRoot, 'ios', entitlementsRelativePath)\n );\n fs.mkdirSync(path.dirname(entitlementsPath), { recursive: true });\n if (!fs.existsSync(entitlementsPath)) {\n fs.writeFileSync(entitlementsPath, ENTITLEMENTS_TEMPLATE);\n }\n xcBuildConfiguration.buildSettings.CODE_SIGN_ENTITLEMENTS = entitlementsRelativePath;\n }\n if (hasChangesToWrite) {\n fs.writeFileSync(project.filepath, project.writeSync());\n }\n}\n\nconst ENTITLEMENTS_TEMPLATE = `\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n</dict>\n</plist>\n`;\n"],"file":"Entitlements.js"}
@@ -1,13 +1,13 @@
1
1
  import { ExpoConfig } from '@expo/config-types';
2
2
  import { XcodeProject } from 'xcode';
3
- import { ConfigPlugin } from '../Plugin.types';
3
+ import { ConfigPlugin, ModProps } from '../Plugin.types';
4
4
  import { InfoPlist } from './IosConfig.types';
5
- export declare const withGoogle: ConfigPlugin<void>;
5
+ export declare const withGoogle: ConfigPlugin;
6
6
  export declare const withGoogleServicesFile: ConfigPlugin;
7
- export declare function getGoogleSignInReservedClientId(config: Pick<ExpoConfig, 'ios'>): string | null;
7
+ export declare function getGoogleSignInReservedClientId(config: Pick<ExpoConfig, 'ios'>, modRequest: Pick<ModProps<InfoPlist>, 'projectRoot'>): string | null;
8
8
  export declare function getGoogleServicesFile(config: Pick<ExpoConfig, 'ios'>): string | null;
9
- export declare function setGoogleSignInReservedClientId(config: Pick<ExpoConfig, 'ios'>, infoPlist: InfoPlist): InfoPlist;
10
- export declare function setGoogleConfig(config: Pick<ExpoConfig, 'ios'>, infoPlist: InfoPlist): InfoPlist;
9
+ export declare function setGoogleSignInReservedClientId(config: Pick<ExpoConfig, 'ios'>, infoPlist: InfoPlist, modRequest: Pick<ModProps<InfoPlist>, 'projectRoot'>): InfoPlist;
10
+ export declare function setGoogleConfig(config: Pick<ExpoConfig, 'ios'>, infoPlist: InfoPlist, modRequest: ModProps<InfoPlist>): InfoPlist;
11
11
  export declare function setGoogleServicesFile(config: Pick<ExpoConfig, 'ios'>, { projectRoot, project }: {
12
12
  project: XcodeProject;
13
13
  projectRoot: string;
@@ -10,10 +10,30 @@ exports.setGoogleServicesFile = setGoogleServicesFile;
10
10
  exports.setGoogleSignInReservedClientId = setGoogleSignInReservedClientId;
11
11
  exports.withGoogleServicesFile = exports.withGoogle = void 0;
12
12
 
13
- function _fsExtra() {
14
- const data = _interopRequireDefault(require("fs-extra"));
13
+ function _plist() {
14
+ const data = _interopRequireDefault(require("@expo/plist"));
15
15
 
16
- _fsExtra = function () {
16
+ _plist = function () {
17
+ return data;
18
+ };
19
+
20
+ return data;
21
+ }
22
+
23
+ function _assert() {
24
+ const data = _interopRequireDefault(require("assert"));
25
+
26
+ _assert = function () {
27
+ return data;
28
+ };
29
+
30
+ return data;
31
+ }
32
+
33
+ function _fs() {
34
+ const data = _interopRequireDefault(require("fs"));
35
+
36
+ _fs = function () {
17
37
  return data;
18
38
  };
19
39
 
@@ -72,7 +92,13 @@ function _Xcodeproj() {
72
92
 
73
93
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
74
94
 
75
- const withGoogle = (0, _iosPlugins().createInfoPlistPlugin)(setGoogleConfig, 'withGoogle');
95
+ const withGoogle = config => {
96
+ return (0, _iosPlugins().withInfoPlist)(config, config => {
97
+ config.modResults = setGoogleConfig(config, config.modResults, config.modRequest);
98
+ return config;
99
+ });
100
+ };
101
+
76
102
  exports.withGoogle = withGoogle;
77
103
 
78
104
  const withGoogleServicesFile = config => {
@@ -87,10 +113,34 @@ const withGoogleServicesFile = config => {
87
113
 
88
114
  exports.withGoogleServicesFile = withGoogleServicesFile;
89
115
 
90
- function getGoogleSignInReservedClientId(config) {
91
- var _config$ios$config$go, _config$ios, _config$ios$config, _config$ios$config$go2;
116
+ function readGoogleServicesInfoPlist(relativePath, {
117
+ projectRoot
118
+ }) {
119
+ const googleServiceFilePath = _path().default.resolve(projectRoot, relativePath);
120
+
121
+ const contents = _fs().default.readFileSync(googleServiceFilePath, 'utf8');
122
+
123
+ (0, _assert().default)(contents, 'GoogleService-Info.plist is empty');
124
+ return _plist().default.parse(contents);
125
+ }
126
+
127
+ function getGoogleSignInReservedClientId(config, modRequest) {
128
+ var _config$ios$config$go, _config$ios, _config$ios$config, _config$ios$config$go2, _infoPlist$REVERSED_C;
129
+
130
+ const reservedClientId = (_config$ios$config$go = (_config$ios = config.ios) === null || _config$ios === void 0 ? void 0 : (_config$ios$config = _config$ios.config) === null || _config$ios$config === void 0 ? void 0 : (_config$ios$config$go2 = _config$ios$config.googleSignIn) === null || _config$ios$config$go2 === void 0 ? void 0 : _config$ios$config$go2.reservedClientId) !== null && _config$ios$config$go !== void 0 ? _config$ios$config$go : null;
131
+
132
+ if (reservedClientId) {
133
+ return reservedClientId;
134
+ }
135
+
136
+ const googleServicesFileRelativePath = getGoogleServicesFile(config);
137
+
138
+ if (googleServicesFileRelativePath === null) {
139
+ return null;
140
+ }
92
141
 
93
- return (_config$ios$config$go = (_config$ios = config.ios) === null || _config$ios === void 0 ? void 0 : (_config$ios$config = _config$ios.config) === null || _config$ios$config === void 0 ? void 0 : (_config$ios$config$go2 = _config$ios$config.googleSignIn) === null || _config$ios$config$go2 === void 0 ? void 0 : _config$ios$config$go2.reservedClientId) !== null && _config$ios$config$go !== void 0 ? _config$ios$config$go : null;
142
+ const infoPlist = readGoogleServicesInfoPlist(googleServicesFileRelativePath, modRequest);
143
+ return (_infoPlist$REVERSED_C = infoPlist.REVERSED_CLIENT_ID) !== null && _infoPlist$REVERSED_C !== void 0 ? _infoPlist$REVERSED_C : null;
94
144
  }
95
145
 
96
146
  function getGoogleServicesFile(config) {
@@ -99,8 +149,8 @@ function getGoogleServicesFile(config) {
99
149
  return (_config$ios$googleSer = (_config$ios2 = config.ios) === null || _config$ios2 === void 0 ? void 0 : _config$ios2.googleServicesFile) !== null && _config$ios$googleSer !== void 0 ? _config$ios$googleSer : null;
100
150
  }
101
151
 
102
- function setGoogleSignInReservedClientId(config, infoPlist) {
103
- const reservedClientId = getGoogleSignInReservedClientId(config);
152
+ function setGoogleSignInReservedClientId(config, infoPlist, modRequest) {
153
+ const reservedClientId = getGoogleSignInReservedClientId(config, modRequest);
104
154
 
105
155
  if (reservedClientId === null) {
106
156
  return infoPlist;
@@ -109,8 +159,8 @@ function setGoogleSignInReservedClientId(config, infoPlist) {
109
159
  return (0, _Scheme().appendScheme)(reservedClientId, infoPlist);
110
160
  }
111
161
 
112
- function setGoogleConfig(config, infoPlist) {
113
- infoPlist = setGoogleSignInReservedClientId(config, infoPlist);
162
+ function setGoogleConfig(config, infoPlist, modRequest) {
163
+ infoPlist = setGoogleSignInReservedClientId(config, infoPlist, modRequest);
114
164
  return infoPlist;
115
165
  }
116
166
 
@@ -126,7 +176,7 @@ function setGoogleServicesFile(config, {
126
176
 
127
177
  const googleServiceFilePath = _path().default.resolve(projectRoot, googleServicesFileRelativePath);
128
178
 
129
- _fsExtra().default.copyFileSync(googleServiceFilePath, _path().default.join((0, _Paths().getSourceRoot)(projectRoot), 'GoogleService-Info.plist'));
179
+ _fs().default.copyFileSync(googleServiceFilePath, _path().default.join((0, _Paths().getSourceRoot)(projectRoot), 'GoogleService-Info.plist'));
130
180
 
131
181
  const projectName = (0, _Xcodeproj().getProjectName)(projectRoot);
132
182
  const plistFilePath = `${projectName}/GoogleService-Info.plist`;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ios/Google.ts"],"names":["withGoogle","setGoogleConfig","withGoogleServicesFile","config","modResults","setGoogleServicesFile","projectRoot","modRequest","project","getGoogleSignInReservedClientId","ios","googleSignIn","reservedClientId","getGoogleServicesFile","googleServicesFile","setGoogleSignInReservedClientId","infoPlist","googleServicesFileRelativePath","googleServiceFilePath","path","resolve","fs","copyFileSync","join","projectName","plistFilePath","hasFile","filepath","groupName","isBuildFile","verbose"],"mappings":";;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;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,UAAU,GAAG,yCAAsBC,eAAtB,EAAuC,YAAvC,CAAnB;;;AAEA,MAAMC,sBAAoC,GAAGC,MAAM,IAAI;AAC5D,SAAO,oCAAiBA,MAAjB,EAAyBA,MAAM,IAAI;AACxCA,IAAAA,MAAM,CAACC,UAAP,GAAoBC,qBAAqB,CAACF,MAAD,EAAS;AAChDG,MAAAA,WAAW,EAAEH,MAAM,CAACI,UAAP,CAAkBD,WADiB;AAEhDE,MAAAA,OAAO,EAAEL,MAAM,CAACC;AAFgC,KAAT,CAAzC;AAIA,WAAOD,MAAP;AACD,GANM,C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CAAgBD,aAAhB,CAAL,EAAqC;AACnCjB,IAAAA,OAAO,GAAG,yCAAuB;AAC/BmB,MAAAA,QAAQ,EAAEF,aADqB;AAE/BG,MAAAA,SAAS,EAAEJ,WAFoB;AAG/BhB,MAAAA,OAH+B;AAI/BqB,MAAAA,WAAW,EAAE,IAJkB;AAK/BC,MAAAA,OAAO,EAAE;AALsB,KAAvB,CAAV;AAOD;;AACD,SAAOtB,OAAP;AACD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { XcodeProject } from 'xcode';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { createInfoPlistPlugin, withXcodeProject } from '../plugins/ios-plugins';\nimport { InfoPlist } from './IosConfig.types';\nimport { getSourceRoot } from './Paths';\nimport { appendScheme } from './Scheme';\nimport { addResourceFileToGroup, getProjectName } from './utils/Xcodeproj';\n\nexport const withGoogle = createInfoPlistPlugin(setGoogleConfig, 'withGoogle');\n\nexport const withGoogleServicesFile: ConfigPlugin = config => {\n return withXcodeProject(config, config => {\n config.modResults = setGoogleServicesFile(config, {\n projectRoot: config.modRequest.projectRoot,\n project: config.modResults,\n });\n return config;\n });\n};\n\nexport function getGoogleSignInReservedClientId(config: Pick<ExpoConfig, 'ios'>) {\n return config.ios?.config?.googleSignIn?.reservedClientId ?? null;\n}\n\nexport function getGoogleServicesFile(config: Pick<ExpoConfig, 'ios'>) {\n return config.ios?.googleServicesFile ?? null;\n}\n\nexport function setGoogleSignInReservedClientId(\n config: Pick<ExpoConfig, 'ios'>,\n infoPlist: InfoPlist\n): InfoPlist {\n const reservedClientId = getGoogleSignInReservedClientId(config);\n\n if (reservedClientId === null) {\n return infoPlist;\n }\n\n return appendScheme(reservedClientId, infoPlist);\n}\n\nexport function setGoogleConfig(config: Pick<ExpoConfig, 'ios'>, infoPlist: InfoPlist): InfoPlist {\n infoPlist = setGoogleSignInReservedClientId(config, infoPlist);\n return infoPlist;\n}\n\nexport function setGoogleServicesFile(\n config: Pick<ExpoConfig, 'ios'>,\n { projectRoot, project }: { project: XcodeProject; projectRoot: string }\n): XcodeProject {\n const googleServicesFileRelativePath = getGoogleServicesFile(config);\n if (googleServicesFileRelativePath === null) {\n return project;\n }\n\n const googleServiceFilePath = path.resolve(projectRoot, googleServicesFileRelativePath);\n fs.copyFileSync(\n googleServiceFilePath,\n path.join(getSourceRoot(projectRoot), 'GoogleService-Info.plist')\n );\n\n const projectName = getProjectName(projectRoot);\n const plistFilePath = `${projectName}/GoogleService-Info.plist`;\n if (!project.hasFile(plistFilePath)) {\n project = addResourceFileToGroup({\n filepath: plistFilePath,\n groupName: projectName,\n project,\n isBuildFile: true,\n verbose: true,\n });\n }\n return project;\n}\n"],"file":"Google.js"}
1
+ {"version":3,"sources":["../../src/ios/Google.ts"],"names":["withGoogle","config","modResults","setGoogleConfig","modRequest","withGoogleServicesFile","setGoogleServicesFile","projectRoot","project","readGoogleServicesInfoPlist","relativePath","googleServiceFilePath","path","resolve","contents","fs","readFileSync","plist","parse","getGoogleSignInReservedClientId","reservedClientId","ios","googleSignIn","googleServicesFileRelativePath","getGoogleServicesFile","infoPlist","REVERSED_CLIENT_ID","googleServicesFile","setGoogleSignInReservedClientId","copyFileSync","join","projectName","plistFilePath","hasFile","filepath","groupName","isBuildFile","verbose"],"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;;AAIA;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,UAAwB,GAAGC,MAAM,IAAI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,CAAgBD,aAAhB,CAAL,EAAqC;AACnCxB,IAAAA,OAAO,GAAG,yCAAuB;AAC/B0B,MAAAA,QAAQ,EAAEF,aADqB;AAE/BG,MAAAA,SAAS,EAAEJ,WAFoB;AAG/BvB,MAAAA,OAH+B;AAI/B4B,MAAAA,WAAW,EAAE,IAJkB;AAK/BC,MAAAA,OAAO,EAAE;AALsB,KAAvB,CAAV;AAOD;;AACD,SAAO7B,OAAP;AACD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport plist from '@expo/plist';\nimport assert from 'assert';\nimport fs from 'fs';\nimport path from 'path';\nimport { XcodeProject } from 'xcode';\n\nimport { ConfigPlugin, ModProps } from '../Plugin.types';\nimport { withInfoPlist, withXcodeProject } from '../plugins/ios-plugins';\nimport { InfoPlist } from './IosConfig.types';\nimport { getSourceRoot } from './Paths';\nimport { appendScheme } from './Scheme';\nimport { addResourceFileToGroup, getProjectName } from './utils/Xcodeproj';\n\nexport const withGoogle: ConfigPlugin = config => {\n return withInfoPlist(config, config => {\n config.modResults = setGoogleConfig(config, config.modResults, config.modRequest);\n return config;\n });\n};\n\nexport const withGoogleServicesFile: ConfigPlugin = config => {\n return withXcodeProject(config, config => {\n config.modResults = setGoogleServicesFile(config, {\n projectRoot: config.modRequest.projectRoot,\n project: config.modResults,\n });\n return config;\n });\n};\n\nfunction readGoogleServicesInfoPlist(\n relativePath: string,\n { projectRoot }: { projectRoot: string }\n) {\n const googleServiceFilePath = path.resolve(projectRoot, relativePath);\n const contents = fs.readFileSync(googleServiceFilePath, 'utf8');\n assert(contents, 'GoogleService-Info.plist is empty');\n return plist.parse(contents);\n}\n\nexport function getGoogleSignInReservedClientId(\n config: Pick<ExpoConfig, 'ios'>,\n modRequest: Pick<ModProps<InfoPlist>, 'projectRoot'>\n): string | null {\n const reservedClientId = config.ios?.config?.googleSignIn?.reservedClientId ?? null;\n if (reservedClientId) {\n return reservedClientId;\n }\n\n const googleServicesFileRelativePath = getGoogleServicesFile(config);\n if (googleServicesFileRelativePath === null) {\n return null;\n }\n\n const infoPlist = readGoogleServicesInfoPlist(googleServicesFileRelativePath, modRequest);\n\n return infoPlist.REVERSED_CLIENT_ID ?? null;\n}\n\nexport function getGoogleServicesFile(config: Pick<ExpoConfig, 'ios'>) {\n return config.ios?.googleServicesFile ?? null;\n}\n\nexport function setGoogleSignInReservedClientId(\n config: Pick<ExpoConfig, 'ios'>,\n infoPlist: InfoPlist,\n modRequest: Pick<ModProps<InfoPlist>, 'projectRoot'>\n): InfoPlist {\n const reservedClientId = getGoogleSignInReservedClientId(config, modRequest);\n\n if (reservedClientId === null) {\n return infoPlist;\n }\n\n return appendScheme(reservedClientId, infoPlist);\n}\n\nexport function setGoogleConfig(\n config: Pick<ExpoConfig, 'ios'>,\n infoPlist: InfoPlist,\n modRequest: ModProps<InfoPlist>\n): InfoPlist {\n infoPlist = setGoogleSignInReservedClientId(config, infoPlist, modRequest);\n return infoPlist;\n}\n\nexport function setGoogleServicesFile(\n config: Pick<ExpoConfig, 'ios'>,\n { projectRoot, project }: { project: XcodeProject; projectRoot: string }\n): XcodeProject {\n const googleServicesFileRelativePath = getGoogleServicesFile(config);\n if (googleServicesFileRelativePath === null) {\n return project;\n }\n\n const googleServiceFilePath = path.resolve(projectRoot, googleServicesFileRelativePath);\n fs.copyFileSync(\n googleServiceFilePath,\n path.join(getSourceRoot(projectRoot), 'GoogleService-Info.plist')\n );\n\n const projectName = getProjectName(projectRoot);\n const plistFilePath = `${projectName}/GoogleService-Info.plist`;\n if (!project.hasFile(plistFilePath)) {\n project = addResourceFileToGroup({\n filepath: plistFilePath,\n groupName: projectName,\n project,\n isBuildFile: true,\n verbose: true,\n });\n }\n return project;\n}\n"],"file":"Google.js"}
@@ -18,10 +18,10 @@ function _jsonFile() {
18
18
  return data;
19
19
  }
20
20
 
21
- function fs() {
22
- const data = _interopRequireWildcard(require("fs-extra"));
21
+ function _fs() {
22
+ const data = _interopRequireDefault(require("fs"));
23
23
 
24
- fs = function () {
24
+ _fs = function () {
25
25
  return data;
26
26
  };
27
27
 
@@ -68,10 +68,6 @@ function _Xcodeproj() {
68
68
  return data;
69
69
  }
70
70
 
71
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
72
-
73
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
74
-
75
71
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
76
72
 
77
73
  const withLocales = config => {
@@ -110,8 +106,11 @@ async function setLocalesAsync(config, {
110
106
  const stringName = 'InfoPlist.strings';
111
107
 
112
108
  for (const [lang, localizationObj] of Object.entries(localesMap)) {
113
- const dir = (0, _path().join)(supportingDirectory, `${lang}.lproj`);
114
- await fs().ensureDir(dir);
109
+ const dir = (0, _path().join)(supportingDirectory, `${lang}.lproj`); // await fs.ensureDir(dir);
110
+
111
+ await _fs().default.promises.mkdir(dir, {
112
+ recursive: true
113
+ });
115
114
  const strings = (0, _path().join)(dir, stringName);
116
115
  const buffer = [];
117
116
 
@@ -120,17 +119,18 @@ async function setLocalesAsync(config, {
120
119
  } // Write the file to the file system.
121
120
 
122
121
 
123
- await fs().writeFile(strings, buffer.join('\n')); // deep find the correct folder
122
+ await _fs().default.promises.writeFile(strings, buffer.join('\n'));
123
+ const groupName = `${projectName}/Supporting/${lang}.lproj`; // deep find the correct folder
124
124
 
125
- const group = (0, _Xcodeproj().ensureGroupRecursively)(project, `${projectName}/Supporting/${lang}.lproj`); // Ensure the file doesn't already exist
125
+ const group = (0, _Xcodeproj().ensureGroupRecursively)(project, groupName); // Ensure the file doesn't already exist
126
126
 
127
127
  if (!(group !== null && group !== void 0 && group.children.some(({
128
128
  comment
129
129
  }) => comment === stringName))) {
130
130
  // Only write the file if it doesn't already exist.
131
131
  project = (0, _Xcodeproj().addResourceFileToGroup)({
132
- filepath: strings,
133
- groupName: `${projectName}/Supporting/${lang}.lproj`,
132
+ filepath: (0, _path().relative)(supportingDirectory, strings),
133
+ groupName,
134
134
  project,
135
135
  isBuildFile: true,
136
136
  verbose: true
@@ -148,7 +148,7 @@ async function getResolvedLocalesAsync(projectRoot, input) {
148
148
  if (typeof localeJsonPath === 'string') {
149
149
  try {
150
150
  locales[lang] = await _jsonFile().default.readAsync((0, _path().join)(projectRoot, localeJsonPath));
151
- } catch (e) {
151
+ } catch {
152
152
  // Add a warning when a json file cannot be parsed.
153
153
  (0, _warnings().addWarningIOS)(`locales.${lang}`, `Failed to parse JSON of locale file for language: ${lang}`, 'https://docs.expo.dev/distribution/app-stores/#localizing-your-ios-app');
154
154
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ios/Locales.ts"],"names":["withLocales","config","modResults","setLocalesAsync","projectRoot","modRequest","project","getLocales","locales","localesMap","getResolvedLocalesAsync","projectName","supportingDirectory","stringName","lang","localizationObj","Object","entries","dir","fs","ensureDir","strings","buffer","plistKey","localVersion","push","writeFile","join","group","children","some","comment","filepath","groupName","isBuildFile","verbose","input","localeJsonPath","JsonFile","readAsync","e"],"mappings":";;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAA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;AAC1D,QAAI,OAAOC,cAAP,KAA0B,QAA9B,EAAwC;AACtC,UAAI;AACF7B,QAAAA,OAAO,CAACM,IAAD,CAAP,GAAgB,MAAMwB,oBAASC,SAAT,CAAmB,kBAAKnC,WAAL,EAAkBiC,cAAlB,CAAnB,CAAtB;AACD,OAFD,CAEE,OAAOG,CAAP,EAAU;AACV;AACA,uCACG,WAAU1B,IAAK,EADlB,EAEG,qDAAoDA,IAAK,EAF5D,EAGE,wEAHF;AAKD;AACF,KAXD,MAWO;AACL;AACA;AACAN,MAAAA,OAAO,CAACM,IAAD,CAAP,GAAgBuB,cAAhB;AACD;AACF;;AAED,SAAO7B,OAAP;AACD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport JsonFile from '@expo/json-file';\nimport * as fs from 'fs-extra';\nimport { join } from 'path';\nimport { XcodeProject } from 'xcode';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withXcodeProject } from '../plugins/ios-plugins';\nimport { addWarningIOS } from '../utils/warnings';\nimport { addResourceFileToGroup, ensureGroupRecursively, getProjectName } from './utils/Xcodeproj';\n\ntype LocaleJson = Record<string, string>;\ntype ResolvedLocalesJson = Record<string, LocaleJson>;\ntype ExpoConfigLocales = NonNullable<ExpoConfig['locales']>;\n\nexport const withLocales: ConfigPlugin = config => {\n return withXcodeProject(config, async config => {\n config.modResults = await setLocalesAsync(config, {\n projectRoot: config.modRequest.projectRoot,\n project: config.modResults,\n });\n return config;\n });\n};\n\nexport function getLocales(\n config: Pick<ExpoConfig, 'locales'>\n): Record<string, string | LocaleJson> | null {\n return config.locales ?? null;\n}\n\nexport async function setLocalesAsync(\n config: Pick<ExpoConfig, 'locales'>,\n { projectRoot, project }: { projectRoot: string; project: XcodeProject }\n): Promise<XcodeProject> {\n const locales = getLocales(config);\n if (!locales) {\n return project;\n }\n // possibly validate CFBundleAllowMixedLocalizations is enabled\n const localesMap = await getResolvedLocalesAsync(projectRoot, locales);\n\n const projectName = getProjectName(projectRoot);\n const supportingDirectory = join(projectRoot, 'ios', projectName, 'Supporting');\n\n // TODO: Should we delete all before running? Revisit after we land on a lock file.\n const stringName = 'InfoPlist.strings';\n\n for (const [lang, localizationObj] of Object.entries(localesMap)) {\n const dir = join(supportingDirectory, `${lang}.lproj`);\n await fs.ensureDir(dir);\n const strings = join(dir, stringName);\n const buffer = [];\n for (const [plistKey, localVersion] of Object.entries(localizationObj)) {\n buffer.push(`${plistKey} = \"${localVersion}\";`);\n }\n // Write the file to the file system.\n await fs.writeFile(strings, buffer.join('\\n'));\n\n // deep find the correct folder\n const group = ensureGroupRecursively(project, `${projectName}/Supporting/${lang}.lproj`);\n\n // Ensure the file doesn't already exist\n if (!group?.children.some(({ comment }) => comment === stringName)) {\n // Only write the file if it doesn't already exist.\n project = addResourceFileToGroup({\n filepath: strings,\n groupName: `${projectName}/Supporting/${lang}.lproj`,\n project,\n isBuildFile: true,\n verbose: true,\n });\n }\n }\n\n return project;\n}\n\nexport async function getResolvedLocalesAsync(\n projectRoot: string,\n input: ExpoConfigLocales\n): Promise<ResolvedLocalesJson> {\n const locales: ResolvedLocalesJson = {};\n for (const [lang, localeJsonPath] of Object.entries(input)) {\n if (typeof localeJsonPath === 'string') {\n try {\n locales[lang] = await JsonFile.readAsync(join(projectRoot, localeJsonPath));\n } catch (e) {\n // Add a warning when a json file cannot be parsed.\n addWarningIOS(\n `locales.${lang}`,\n `Failed to parse JSON of locale file for language: ${lang}`,\n 'https://docs.expo.dev/distribution/app-stores/#localizing-your-ios-app'\n );\n }\n } else {\n // In the off chance that someone defined the locales json in the config, pass it directly to the object.\n // We do this to make the types more elegant.\n locales[lang] = localeJsonPath;\n }\n }\n\n return locales;\n}\n"],"file":"Locales.js"}
1
+ {"version":3,"sources":["../../src/ios/Locales.ts"],"names":["withLocales","config","modResults","setLocalesAsync","projectRoot","modRequest","project","getLocales","locales","localesMap","getResolvedLocalesAsync","projectName","supportingDirectory","stringName","lang","localizationObj","Object","entries","dir","fs","promises","mkdir","recursive","strings","buffer","plistKey","localVersion","push","writeFile","join","groupName","group","children","some","comment","filepath","isBuildFile","verbose","input","localeJsonPath","JsonFile","readAsync"],"mappings":";;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAMO,MAAMA,WAAyB,GAAGC,MAAM,IAAI;AACjD,SAAO,oCAAiBA,MAAjB,EAAyB,MAAMA,MAAN,IAAgB;AAC9CA,IAAAA,MAAM,CAACC,UAAP,GAAoB,MAAMC,eAAe,CAACF,MAAD,EAAS;AAChDG,MAAAA,WAAW,EAAEH,MAAM,CAACI,UAAP,CAAkBD,WADiB;AAEhDE,MAAAA,OAAO,EAAEL,MAAM,CAACC;AAFgC,KAAT,CAAzC;AAIA,WAAOD,MAAP;AACD,GANM,CAAP;AAOD,CARM;;;;AAUA,SAASM,UAAT,CACLN,MADK,EAEuC;AAAA;;AAC5C,4BAAOA,MAAM,CAACO,OAAd,6DAAyB,IAAzB;AACD;;AAEM,eAAeL,eAAf,CACLF,MADK,EAEL;AAAEG,EAAAA,WAAF;AAAeE,EAAAA;AAAf,CAFK,EAGkB;AACvB,QAAME,OAAO,GAAGD,UAAU,CAACN,MAAD,CAA1B;;AACA,MAAI,CAACO,OAAL,EAAc;AACZ,WAAOF,OAAP;AACD,GAJsB,CAKvB;;;AACA,QAAMG,UAAU,GAAG,MAAMC,uBAAuB,CAACN,WAAD,EAAcI,OAAd,CAAhD;AAEA,QAAMG,WAAW,GAAG,iCAAeP,WAAf,CAApB;AACA,QAAMQ,mBAAmB,GAAG,kBAAKR,WAAL,EAAkB,KAAlB,EAAyBO,WAAzB,EAAsC,YAAtC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I/B8B,QAAAA,WAAW,EAAE,IAJkB;AAK/BC,QAAAA,OAAO,EAAE;AALsB,OAAvB,CAAV;AAOD;AACF;;AAED,SAAO/B,OAAP;AACD;;AAEM,eAAeI,uBAAf,CACLN,WADK,EAELkC,KAFK,EAGyB;AAC9B,QAAM9B,OAA4B,GAAG,EAArC;;AACA,OAAK,MAAM,CAACM,IAAD,EAAOyB,cAAP,CAAX,IAAqCvB,MAAM,CAACC,OAAP,CAAeqB,KAAf,CAArC,EAA4D;AAC1D,QAAI,OAAOC,cAAP,KAA0B,QAA9B,EAAwC;AACtC,UAAI;AACF/B,QAAAA,OAAO,CAACM,IAAD,CAAP,GAAgB,MAAM0B,oBAASC,SAAT,CAAmB,kBAAKrC,WAAL,EAAkBmC,cAAlB,CAAnB,CAAtB;AACD,OAFD,CAEE,MAAM;AACN;AACA,uCACG,WAAUzB,IAAK,EADlB,EAEG,qDAAoDA,IAAK,EAF5D,EAGE,wEAHF;AAKD;AACF,KAXD,MAWO;AACL;AACA;AACAN,MAAAA,OAAO,CAACM,IAAD,CAAP,GAAgByB,cAAhB;AACD;AACF;;AAED,SAAO/B,OAAP;AACD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport JsonFile from '@expo/json-file';\nimport fs from 'fs';\nimport { join, relative } from 'path';\nimport { XcodeProject } from 'xcode';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withXcodeProject } from '../plugins/ios-plugins';\nimport { addWarningIOS } from '../utils/warnings';\nimport { addResourceFileToGroup, ensureGroupRecursively, getProjectName } from './utils/Xcodeproj';\n\ntype LocaleJson = Record<string, string>;\ntype ResolvedLocalesJson = Record<string, LocaleJson>;\ntype ExpoConfigLocales = NonNullable<ExpoConfig['locales']>;\n\nexport const withLocales: ConfigPlugin = config => {\n return withXcodeProject(config, async config => {\n config.modResults = await setLocalesAsync(config, {\n projectRoot: config.modRequest.projectRoot,\n project: config.modResults,\n });\n return config;\n });\n};\n\nexport function getLocales(\n config: Pick<ExpoConfig, 'locales'>\n): Record<string, string | LocaleJson> | null {\n return config.locales ?? null;\n}\n\nexport async function setLocalesAsync(\n config: Pick<ExpoConfig, 'locales'>,\n { projectRoot, project }: { projectRoot: string; project: XcodeProject }\n): Promise<XcodeProject> {\n const locales = getLocales(config);\n if (!locales) {\n return project;\n }\n // possibly validate CFBundleAllowMixedLocalizations is enabled\n const localesMap = await getResolvedLocalesAsync(projectRoot, locales);\n\n const projectName = getProjectName(projectRoot);\n const supportingDirectory = join(projectRoot, 'ios', projectName, 'Supporting');\n\n // TODO: Should we delete all before running? Revisit after we land on a lock file.\n const stringName = 'InfoPlist.strings';\n\n for (const [lang, localizationObj] of Object.entries(localesMap)) {\n const dir = join(supportingDirectory, `${lang}.lproj`);\n // await fs.ensureDir(dir);\n await fs.promises.mkdir(dir, { recursive: true });\n\n const strings = join(dir, stringName);\n const buffer = [];\n for (const [plistKey, localVersion] of Object.entries(localizationObj)) {\n buffer.push(`${plistKey} = \"${localVersion}\";`);\n }\n // Write the file to the file system.\n await fs.promises.writeFile(strings, buffer.join('\\n'));\n\n const groupName = `${projectName}/Supporting/${lang}.lproj`;\n // deep find the correct folder\n const group = ensureGroupRecursively(project, groupName);\n\n // Ensure the file doesn't already exist\n if (!group?.children.some(({ comment }) => comment === stringName)) {\n // Only write the file if it doesn't already exist.\n project = addResourceFileToGroup({\n filepath: relative(supportingDirectory, strings),\n groupName,\n project,\n isBuildFile: true,\n verbose: true,\n });\n }\n }\n\n return project;\n}\n\nexport async function getResolvedLocalesAsync(\n projectRoot: string,\n input: ExpoConfigLocales\n): Promise<ResolvedLocalesJson> {\n const locales: ResolvedLocalesJson = {};\n for (const [lang, localeJsonPath] of Object.entries(input)) {\n if (typeof localeJsonPath === 'string') {\n try {\n locales[lang] = await JsonFile.readAsync(join(projectRoot, localeJsonPath));\n } catch {\n // Add a warning when a json file cannot be parsed.\n addWarningIOS(\n `locales.${lang}`,\n `Failed to parse JSON of locale file for language: ${lang}`,\n 'https://docs.expo.dev/distribution/app-stores/#localizing-your-ios-app'\n );\n }\n } else {\n // In the off chance that someone defined the locales json in the config, pass it directly to the object.\n // We do this to make the types more elegant.\n locales[lang] = localeJsonPath;\n }\n }\n\n return locales;\n}\n"],"file":"Locales.js"}