@expo/config-plugins 4.1.0 → 4.1.3

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 (80) 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.d.ts +7 -0
  10. package/build/android/Manifest.js +43 -5
  11. package/build/android/Manifest.js.map +1 -1
  12. package/build/android/Package.js +27 -15
  13. package/build/android/Package.js.map +1 -1
  14. package/build/android/Paths.js +6 -6
  15. package/build/android/Paths.js.map +1 -1
  16. package/build/android/Permissions.d.ts +3 -1
  17. package/build/android/Permissions.js +42 -28
  18. package/build/android/Permissions.js.map +1 -1
  19. package/build/android/codeMod.js +1 -1
  20. package/build/android/codeMod.js.map +1 -1
  21. package/build/android/index.d.ts +2 -2
  22. package/build/android/index.js +18 -18
  23. package/build/android/index.js.map +1 -1
  24. package/build/ios/BuildProperties.d.ts +27 -0
  25. package/build/ios/BuildProperties.js +83 -0
  26. package/build/ios/BuildProperties.js.map +1 -0
  27. package/build/ios/BuildScheme.js +6 -3
  28. package/build/ios/BuildScheme.js.map +1 -1
  29. package/build/ios/BundleIdentifier.js +6 -6
  30. package/build/ios/BundleIdentifier.js.map +1 -1
  31. package/build/ios/Entitlements.d.ts +5 -1
  32. package/build/ios/Entitlements.js +63 -52
  33. package/build/ios/Entitlements.js.map +1 -1
  34. package/build/ios/Google.js +5 -5
  35. package/build/ios/Google.js.map +1 -1
  36. package/build/ios/Locales.js +14 -14
  37. package/build/ios/Locales.js.map +1 -1
  38. package/build/ios/Maps.js +5 -5
  39. package/build/ios/Maps.js.map +1 -1
  40. package/build/ios/Paths.d.ts +1 -3
  41. package/build/ios/Paths.js +29 -24
  42. package/build/ios/Paths.js.map +1 -1
  43. package/build/ios/ProvisioningProfile.js +4 -4
  44. package/build/ios/ProvisioningProfile.js.map +1 -1
  45. package/build/ios/Swift.js +5 -5
  46. package/build/ios/Swift.js.map +1 -1
  47. package/build/ios/Target.d.ts +1 -0
  48. package/build/ios/Target.js +11 -1
  49. package/build/ios/Target.js.map +1 -1
  50. package/build/ios/XcodeProjectFile.js +5 -5
  51. package/build/ios/XcodeProjectFile.js.map +1 -1
  52. package/build/ios/index.d.ts +2 -2
  53. package/build/ios/index.js +19 -19
  54. package/build/ios/index.js.map +1 -1
  55. package/build/ios/utils/Xcodeproj.d.ts +2 -1
  56. package/build/ios/utils/Xcodeproj.js +4 -1
  57. package/build/ios/utils/Xcodeproj.js.map +1 -1
  58. package/build/plugins/ios-plugins.d.ts +2 -2
  59. package/build/plugins/ios-plugins.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/XML.js +8 -6
  66. package/build/utils/XML.js.map +1 -1
  67. package/build/utils/fs.d.ts +4 -0
  68. package/build/utils/fs.js +56 -0
  69. package/build/utils/fs.js.map +1 -0
  70. package/build/utils/modules.js +1 -1
  71. package/build/utils/modules.js.map +1 -1
  72. package/build/utils/versions.js +2 -2
  73. package/build/utils/versions.js.map +1 -1
  74. package/package.json +3 -5
  75. package/build/android/JsEngine.d.ts +0 -8
  76. package/build/android/JsEngine.js +0 -59
  77. package/build/android/JsEngine.js.map +0 -1
  78. package/build/ios/JsEngine.d.ts +0 -8
  79. package/build/ios/JsEngine.js +0 -47
  80. package/build/ios/JsEngine.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ios/BuildProperties.ts"],"names":["createBuildPodfilePropsConfigPlugin","configToPropertyRules","name","withUnknown","config","sourceConfig","modResults","updateIosBuildPropertiesFromConfig","Object","defineProperty","value","withJsEnginePodfileProps","propName","propValueGetter","ios","jsEngine","podfileProperties","configToProperty","updateIosBuildProperty","options","removePropWhenValueIsNull"],"mappings":";;;;;;;;;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mCAAT,CACLC,qBADK,EAELC,IAFK,EAGL;AACA,QAAMC,WAAwF,GAAG,CAC/FC,MAD+F,EAE/FC,YAF+F,KAI/F,yCAAsBD,MAAtB,EAA8BA,MAAM,IAAI;AACtCA,IAAAA,MAAM,CAACE,UAAP,GAAoBC,kCAAkC,CACnDF,YADmD,aACnDA,YADmD,cACnDA,YADmD,GACnCD,MADmC,EAEpDA,MAAM,CAACE,UAF6C,EAGpDL,qBAHoD,CAAtD;AAKA,WAAOG,MAAP;AACD,GAPD,CAJF;;AAYA,MAAIF,IAAJ,EAAU;AACRM,IAAAA,MAAM,CAACC,cAAP,CAAsBN,WAAtB,EAAmC,MAAnC,EAA2C;AACzCO,MAAAA,KAAK,EAAER;AADkC,KAA3C;AAGD;;AACD,SAAOC,WAAP;AACD;AAED;AACA;AACA;;;AACO,MAAMQ,wBAAwB,GAAGX,mCAAmC,CACzE,CACE;AACEY,EAAAA,QAAQ,EAAE,eADZ;AAEEC,EAAAA,eAAe,EAAET,MAAM;AAAA;;AAAA,0DAAIA,MAAM,CAACU,GAAX,gDAAI,YAAYC,QAAhB,uEAA4BX,MAAM,CAACW,QAAnC,uCAA+C,KAA/C;AAAA;AAFzB,CADF,CADyE,EAOzE,0BAPyE,CAApE;;;AAUA,SAASR,kCAAT,CACLH,MADK,EAELY,iBAFK,EAGLf,qBAHK,EAIL;AACA,OAAK,MAAMgB,gBAAX,IAA+BhB,qBAA/B,EAAsD;AACpD,UAAMS,KAAK,GAAGO,gBAAgB,CAACJ,eAAjB,CAAiCT,MAAjC,CAAd;AACAc,IAAAA,sBAAsB,CAACF,iBAAD,EAAoBC,gBAAgB,CAACL,QAArC,EAA+CF,KAA/C,CAAtB;AACD;;AACD,SAAOM,iBAAP;AACD;;AAEM,SAASE,sBAAT,CACLF,iBADK,EAELd,IAFK,EAGLQ,KAHK,EAILS,OAJK,EAKL;AACA,MAAIT,KAAJ,EAAW;AACTM,IAAAA,iBAAiB,CAACd,IAAD,CAAjB,GAA0BQ,KAA1B;AACD,GAFD,MAEO,IAAIS,OAAJ,aAAIA,OAAJ,eAAIA,OAAO,CAAEC,yBAAb,EAAwC;AAC7C,WAAOJ,iBAAiB,CAACd,IAAD,CAAxB;AACD;;AACD,SAAOc,iBAAP;AACD","sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { ConfigPlugin } from '../Plugin.types';\nimport { withPodfileProperties } from '../plugins/ios-plugins';\nimport { BuildPropertiesConfig, ConfigToPropertyRuleType } from '../utils/BuildProperties.types';\n\n/**\n * Creates a `withPodfileProperties` config-plugin based on given config to property mapping rules.\n *\n * The factory supports two modes from generic type inference\n * ```ts\n * // config-plugin without `props`, it will implicitly use the expo config as source config.\n * createBuildPodfilePropsConfigPlugin<ExpoConfig>(): ConfigPlugin<void>;\n *\n * // config-plugin with a parameter `props: CustomType`, it will use the `props` as source config.\n * createBuildPodfilePropsConfigPlugin<CustomType>(): ConfigPlugin<CustomType>;\n * ```\n *\n * @param configToPropertyRules config to property mapping rules\n * @param name the config plugin name\n */\nexport function createBuildPodfilePropsConfigPlugin<SourceConfigType extends BuildPropertiesConfig>(\n configToPropertyRules: ConfigToPropertyRuleType<SourceConfigType>[],\n name?: string\n) {\n const withUnknown: ConfigPlugin<SourceConfigType extends ExpoConfig ? void : SourceConfigType> = (\n config,\n sourceConfig\n ) =>\n withPodfileProperties(config, config => {\n config.modResults = updateIosBuildPropertiesFromConfig(\n (sourceConfig ?? config) as SourceConfigType,\n config.modResults,\n configToPropertyRules\n );\n return config;\n });\n if (name) {\n Object.defineProperty(withUnknown, 'name', {\n value: name,\n });\n }\n return withUnknown;\n}\n\n/**\n * A config-plugin to update `ios/Podfile.properties.json` from the `jsEngine` in expo config\n */\nexport const withJsEnginePodfileProps = createBuildPodfilePropsConfigPlugin<ExpoConfig>(\n [\n {\n propName: 'expo.jsEngine',\n propValueGetter: config => config.ios?.jsEngine ?? config.jsEngine ?? 'jsc',\n },\n ],\n 'withJsEnginePodfileProps'\n);\n\nexport function updateIosBuildPropertiesFromConfig<SourceConfigType extends BuildPropertiesConfig>(\n config: SourceConfigType,\n podfileProperties: Record<string, string>,\n configToPropertyRules: ConfigToPropertyRuleType<SourceConfigType>[]\n) {\n for (const configToProperty of configToPropertyRules) {\n const value = configToProperty.propValueGetter(config);\n updateIosBuildProperty(podfileProperties, configToProperty.propName, value);\n }\n return podfileProperties;\n}\n\nexport function updateIosBuildProperty(\n podfileProperties: Record<string, string>,\n name: string,\n value: string | null | undefined,\n options?: { removePropWhenValueIsNull?: boolean }\n) {\n if (value) {\n podfileProperties[name] = value;\n } else if (options?.removePropWhenValueIsNull) {\n delete podfileProperties[name];\n }\n return podfileProperties;\n}\n"],"file":"BuildProperties.js"}
@@ -60,7 +60,12 @@ function getRunnableSchemesFromXcodeproj(projectRoot, {
60
60
  let osType = 'iOS';
61
61
  const type = (0, _Xcodeproj().unquote)(target.productType);
62
62
 
63
- if (type === _Target().TargetType.APPLICATION) {
63
+ if (type === _Target().TargetType.WATCH) {
64
+ osType = 'watchOS';
65
+ } else if ( // (apps) com.apple.product-type.application
66
+ // (app clips) com.apple.product-type.application.on-demand-install-capable
67
+ // NOTE(EvanBacon): This matches against `watchOS` as well so we check for watch first.
68
+ type.startsWith(_Target().TargetType.APPLICATION)) {
64
69
  // Attempt to resolve the platform SDK for each target so we can filter devices.
65
70
  const xcConfigurationList = project.hash.project.objects.XCConfigurationList[target.buildConfigurationList];
66
71
 
@@ -81,8 +86,6 @@ function getRunnableSchemesFromXcodeproj(projectRoot, {
81
86
  }
82
87
  }
83
88
  }
84
- } else if (type === _Target().TargetType.WATCH) {
85
- osType = 'watchOS';
86
89
  }
87
90
 
88
91
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ios/BuildScheme.ts"],"names":["getSchemesFromXcodeproj","projectRoot","getRunnableSchemesFromXcodeproj","configuration","project","map","target","osType","type","productType","TargetType","APPLICATION","xcConfigurationList","hash","objects","XCConfigurationList","buildConfigurationList","buildConfiguration","buildConfigurations","find","value","comment","xcBuildConfiguration","XCBuildConfiguration","buildSdkRoot","buildSettings","SDKROOT","WATCH","name","readSchemeAsync","scheme","allSchemePaths","re","RegExp","schemePath","i","exec","path","Error","getApplicationTargetNameForSchemeAsync","schemeXML","buildActionEntry","Scheme","BuildAction","BuildActionEntries","BuildActionEntry","targetName","length","getBlueprintName","entry","BuildableReference","BuildableName","endsWith","getArchiveBuildConfigurationForSchemeAsync","ArchiveAction","BlueprintName"],"mappings":";;;;;;;;;;AAAA;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;;AA0BO,SAASA,uBAAT,CAAiCC,WAAjC,EAAgE;AACrE,SAAO,8BAAgBA,WAAhB,CAAP;AACD;;AAEM,SAASC,+BAAT,CACLD,WADK,EAEL;AAAEE,EAAAA,aAAa,GAAG;AAAlB,IAAuE,EAFlE,EAG6C;AAClD,QAAMC,OAAO,GAAG,6BAAWH,WAAX,CAAhB;AAEA,SAAO,mCAAoBG,OAApB,EAA6BC,GAA7B,CAAiC,CAAC,GAAGC,MAAH,CAAD,KAAgB;AACtD,QAAIC,MAAM,GAAG,KAAb;AACA,UAAMC,IAAI,GAAG,0BAAQF,MAAM,CAACG,WAAf,CAAb;;AAEA,QAAID,IAAI,KAAKE,qBAAWC,WAAxB,EAAqC;A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AN;AACD;;AACD,SAAOgB,UAAP;AACD;;AAEM,eAAeO,0CAAf,CACLpD,WADK,EAEL6B,MAFK,EAGY;AAAA;;AACjB,QAAMU,SAAS,GAAG,MAAMX,eAAe,CAAC5B,WAAD,EAAc6B,MAAd,CAAvC;AACA,QAAMb,kBAAkB,GAAGuB,SAAH,aAAGA,SAAH,6CAAGA,SAAS,CAAEE,MAAd,gFAAG,mBAAmBY,aAAtB,oFAAG,sBAAmC,CAAnC,CAAH,qFAAG,uBAAwC,GAAxC,CAAH,2DAAG,uBAA8CrC,kBAAzE;;AACA,MAAI,CAACA,kBAAL,EAAyB;AACvB,UAAM,IAAIqB,KAAJ,CAAW,GAAER,MAAO,iCAApB,CAAN;AACD;;AACD,SAAOb,kBAAP;AACD;;AAED,SAAS+B,gBAAT,CAA0BC,KAA1B,EAA4E;AAAA;;AAC1E,SAAOA,KAAP,aAAOA,KAAP,iDAAOA,KAAK,CAAEC,kBAAd,qFAAO,uBAA4B,CAA5B,CAAP,qFAAO,uBAAiC,GAAjC,CAAP,2DAAO,uBAAuCK,aAA9C;AACD","sourcesContent":["import { readXMLAsync } from '../utils/XML';\nimport { findSchemeNames, findSchemePaths } from './Paths';\nimport { findSignableTargets, TargetType } from './Target';\nimport { getPbxproj, unquote } from './utils/Xcodeproj';\n\ninterface SchemeXML {\n Scheme?: {\n BuildAction?: {\n BuildActionEntries?: {\n BuildActionEntry?: BuildActionEntryType[];\n }[];\n }[];\n ArchiveAction?: {\n $?: {\n buildConfiguration?: string;\n };\n }[];\n };\n}\n\ninterface BuildActionEntryType {\n BuildableReference?: {\n $?: {\n BlueprintName?: string;\n BuildableName?: string;\n };\n }[];\n}\n\nexport function getSchemesFromXcodeproj(projectRoot: string): string[] {\n return findSchemeNames(projectRoot);\n}\n\nexport function getRunnableSchemesFromXcodeproj(\n projectRoot: string,\n { configuration = 'Debug' }: { configuration?: 'Debug' | 'Release' } = {}\n): { name: string; osType: string; type: string }[] {\n const project = getPbxproj(projectRoot);\n\n return findSignableTargets(project).map(([, target]) => {\n let osType = 'iOS';\n const type = unquote(target.productType);\n\n if (type === TargetType.APPLICATION) {\n // Attempt to resolve the platform SDK for each target so we can filter devices.\n const xcConfigurationList =\n project.hash.project.objects.XCConfigurationList[target.buildConfigurationList];\n\n if (xcConfigurationList) {\n const buildConfiguration =\n xcConfigurationList.buildConfigurations.find(\n (value: { comment: string; value: string }) => value.comment === configuration\n ) || xcConfigurationList.buildConfigurations[0];\n if (buildConfiguration?.value) {\n const xcBuildConfiguration =\n project.hash.project.objects.XCBuildConfiguration?.[buildConfiguration.value];\n\n const buildSdkRoot = xcBuildConfiguration.buildSettings.SDKROOT;\n if (\n buildSdkRoot === 'appletvos' ||\n 'TVOS_DEPLOYMENT_TARGET' in xcBuildConfiguration.buildSettings\n ) {\n // Is a TV app...\n osType = 'tvOS';\n } else if (buildSdkRoot === 'iphoneos') {\n osType = 'iOS';\n }\n }\n }\n } else if (type === TargetType.WATCH) {\n osType = 'watchOS';\n }\n\n return {\n name: unquote(target.name),\n osType,\n type: unquote(target.productType),\n };\n });\n}\n\nasync function readSchemeAsync(\n projectRoot: string,\n scheme: string\n): Promise<SchemeXML | undefined> {\n const allSchemePaths = findSchemePaths(projectRoot);\n const re = new RegExp(`/${scheme}.xcscheme`, 'i');\n const schemePath = allSchemePaths.find(i => re.exec(i));\n if (schemePath) {\n return ((await readXMLAsync({ path: schemePath })) as unknown) as SchemeXML | undefined;\n } else {\n throw new Error(`scheme '${scheme}' does not exist, make sure it's marked as shared`);\n }\n}\n\nexport async function getApplicationTargetNameForSchemeAsync(\n projectRoot: string,\n scheme: string\n): Promise<string> {\n const schemeXML = await readSchemeAsync(projectRoot, scheme);\n const buildActionEntry =\n schemeXML?.Scheme?.BuildAction?.[0]?.BuildActionEntries?.[0]?.BuildActionEntry;\n const targetName =\n buildActionEntry?.length === 1\n ? getBlueprintName(buildActionEntry[0])\n : getBlueprintName(\n buildActionEntry?.find(entry => {\n return entry.BuildableReference?.[0]?.['$']?.BuildableName?.endsWith('.app');\n })\n );\n if (!targetName) {\n throw new Error(`${scheme}.xcscheme seems to be corrupted`);\n }\n return targetName;\n}\n\nexport async function getArchiveBuildConfigurationForSchemeAsync(\n projectRoot: string,\n scheme: string\n): Promise<string> {\n const schemeXML = await readSchemeAsync(projectRoot, scheme);\n const buildConfiguration = schemeXML?.Scheme?.ArchiveAction?.[0]?.['$']?.buildConfiguration;\n if (!buildConfiguration) {\n throw new Error(`${scheme}.xcscheme seems to be corrupted`);\n }\n return buildConfiguration;\n}\n\nfunction getBlueprintName(entry?: BuildActionEntryType): string | undefined {\n return entry?.BuildableReference?.[0]?.['$']?.BlueprintName;\n}\n"],"file":"BuildScheme.js"}
1
+ {"version":3,"sources":["../../src/ios/BuildScheme.ts"],"names":["getSchemesFromXcodeproj","projectRoot","getRunnableSchemesFromXcodeproj","configuration","project","map","target","osType","type","productType","TargetType","WATCH","startsWith","APPLICATION","xcConfigurationList","hash","objects","XCConfigurationList","buildConfigurationList","buildConfiguration","buildConfigurations","find","value","comment","xcBuildConfiguration","XCBuildConfiguration","buildSdkRoot","buildSettings","SDKROOT","name","readSchemeAsync","scheme","allSchemePaths","re","RegExp","schemePath","i","exec","path","Error","getApplicationTargetNameForSchemeAsync","schemeXML","buildActionEntry","Scheme","BuildAction","BuildActionEntries","BuildActionEntry","targetName","length","getBlueprintName","entry","BuildableReference","BuildableName","endsWith","getArchiveBuildConfigurationForSchemeAsync","ArchiveAction","BlueprintName"],"mappings":";;;;;;;;;;AAAA;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;;AA0BO,SAASA,uBAAT,CAAiCC,WAAjC,EAAgE;AACrE,SAAO,8BAAgBA,WAAhB,CAAP;AACD;;AAEM,SAASC,+BAAT,CACLD,WADK,EAEL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B,CACdP,gBADc,aACdA,gBADc,uBACdA,gBAAgB,CAAErB,IAAlB,CAAuB6B,KAAK,IAAI;AAAA;;AAC9B,oCAAOA,KAAK,CAACC,kBAAb,oFAAO,sBAA2B,CAA3B,CAAP,qFAAO,uBAAgC,GAAhC,CAAP,qFAAO,uBAAsCC,aAA7C,2DAAO,uBAAqDC,QAArD,CAA8D,MAA9D,CAAP;AACD,GAFD,CADc,CAHtB;;AAQA,MAAI,CAACN,UAAL,EAAiB;AACf,UAAM,IAAIR,KAAJ,CAAW,GAAER,MAAO,iCAApB,CAAN;AACD;;AACD,SAAOgB,UAAP;AACD;;AAEM,eAAeO,0CAAf,CACLrD,WADK,EAEL8B,MAFK,EAGY;AAAA;;AACjB,QAAMU,SAAS,GAAG,MAAMX,eAAe,CAAC7B,WAAD,EAAc8B,MAAd,CAAvC;AACA,QAAMZ,kBAAkB,GAAGsB,SAAH,aAAGA,SAAH,6CAAGA,SAAS,CAAEE,MAAd,gFAAG,mBAAmBY,aAAtB,oFAAG,sBAAmC,CAAnC,CAAH,qFAAG,uBAAwC,GAAxC,CAAH,2DAAG,uBAA8CpC,kBAAzE;;AACA,MAAI,CAACA,kBAAL,EAAyB;AACvB,UAAM,IAAIoB,KAAJ,CAAW,GAAER,MAAO,iCAApB,CAAN;AACD;;AACD,SAAOZ,kBAAP;AACD;;AAED,SAAS8B,gBAAT,CAA0BC,KAA1B,EAA4E;AAAA;;AAC1E,SAAOA,KAAP,aAAOA,KAAP,iDAAOA,KAAK,CAAEC,kBAAd,qFAAO,uBAA4B,CAA5B,CAAP,qFAAO,uBAAiC,GAAjC,CAAP,2DAAO,uBAAuCK,aAA9C;AACD","sourcesContent":["import { readXMLAsync } from '../utils/XML';\nimport { findSchemeNames, findSchemePaths } from './Paths';\nimport { findSignableTargets, TargetType } from './Target';\nimport { getPbxproj, unquote } from './utils/Xcodeproj';\n\ninterface SchemeXML {\n Scheme?: {\n BuildAction?: {\n BuildActionEntries?: {\n BuildActionEntry?: BuildActionEntryType[];\n }[];\n }[];\n ArchiveAction?: {\n $?: {\n buildConfiguration?: string;\n };\n }[];\n };\n}\n\ninterface BuildActionEntryType {\n BuildableReference?: {\n $?: {\n BlueprintName?: string;\n BuildableName?: string;\n };\n }[];\n}\n\nexport function getSchemesFromXcodeproj(projectRoot: string): string[] {\n return findSchemeNames(projectRoot);\n}\n\nexport function getRunnableSchemesFromXcodeproj(\n projectRoot: string,\n { configuration = 'Debug' }: { configuration?: 'Debug' | 'Release' } = {}\n): { name: string; osType: string; type: string }[] {\n const project = getPbxproj(projectRoot);\n\n return findSignableTargets(project).map(([, target]) => {\n let osType = 'iOS';\n const type = unquote(target.productType);\n\n if (type === TargetType.WATCH) {\n osType = 'watchOS';\n } else if (\n // (apps) com.apple.product-type.application\n // (app clips) com.apple.product-type.application.on-demand-install-capable\n // NOTE(EvanBacon): This matches against `watchOS` as well so we check for watch first.\n type.startsWith(TargetType.APPLICATION)\n ) {\n // Attempt to resolve the platform SDK for each target so we can filter devices.\n const xcConfigurationList =\n project.hash.project.objects.XCConfigurationList[target.buildConfigurationList];\n\n if (xcConfigurationList) {\n const buildConfiguration =\n xcConfigurationList.buildConfigurations.find(\n (value: { comment: string; value: string }) => value.comment === configuration\n ) || xcConfigurationList.buildConfigurations[0];\n if (buildConfiguration?.value) {\n const xcBuildConfiguration =\n project.hash.project.objects.XCBuildConfiguration?.[buildConfiguration.value];\n\n const buildSdkRoot = xcBuildConfiguration.buildSettings.SDKROOT;\n if (\n buildSdkRoot === 'appletvos' ||\n 'TVOS_DEPLOYMENT_TARGET' in xcBuildConfiguration.buildSettings\n ) {\n // Is a TV app...\n osType = 'tvOS';\n } else if (buildSdkRoot === 'iphoneos') {\n osType = 'iOS';\n }\n }\n }\n }\n\n return {\n name: unquote(target.name),\n osType,\n type: unquote(target.productType),\n };\n });\n}\n\nasync function readSchemeAsync(\n projectRoot: string,\n scheme: string\n): Promise<SchemeXML | undefined> {\n const allSchemePaths = findSchemePaths(projectRoot);\n const re = new RegExp(`/${scheme}.xcscheme`, 'i');\n const schemePath = allSchemePaths.find(i => re.exec(i));\n if (schemePath) {\n return ((await readXMLAsync({ path: schemePath })) as unknown) as SchemeXML | undefined;\n } else {\n throw new Error(`scheme '${scheme}' does not exist, make sure it's marked as shared`);\n }\n}\n\nexport async function getApplicationTargetNameForSchemeAsync(\n projectRoot: string,\n scheme: string\n): Promise<string> {\n const schemeXML = await readSchemeAsync(projectRoot, scheme);\n const buildActionEntry =\n schemeXML?.Scheme?.BuildAction?.[0]?.BuildActionEntries?.[0]?.BuildActionEntry;\n const targetName =\n buildActionEntry?.length === 1\n ? getBlueprintName(buildActionEntry[0])\n : getBlueprintName(\n buildActionEntry?.find(entry => {\n return entry.BuildableReference?.[0]?.['$']?.BuildableName?.endsWith('.app');\n })\n );\n if (!targetName) {\n throw new Error(`${scheme}.xcscheme seems to be corrupted`);\n }\n return targetName;\n}\n\nexport async function getArchiveBuildConfigurationForSchemeAsync(\n projectRoot: string,\n scheme: string\n): Promise<string> {\n const schemeXML = await readSchemeAsync(projectRoot, scheme);\n const buildConfiguration = schemeXML?.Scheme?.ArchiveAction?.[0]?.['$']?.buildConfiguration;\n if (!buildConfiguration) {\n throw new Error(`${scheme}.xcscheme seems to be corrupted`);\n }\n return buildConfiguration;\n}\n\nfunction getBlueprintName(entry?: BuildActionEntryType): string | undefined {\n return entry?.BuildableReference?.[0]?.['$']?.BlueprintName;\n}\n"],"file":"BuildScheme.js"}
@@ -32,10 +32,10 @@ function _assert() {
32
32
  return data;
33
33
  }
34
34
 
35
- function _fsExtra() {
36
- const data = _interopRequireDefault(require("fs-extra"));
35
+ function _fs() {
36
+ const data = _interopRequireDefault(require("fs"));
37
37
 
38
- _fsExtra = function () {
38
+ _fs = function () {
39
39
  return data;
40
40
  };
41
41
 
@@ -235,7 +235,7 @@ function updateBundleIdentifierForPbxproj(pbxprojPath, bundleIdentifier, updateP
235
235
  }
236
236
  });
237
237
 
238
- _fsExtra().default.writeFileSync(pbxprojPath, project.writeSync());
238
+ _fs().default.writeFileSync(pbxprojPath, project.writeSync());
239
239
  }
240
240
  /**
241
241
  * Updates the bundle identifier for pbx projects inside the ios directory of the given project root
@@ -274,7 +274,7 @@ function resetAllPlistBundleIdentifiers(projectRoot) {
274
274
  }
275
275
 
276
276
  function resetPlistBundleIdentifier(plistPath) {
277
- const rawPlist = _fsExtra().default.readFileSync(plistPath, 'utf8');
277
+ const rawPlist = _fs().default.readFileSync(plistPath, 'utf8');
278
278
 
279
279
  const plistObject = _plist().default.parse(rawPlist);
280
280
 
@@ -291,7 +291,7 @@ function resetPlistBundleIdentifier(plistPath) {
291
291
  }, format);
292
292
 
293
293
  if (xml !== rawPlist) {
294
- _fsExtra().default.writeFileSync(plistPath, xml);
294
+ _fs().default.writeFileSync(plistPath, xml);
295
295
  }
296
296
  }
297
297
  }
@@ -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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BAAd,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
+ {"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,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AAME,QAAQ,GAAGT,cAAGU,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,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;AAAA;;AAAA;AAAA;;;;;;;;AASO,MAAMA,qBAAqB,GAAG,4CACnCC,oBADmC,EAEnC,uBAFmC,CAA9B;;;AAKA,SAASA,oBAAT,CACLC,MADK,EAEL;AAAE,4CAA0CC,CAA5C;AAA+C,KAAGC;AAAlD,CAFK,EAGO;AAAA;;AACZ,qBAAIF,MAAM,CAACG,GAAX,wCAAI,YAAYC,iBAAhB,EAAmC;AACjC,WAAO,EACL,GAAGF,iBADE;AAEL,gDAA0CF,MAAM,CAACG,GAAP,CAAWC;AAFhD,KAAP;AAID;;AAED,SAAOF,iBAAP;AACD;;AAEM,SAASG,mBAAT,CAA6BC,WAA7B,EAA0D;AAC/D,QAAMC,KAAK,GAAGC,KAAK,GAACC,uBAAN,CAA8BH,WAA9B,CAAd;AACA,MAAII,UAAyB,GAAG,IAAhC;AAEA;AACF;AACA;;AACE,QAAMC,OAAO,GAAG,6BAAWL,WAAX,CAAhB;AACA,QAAMM,WAAW,GAAG,iCAAeN,WAAf,CAApB;AACA,QAAMO,WAAW,GAAG,iCAAeF,OAAf,CAApB,CAT+D,CAW/D;;AACA,QAAMG,wBAAwB,GAAG,sBAAMC,gBAAKC,IAAL,CAAUJ,WAAV,EAA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BAAyB,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;AAAA;AAAA;;AAAA;AAAA;;;;AAEO,MAAMA,qBAAqB,GAAG,4CACnCC,oBADmC,EAEnC,uBAFmC,CAA9B;;;AAKA,SAASA,oBAAT,CACLC,MADK,EAEL;AAAE,4CAA0CC,CAA5C;AAA+C,KAAGC;AAAlD,CAFK,EAGO;AAAA;;AACZ,qBAAIF,MAAM,CAACG,GAAX,wCAAI,YAAYC,iBAAhB,EAAmC;AACjC,WAAO,EACL,GAAGF,iBADE;AAEL,gDAA0CF,MAAM,CAACG,GAAP,CAAWC;AAFhD,KAAP;AAID;;AAED,SAAOF,iBAAP;AACD;;AAEM,SAASG,mBAAT,CACLC,WADK,EAEL;AACEC,EAAAA,UADF;AAEEC,EAAAA,kBAAkB,GAAG;AAFvB,IAG0D,EALrD,EAMU;AACf,QAAMC,OAAO,GAAG,6BAAWH,WAAX,CAAhB;AACA,QAAMI,oBAAoB,GAAG,kDAAmCD,OAAnC,EAA4C;AACvEF,IAAAA,UADuE;AAEvEC,IAAAA;AAFuE,GAA5C,CAA7B;;AAIA,MAAI,CAACE,oBAAL,EAA2B;AACzB,WAAO,IAAP;AACD;;AACD,QAAMC,gBAAgB,GAAGC,yCAAyC,CAChEN,WADgE,E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AgB,GAAGO,gBAAKC,SAAL,CACvBD,gBAAKE,IAAL,CAAUd,WAAV,EAAuB,KAAvB,EAA8BuB,wBAA9B,CADuB,CAAzB;;AAGAhB,kBAAGiB,SAAH,CAAaZ,gBAAKa,OAAL,CAAapB,gBAAb,CAAb,EAA6C;AAAEqB,MAAAA,SAAS,EAAE;AAAb,KAA7C;;AACA,QAAI,CAACnB,cAAGC,UAAH,CAAcH,gBAAd,CAAL,EAAsC;AACpCE,oBAAGoB,aAAH,CAAiBtB,gBAAjB,EAAmCuB,qBAAnC;AACD;;AACDxB,IAAAA,oBAAoB,CAACM,aAArB,CAAmCC,sBAAnC,GAA4DY,wBAA5D;AACD;;AACD,MAAIF,iBAAJ,EAAuB;AACrBd,kBAAGoB,aAAH,CAAiBxB,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"}
@@ -30,10 +30,10 @@ function _assert() {
30
30
  return data;
31
31
  }
32
32
 
33
- function _fsExtra() {
34
- const data = _interopRequireDefault(require("fs-extra"));
33
+ function _fs() {
34
+ const data = _interopRequireDefault(require("fs"));
35
35
 
36
- _fsExtra = function () {
36
+ _fs = function () {
37
37
  return data;
38
38
  };
39
39
 
@@ -118,7 +118,7 @@ function readGoogleServicesInfoPlist(relativePath, {
118
118
  }) {
119
119
  const googleServiceFilePath = _path().default.resolve(projectRoot, relativePath);
120
120
 
121
- const contents = _fsExtra().default.readFileSync(googleServiceFilePath, 'utf8');
121
+ const contents = _fs().default.readFileSync(googleServiceFilePath, 'utf8');
122
122
 
123
123
  (0, _assert().default)(contents, 'GoogleService-Info.plist is empty');
124
124
  return _plist().default.parse(contents);
@@ -176,7 +176,7 @@ function setGoogleServicesFile(config, {
176
176
 
177
177
  const googleServiceFilePath = _path().default.resolve(projectRoot, googleServicesFileRelativePath);
178
178
 
179
- _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'));
180
180
 
181
181
  const projectName = (0, _Xcodeproj().getProjectName)(projectRoot);
182
182
  const plistFilePath = `${projectName}/GoogleService-Info.plist`;
@@ -1 +1 @@
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;AAChD,SAAO,iCAAcA,MAAd,EAAsBA,MAAM,IAAI;AACrCA,IAAAA,MAAM,CAACC,UAAP,GAAoBC,eAAe,CAACF,MAAD,EAASA,MAAM,CAACC,UAAhB,EAA4BD,MAAM,CAACG,UAAnC,CAAnC;AACA,WAAOH,MAAP;AACD,GAHM,CAAP;AAID,CALM;;;;AAOA,MAAMI,sBAAoC,GAAGJ,MAAM,IAAI;AAC5D,SAAO,oCAAiBA,MAAjB,EAAyBA,MAAM,IAAI;AACxCA,IAAAA,MAAM,CAACC,UAAP,GAAoBI,qBAAqB,CAACL,MAAD,EAAS;AAChDM,MAAAA,WAAW,EAAEN,MAAM,CAACG,UAAP,CAAkBG,WADiB;AAEhDC,MAAAA,OAAO,EAAEP,MAAM,CAACC;AAFgC,KAAT,CAAzC;AAIA,WAAOD,MAAP;AACD,GANM,CAAP;AAOD,CARM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T,CACLF,MADK,EAELwB,SAFK,EAGLrB,UAHK,EAIM;AACXqB,EAAAA,SAAS,GAAGG,+BAA+B,CAAC3B,MAAD,EAASwB,SAAT,EAAoBrB,UAApB,CAA3C;AACA,SAAOqB,SAAP;AACD;;AAEM,SAASnB,qBAAT,CACLL,MADK,EAEL;AAAEM,EAAAA,WAAF;AAAeC,EAAAA;AAAf,CAFK,EAGS;AACd,QAAMe,8BAA8B,GAAGC,qBAAqB,CAACvB,MAAD,CAA5D;;AACA,MAAIsB,8BAA8B,KAAK,IAAvC,EAA6C;AAC3C,WAAOf,OAAP;AACD;;AAED,QAAMG,qBAAqB,GAAGC,gBAAKC,OAAL,CAAaN,WAAb,EAA0BgB,8BAA1B,CAA9B;;AACAR,qBAAGc,YAAH,CACElB,qBADF,EAEEC,gBAAKkB,IAAL,CAAU,4BAAcvB,WAAd,CAAV,EAAsC,0BAAtC,CAFF;;AAKA,QAAMwB,WAAW,GAAG,iCAAexB,WAAf,CAApB;AACA,QAAMyB,aAAa,GAAI,GAAED,WAAY,2BAArC;;AACA,MAAI,CAACvB,OAAO,CAACyB,OAAR,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-extra';\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"}
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;AAA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,GAAI,GAAED,WAAY,2BAArC;;AACA,MAAI,CAACvB,OAAO,CAACyB,OAAR,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;AAA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AAP,CAAX,IAAqCrB,MAAM,CAACC,OAAP,CAAemB,KAAf,CAArC,EAA4D;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,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,OAA9B,CADqB;AAE/BO,QAAAA,SAF+B;AAG/BxB,QAAAA,OAH+B;AAI/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"}