@expo/config-plugins 4.1.0 → 4.1.1
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.
- package/README.md +17 -2
- package/build/android/EasBuild.js +8 -8
- package/build/android/EasBuild.js.map +1 -1
- package/build/android/GoogleServices.js +16 -14
- package/build/android/GoogleServices.js.map +1 -1
- package/build/android/Manifest.js +7 -5
- package/build/android/Manifest.js.map +1 -1
- package/build/android/Package.js +26 -14
- package/build/android/Package.js.map +1 -1
- package/build/android/Paths.js +6 -6
- package/build/android/Paths.js.map +1 -1
- package/build/ios/BundleIdentifier.js +6 -6
- package/build/ios/BundleIdentifier.js.map +1 -1
- package/build/ios/Entitlements.js +20 -8
- package/build/ios/Entitlements.js.map +1 -1
- package/build/ios/Google.js +5 -5
- package/build/ios/Google.js.map +1 -1
- package/build/ios/Locales.js +13 -13
- package/build/ios/Locales.js.map +1 -1
- package/build/ios/Maps.js +5 -5
- package/build/ios/Maps.js.map +1 -1
- package/build/ios/Paths.js +17 -8
- package/build/ios/Paths.js.map +1 -1
- package/build/ios/ProvisioningProfile.js +4 -4
- package/build/ios/ProvisioningProfile.js.map +1 -1
- package/build/ios/Swift.js +5 -5
- package/build/ios/Swift.js.map +1 -1
- package/build/ios/XcodeProjectFile.js +5 -5
- package/build/ios/XcodeProjectFile.js.map +1 -1
- package/build/utils/XML.js +8 -6
- package/build/utils/XML.js.map +1 -1
- package/build/utils/fs.d.ts +4 -0
- package/build/utils/fs.js +56 -0
- package/build/utils/fs.js.map +1 -0
- package/package.json +3 -5
|
@@ -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,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,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AAkB,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":";;;;;;;;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,CAAf;AACD,GAFD,CAEE,MAAM,CAAE;;AAEV,OAAK,MAAMQ,WAAX,IAA0B2B,YAA1B,EAAwC;AACtCZ,IAAAA,gCAAgC,CAACf,WAAD,EAAcb,gBAAd,EAAgC6B,iBAAhC,CAAhC;AACD;AACF;AAED;AACA;AACA;;;AAEA,MAAMY,eAAe,GAAG,8BAAxB;;AAEA,SAASC,8BAAT,CAAwCrC,WAAxC,EAAmE;AACjE,QAAMsC,cAAc,GAAG,mCAAqBtC,WAArB,CAAvB;;AAEA,OAAK,MAAMuC,SAAX,IAAwBD,cAAxB,EAAwC;AACtCE,IAAAA,0BAA0B,CAACD,SAAD,CAA1B;AACD;AACF;;AAED,SAASC,0BAAT,CAAoCD,SAApC,EAA6D;AAC3D,QAAME,QAAQ,GAAGT,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"}
|
|
@@ -7,10 +7,10 @@ exports.getEntitlementsPath = getEntitlementsPath;
|
|
|
7
7
|
exports.setAssociatedDomains = setAssociatedDomains;
|
|
8
8
|
exports.withAssociatedDomains = void 0;
|
|
9
9
|
|
|
10
|
-
function
|
|
11
|
-
const data = _interopRequireDefault(require("fs
|
|
10
|
+
function _fs() {
|
|
11
|
+
const data = _interopRequireDefault(require("fs"));
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
_fs = function () {
|
|
14
14
|
return data;
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -47,6 +47,16 @@ function _iosPlugins() {
|
|
|
47
47
|
return data;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
function _fs2() {
|
|
51
|
+
const data = require("../utils/fs");
|
|
52
|
+
|
|
53
|
+
_fs2 = function () {
|
|
54
|
+
return data;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
|
|
50
60
|
function Paths() {
|
|
51
61
|
const data = _interopRequireWildcard(require("./Paths"));
|
|
52
62
|
|
|
@@ -125,12 +135,14 @@ function getEntitlementsPath(projectRoot) {
|
|
|
125
135
|
if (pathsToDelete.length) {
|
|
126
136
|
// Get the last entitlements file and use it as the template
|
|
127
137
|
const last = pathsToDelete[pathsToDelete.length - 1];
|
|
128
|
-
template =
|
|
138
|
+
template = _fs().default.readFileSync(last, 'utf8');
|
|
129
139
|
}
|
|
130
140
|
|
|
131
|
-
|
|
141
|
+
_fs().default.mkdirSync(_path().default.dirname(entitlementsPath), {
|
|
142
|
+
recursive: true
|
|
143
|
+
});
|
|
132
144
|
|
|
133
|
-
|
|
145
|
+
_fs().default.writeFileSync(entitlementsPath, template);
|
|
134
146
|
|
|
135
147
|
Object.entries(project.pbxXCBuildConfigurationSection()).filter(_Xcodeproj().isNotComment).filter(_Xcodeproj().isBuildConfig).filter(_Xcodeproj().isNotTestHost).forEach(({
|
|
136
148
|
1: {
|
|
@@ -140,7 +152,7 @@ function getEntitlementsPath(projectRoot) {
|
|
|
140
152
|
buildSettings.CODE_SIGN_ENTITLEMENTS = `"${entitlementsRelativePath}"`;
|
|
141
153
|
});
|
|
142
154
|
|
|
143
|
-
|
|
155
|
+
_fs().default.writeFileSync(project.filepath, project.writeSync());
|
|
144
156
|
} // Clean up others
|
|
145
157
|
|
|
146
158
|
|
|
@@ -150,7 +162,7 @@ function getEntitlementsPath(projectRoot) {
|
|
|
150
162
|
|
|
151
163
|
function deleteEntitlementsFiles(entitlementsPaths) {
|
|
152
164
|
for (const path of entitlementsPaths) {
|
|
153
|
-
|
|
165
|
+
(0, _fs2().removeFile)(path);
|
|
154
166
|
}
|
|
155
167
|
}
|
|
156
168
|
|
|
@@ -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","
|
|
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","mkdirSync","dirname","recursive","writeFileSync","Object","entries","pbxXCBuildConfigurationSection","filter","isNotComment","isBuildConfig","isNotTestHost","forEach","buildSettings","CODE_SIGN_ENTITLEMENTS","filepath","writeSync","deleteEntitlementsFiles","entitlementsPaths"],"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;;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,GA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AEC,QAAAA;AAAF;AAAL,KAAD,KAAmC;AAC1CA,MAAAA,aAAa,CAACC,sBAAd,GAAwC,IAAG3B,wBAAyB,GAApE;AACD,KANH;;AAOAY,kBAAGK,aAAH,CAAiBpB,OAAO,CAAC+B,QAAzB,EAAmC/B,OAAO,CAACgC,SAAR,EAAnC;AACD,GArD8D,CAuD/D;;;AACAC,EAAAA,uBAAuB,CAACzB,aAAD,CAAvB;AAEA,SAAOF,gBAAP;AACD;;AAED,SAAS2B,uBAAT,CAAiCC,iBAAjC,EAA8D;AAC5D,OAAK,MAAM9B,IAAX,IAAmB8B,iBAAnB,EAAsC;AACpC,2BAAW9B,IAAX;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';\nimport path from 'path';\nimport slash from 'slash';\n\nimport { createEntitlementsPlugin } from '../plugins/ios-plugins';\nimport { removeFile } from '../utils/fs';\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.mkdirSync(path.dirname(entitlementsPath), { recursive: true });\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 removeFile(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"}
|
package/build/ios/Google.js
CHANGED
|
@@ -30,10 +30,10 @@ function _assert() {
|
|
|
30
30
|
return data;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function
|
|
34
|
-
const data = _interopRequireDefault(require("fs
|
|
33
|
+
function _fs() {
|
|
34
|
+
const data = _interopRequireDefault(require("fs"));
|
|
35
35
|
|
|
36
|
-
|
|
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 =
|
|
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
|
-
|
|
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`;
|
package/build/ios/Google.js.map
CHANGED
|
@@ -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;;;;AAUP,SAASQ,2BAAT,CACEC,YADF,EAEE;AAAEH,EAAAA;AAAF,CAFF,EAGE;AACA,QAAMI,qBAAqB,GAAGC,gBAAKC,OAAL,CAAaN,WAAb,EAA0BG,YAA1B,CAA9B;;AACA,QAAMI,QAAQ,GAAGC,
|
|
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;;;;AAUP,SAASQ,2BAAT,CACEC,YADF,EAE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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,gBAAGc,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';\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"}
|
package/build/ios/Locales.js
CHANGED
|
@@ -18,10 +18,10 @@ function _jsonFile() {
|
|
|
18
18
|
return data;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function
|
|
22
|
-
const data =
|
|
21
|
+
function _fs() {
|
|
22
|
+
const data = _interopRequireDefault(require("fs"));
|
|
23
23
|
|
|
24
|
-
|
|
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
|
-
|
|
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
|
|
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,
|
|
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
|
|
132
|
+
filepath: (0, _path().relative)(supportingDirectory, strings),
|
|
133
|
+
groupName,
|
|
134
134
|
project,
|
|
135
135
|
isBuildFile: true,
|
|
136
136
|
verbose: true
|
package/build/ios/Locales.js.map
CHANGED
|
@@ -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","
|
|
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","e"],"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;AA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D;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 (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"}
|
package/build/ios/Maps.js
CHANGED
|
@@ -14,10 +14,10 @@ exports.removeMapsCocoaPods = removeMapsCocoaPods;
|
|
|
14
14
|
exports.setGoogleMapsApiKey = setGoogleMapsApiKey;
|
|
15
15
|
exports.withMaps = void 0;
|
|
16
16
|
|
|
17
|
-
function
|
|
18
|
-
const data = _interopRequireDefault(require("fs
|
|
17
|
+
function _fs() {
|
|
18
|
+
const data = _interopRequireDefault(require("fs"));
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
_fs = function () {
|
|
21
21
|
return data;
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -208,7 +208,7 @@ const withMapsCocoaPods = (config, {
|
|
|
208
208
|
return (0, _withDangerousMod().withDangerousMod)(config, ['ios', async config => {
|
|
209
209
|
const filePath = _path().default.join(config.modRequest.platformProjectRoot, 'Podfile');
|
|
210
210
|
|
|
211
|
-
const contents = await
|
|
211
|
+
const contents = await _fs().default.promises.readFile(filePath, 'utf-8');
|
|
212
212
|
let results; // Only add the block if react-native-maps is installed in the project (best effort).
|
|
213
213
|
// Generally prebuild runs after a yarn install so this should always work as expected.
|
|
214
214
|
|
|
@@ -233,7 +233,7 @@ const withMapsCocoaPods = (config, {
|
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
if (results.didMerge || results.didClear) {
|
|
236
|
-
await
|
|
236
|
+
await _fs().default.promises.writeFile(filePath, results.contents);
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
return config;
|
package/build/ios/Maps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ios/Maps.ts"],"names":["debug","require","MATCH_INIT","withGoogleMapsKey","setGoogleMapsApiKey","withMaps","config","apiKey","getGoogleMapsApiKey","withMapsCocoaPods","useGoogleMaps","withGoogleMapsAppDelegate","ios","googleMapsApiKey","GMSApiKey","infoPlist","addGoogleMapsAppDelegateImport","src","newSrc","push","tag","join","anchor","offset","comment","removeGoogleMapsAppDelegateImport","addGoogleMapsAppDelegateInit","removeGoogleMapsAppDelegateInit","addMapsCocoaPods","removeMapsCocoaPods","isReactNativeMapsInstalled","projectRoot","resolved","resolveFrom","silent","path","dirname","isReactNativeMapsAutolinked","filePath","modRequest","platformProjectRoot","contents","fs","readFile","results","googleMapsPath","isLinked","error","code","Error","didMerge","didClear","writeFile","includes","modResults","language"],"mappings":";;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AA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ACnB,cAAIA,KAAK,CAACC,IAAN,KAAe,cAAnB,EAAmC;AACjC,kBAAM,IAAIC,KAAJ,CACH,yIADG,CAAN;AAGD;;AACD,gBAAMF,KAAN;AACD;AACF,OArBD,MAqBO;AACLzC,QAAAA,MAAM,CAACgD,UAAP,CAAkBb,QAAlB,GAA6BhB,iCAAiC,CAC5DnB,MAAM,CAACgD,UAAP,CAAkBb,QAD0C,CAAjC,CAE3BA,QAFF;AAGAnC,QAAAA,MAAM,CAACgD,UAAP,CAAkBb,QAAlB,GAA6Bd,+BAA+B,CAC1DrB,MAAM,CAACgD,UAAP,CAAkBb,QADwC,CAA/B,CAE3BA,QAFF;AAGD;AACF,KA9BD,MA8BO;AACL,YAAM,IAAIQ,KAAJ,CACH,yFAAwF3C,MAAM,CAACgD,UAAP,CAAkBC,QAAS,EADhH,CAAN;AAGD;;AACD,WAAOjD,MAAP;AACD,GArCM,CAAP;AAsCD,CAvCD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { ConfigPlugin, InfoPlist } from '../Plugin.types';\nimport { createInfoPlistPlugin, withAppDelegate } from '../plugins/ios-plugins';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { mergeContents, MergeResults, removeContents } from '../utils/generateCode';\n\nconst debug = require('debug')('expo:config-plugins:ios:maps') as typeof console.log;\n\n// Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules), and SDK +44 React AppDelegate subscriber.\nexport const MATCH_INIT = /(?:(self\\.|_)(\\w+)\\s?=\\s?\\[\\[UMModuleRegistryAdapter alloc\\])|(?:RCTBridge\\s?\\*\\s?(\\w+)\\s?=\\s?\\[\\[RCTBridge alloc\\])|(\\[self\\.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions\\])/g;\n\nconst withGoogleMapsKey = createInfoPlistPlugin(setGoogleMapsApiKey, 'withGoogleMapsKey');\n\nexport const withMaps: ConfigPlugin = config => {\n config = withGoogleMapsKey(config);\n\n const apiKey = getGoogleMapsApiKey(config);\n // Technically adds react-native-maps (Apple maps) and google maps.\n\n debug('Google Maps API Key:', apiKey);\n config = withMapsCocoaPods(config, { useGoogleMaps: !!apiKey });\n\n // Adds/Removes AppDelegate setup for Google Maps API on iOS\n config = withGoogleMapsAppDelegate(config, { apiKey });\n\n return config;\n};\n\nexport function getGoogleMapsApiKey(config: Pick<ExpoConfig, 'ios'>) {\n return config.ios?.config?.googleMapsApiKey ?? null;\n}\n\nexport function setGoogleMapsApiKey(\n config: Pick<ExpoConfig, 'ios'>,\n { GMSApiKey, ...infoPlist }: InfoPlist\n): InfoPlist {\n const apiKey = getGoogleMapsApiKey(config);\n\n if (apiKey === null) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n GMSApiKey: apiKey,\n };\n}\n\nexport function addGoogleMapsAppDelegateImport(src: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n '#import <GoogleMaps/GoogleMaps.h>',\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-import',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: /#import \"AppDelegate\\.h\"/,\n offset: 1,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateImport(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-import',\n src,\n });\n}\n\nexport function addGoogleMapsAppDelegateInit(src: string, apiKey: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n ` [GMSServices provideAPIKey:@\"${apiKey}\"];`,\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-init',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: MATCH_INIT,\n offset: 0,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateInit(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-init',\n src,\n });\n}\n\n/**\n * @param src The contents of the Podfile.\n * @returns Podfile with Google Maps added.\n */\nexport function addMapsCocoaPods(src: string): MergeResults {\n return mergeContents({\n tag: 'react-native-maps',\n src,\n newSrc: ` pod 'react-native-google-maps', path: File.dirname(\\`node --print \"require.resolve('react-native-maps/package.json')\"\\`)`,\n anchor: /use_native_modules/,\n offset: 0,\n comment: '#',\n });\n}\n\nexport function removeMapsCocoaPods(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps',\n src,\n });\n}\n\nfunction isReactNativeMapsInstalled(projectRoot: string): string | null {\n const resolved = resolveFrom.silent(projectRoot, 'react-native-maps/package.json');\n return resolved ? path.dirname(resolved) : null;\n}\n\nfunction isReactNativeMapsAutolinked(config: Pick<ExpoConfig, '_internal'>): boolean {\n // Only add the native code changes if we know that the package is going to be linked natively.\n // This is specifically for monorepo support where one app might have react-native-maps (adding it to the node_modules)\n // but another app will not have it installed in the package.json, causing it to not be linked natively.\n // This workaround only exists because react-native-maps doesn't have a config plugin vendored in the package.\n\n // TODO: `react-native-maps` doesn't use Expo autolinking so we cannot safely disable the module.\n return true;\n\n // return (\n // !config._internal?.autolinkedModules ||\n // config._internal.autolinkedModules.includes('react-native-maps')\n // );\n}\n\nconst withMapsCocoaPods: ConfigPlugin<{ useGoogleMaps: boolean }> = (config, { useGoogleMaps }) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');\n const contents = await fs.readFile(filePath, 'utf-8');\n let results: MergeResults;\n // Only add the block if react-native-maps is installed in the project (best effort).\n // Generally prebuild runs after a yarn install so this should always work as expected.\n const googleMapsPath = isReactNativeMapsInstalled(config.modRequest.projectRoot);\n const isLinked = isReactNativeMapsAutolinked(config);\n debug('Is Expo Autolinked:', isLinked);\n debug('react-native-maps path:', googleMapsPath);\n if (isLinked && googleMapsPath && useGoogleMaps) {\n try {\n results = addMapsCocoaPods(contents);\n } catch (error: any) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add react-native-maps to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.`\n );\n }\n throw error;\n }\n } else {\n // If the package is no longer installed, then remove the block.\n results = removeMapsCocoaPods(contents);\n }\n if (results.didMerge || results.didClear) {\n await fs.writeFile(filePath, results.contents);\n }\n return config;\n },\n ]);\n};\n\nconst withGoogleMapsAppDelegate: ConfigPlugin<{ apiKey: string | null }> = (config, { apiKey }) => {\n return withAppDelegate(config, config => {\n if (['objc', 'objcpp'].includes(config.modResults.language)) {\n if (\n apiKey &&\n isReactNativeMapsAutolinked(config) &&\n isReactNativeMapsInstalled(config.modRequest.projectRoot)\n ) {\n try {\n config.modResults.contents = addGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = addGoogleMapsAppDelegateInit(\n config.modResults.contents,\n apiKey\n ).contents;\n } catch (error: any) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add Google Maps to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.`\n );\n }\n throw error;\n }\n } else {\n config.modResults.contents = removeGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = removeGoogleMapsAppDelegateInit(\n config.modResults.contents\n ).contents;\n }\n } else {\n throw new Error(\n `Cannot setup Google Maps because the project AppDelegate is not a supported language: ${config.modResults.language}`\n );\n }\n return config;\n });\n};\n"],"file":"Maps.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/ios/Maps.ts"],"names":["debug","require","MATCH_INIT","withGoogleMapsKey","setGoogleMapsApiKey","withMaps","config","apiKey","getGoogleMapsApiKey","withMapsCocoaPods","useGoogleMaps","withGoogleMapsAppDelegate","ios","googleMapsApiKey","GMSApiKey","infoPlist","addGoogleMapsAppDelegateImport","src","newSrc","push","tag","join","anchor","offset","comment","removeGoogleMapsAppDelegateImport","addGoogleMapsAppDelegateInit","removeGoogleMapsAppDelegateInit","addMapsCocoaPods","removeMapsCocoaPods","isReactNativeMapsInstalled","projectRoot","resolved","resolveFrom","silent","path","dirname","isReactNativeMapsAutolinked","filePath","modRequest","platformProjectRoot","contents","fs","promises","readFile","results","googleMapsPath","isLinked","error","code","Error","didMerge","didClear","writeFile","includes","modResults","language"],"mappings":";;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAD,CAAP,CAAiB,8BAAjB,CAAd,C,CAEA;;;AACO,MAAMC,UAAU,GAAG,2MAAnB;;AAEP,MAAMC,iBAAiB,GAAG,yCAAsBC,mBAAtB,EAA2C,mBAA3C,CAA1B;;AAEO,MAAMC,QAAsB,GAAGC,MAAM,IAAI;AAC9CA,EAAAA,MAAM,GAAGH,iBAAiB,CAACG,MAAD,CAA1B;AAEA,QAAMC,MAAM,GAAGC,mBAAmB,CAACF,MAAD,CAAlC,CAH8C,CAI9C;;AAEAN,EAAAA,KAAK,CAAC,sBAAD,EAAyBO,MAAzB,CAAL;AACAD,EAAAA,MAAM,GAAGG,iBAAiB,CAACH,MAAD,EAAS;AAAEI,IAAAA,aAAa,EAAE,CAAC,CAACH;AAAnB,GAAT,CAA1B,CAP8C,CAS9C;;AACAD,EAAAA,MAAM,GAAGK,yBAAyB,CAACL,MAAD,EAAS;AAAEC,IAAAA;AAAF,GAAT,CAAlC;AAEA,SAAOD,MAAP;AACD,CAbM;;;;AAeA,SAASE,mBAAT,CAA6BF,MAA7B,EAA8D;AAAA;;AACnE,iDAAOA,MAAM,CAACM,GAAd,sEAAO,YAAYN,MAAnB,uDAAO,mBAAoBO,gBAA3B,yEAA+C,I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IAEAwB,0BAA0B,CAACxB,MAAM,CAACiC,UAAP,CAAkBR,WAAnB,CAH5B,EAIE;AACA,YAAI;AACFzB,UAAAA,MAAM,CAACiD,UAAP,CAAkBd,QAAlB,GAA6BzB,8BAA8B,CACzDV,MAAM,CAACiD,UAAP,CAAkBd,QADuC,CAA9B,CAE3BA,QAFF;AAGAnC,UAAAA,MAAM,CAACiD,UAAP,CAAkBd,QAAlB,GAA6Bf,4BAA4B,CACvDpB,MAAM,CAACiD,UAAP,CAAkBd,QADqC,EAEvDlC,MAFuD,CAA5B,CAG3BkC,QAHF;AAID,SARD,CAQE,OAAOO,KAAP,EAAmB;AACnB,cAAIA,KAAK,CAACC,IAAN,KAAe,cAAnB,EAAmC;AACjC,kBAAM,IAAIC,KAAJ,CACH,yIADG,CAAN;AAGD;;AACD,gBAAMF,KAAN;AACD;AACF,OArBD,MAqBO;AACL1C,QAAAA,MAAM,CAACiD,UAAP,CAAkBd,QAAlB,GAA6BhB,iCAAiC,CAC5DnB,MAAM,CAACiD,UAAP,CAAkBd,QAD0C,CAAjC,CAE3BA,QAFF;AAGAnC,QAAAA,MAAM,CAACiD,UAAP,CAAkBd,QAAlB,GAA6Bd,+BAA+B,CAC1DrB,MAAM,CAACiD,UAAP,CAAkBd,QADwC,CAA/B,CAE3BA,QAFF;AAGD;AACF,KA9BD,MA8BO;AACL,YAAM,IAAIS,KAAJ,CACH,yFAAwF5C,MAAM,CAACiD,UAAP,CAAkBC,QAAS,EADhH,CAAN;AAGD;;AACD,WAAOlD,MAAP;AACD,GArCM,CAAP;AAsCD,CAvCD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport fs from 'fs';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { ConfigPlugin, InfoPlist } from '../Plugin.types';\nimport { createInfoPlistPlugin, withAppDelegate } from '../plugins/ios-plugins';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { mergeContents, MergeResults, removeContents } from '../utils/generateCode';\n\nconst debug = require('debug')('expo:config-plugins:ios:maps') as typeof console.log;\n\n// Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules), and SDK +44 React AppDelegate subscriber.\nexport const MATCH_INIT = /(?:(self\\.|_)(\\w+)\\s?=\\s?\\[\\[UMModuleRegistryAdapter alloc\\])|(?:RCTBridge\\s?\\*\\s?(\\w+)\\s?=\\s?\\[\\[RCTBridge alloc\\])|(\\[self\\.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions\\])/g;\n\nconst withGoogleMapsKey = createInfoPlistPlugin(setGoogleMapsApiKey, 'withGoogleMapsKey');\n\nexport const withMaps: ConfigPlugin = config => {\n config = withGoogleMapsKey(config);\n\n const apiKey = getGoogleMapsApiKey(config);\n // Technically adds react-native-maps (Apple maps) and google maps.\n\n debug('Google Maps API Key:', apiKey);\n config = withMapsCocoaPods(config, { useGoogleMaps: !!apiKey });\n\n // Adds/Removes AppDelegate setup for Google Maps API on iOS\n config = withGoogleMapsAppDelegate(config, { apiKey });\n\n return config;\n};\n\nexport function getGoogleMapsApiKey(config: Pick<ExpoConfig, 'ios'>) {\n return config.ios?.config?.googleMapsApiKey ?? null;\n}\n\nexport function setGoogleMapsApiKey(\n config: Pick<ExpoConfig, 'ios'>,\n { GMSApiKey, ...infoPlist }: InfoPlist\n): InfoPlist {\n const apiKey = getGoogleMapsApiKey(config);\n\n if (apiKey === null) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n GMSApiKey: apiKey,\n };\n}\n\nexport function addGoogleMapsAppDelegateImport(src: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n '#import <GoogleMaps/GoogleMaps.h>',\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-import',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: /#import \"AppDelegate\\.h\"/,\n offset: 1,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateImport(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-import',\n src,\n });\n}\n\nexport function addGoogleMapsAppDelegateInit(src: string, apiKey: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n ` [GMSServices provideAPIKey:@\"${apiKey}\"];`,\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-init',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: MATCH_INIT,\n offset: 0,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateInit(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-init',\n src,\n });\n}\n\n/**\n * @param src The contents of the Podfile.\n * @returns Podfile with Google Maps added.\n */\nexport function addMapsCocoaPods(src: string): MergeResults {\n return mergeContents({\n tag: 'react-native-maps',\n src,\n newSrc: ` pod 'react-native-google-maps', path: File.dirname(\\`node --print \"require.resolve('react-native-maps/package.json')\"\\`)`,\n anchor: /use_native_modules/,\n offset: 0,\n comment: '#',\n });\n}\n\nexport function removeMapsCocoaPods(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps',\n src,\n });\n}\n\nfunction isReactNativeMapsInstalled(projectRoot: string): string | null {\n const resolved = resolveFrom.silent(projectRoot, 'react-native-maps/package.json');\n return resolved ? path.dirname(resolved) : null;\n}\n\nfunction isReactNativeMapsAutolinked(config: Pick<ExpoConfig, '_internal'>): boolean {\n // Only add the native code changes if we know that the package is going to be linked natively.\n // This is specifically for monorepo support where one app might have react-native-maps (adding it to the node_modules)\n // but another app will not have it installed in the package.json, causing it to not be linked natively.\n // This workaround only exists because react-native-maps doesn't have a config plugin vendored in the package.\n\n // TODO: `react-native-maps` doesn't use Expo autolinking so we cannot safely disable the module.\n return true;\n\n // return (\n // !config._internal?.autolinkedModules ||\n // config._internal.autolinkedModules.includes('react-native-maps')\n // );\n}\n\nconst withMapsCocoaPods: ConfigPlugin<{ useGoogleMaps: boolean }> = (config, { useGoogleMaps }) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');\n const contents = await fs.promises.readFile(filePath, 'utf-8');\n let results: MergeResults;\n // Only add the block if react-native-maps is installed in the project (best effort).\n // Generally prebuild runs after a yarn install so this should always work as expected.\n const googleMapsPath = isReactNativeMapsInstalled(config.modRequest.projectRoot);\n const isLinked = isReactNativeMapsAutolinked(config);\n debug('Is Expo Autolinked:', isLinked);\n debug('react-native-maps path:', googleMapsPath);\n if (isLinked && googleMapsPath && useGoogleMaps) {\n try {\n results = addMapsCocoaPods(contents);\n } catch (error: any) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add react-native-maps to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.`\n );\n }\n throw error;\n }\n } else {\n // If the package is no longer installed, then remove the block.\n results = removeMapsCocoaPods(contents);\n }\n if (results.didMerge || results.didClear) {\n await fs.promises.writeFile(filePath, results.contents);\n }\n return config;\n },\n ]);\n};\n\nconst withGoogleMapsAppDelegate: ConfigPlugin<{ apiKey: string | null }> = (config, { apiKey }) => {\n return withAppDelegate(config, config => {\n if (['objc', 'objcpp'].includes(config.modResults.language)) {\n if (\n apiKey &&\n isReactNativeMapsAutolinked(config) &&\n isReactNativeMapsInstalled(config.modRequest.projectRoot)\n ) {\n try {\n config.modResults.contents = addGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = addGoogleMapsAppDelegateInit(\n config.modResults.contents,\n apiKey\n ).contents;\n } catch (error: any) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add Google Maps to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.`\n );\n }\n throw error;\n }\n } else {\n config.modResults.contents = removeGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = removeGoogleMapsAppDelegateInit(\n config.modResults.contents\n ).contents;\n }\n } else {\n throw new Error(\n `Cannot setup Google Maps because the project AppDelegate is not a supported language: ${config.modResults.language}`\n );\n }\n return config;\n });\n};\n"],"file":"Maps.js"}
|
package/build/ios/Paths.js
CHANGED
|
@@ -22,10 +22,10 @@ exports.getSourceRoot = getSourceRoot;
|
|
|
22
22
|
exports.getSupportingPath = getSupportingPath;
|
|
23
23
|
exports.getXcodeProjectPath = getXcodeProjectPath;
|
|
24
24
|
|
|
25
|
-
function
|
|
26
|
-
const data = require("fs
|
|
25
|
+
function _fs() {
|
|
26
|
+
const data = require("fs");
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
_fs = function () {
|
|
29
29
|
return data;
|
|
30
30
|
};
|
|
31
31
|
|
|
@@ -172,7 +172,7 @@ function getLanguage(filePath) {
|
|
|
172
172
|
function getFileInfo(filePath) {
|
|
173
173
|
return {
|
|
174
174
|
path: path().normalize(filePath),
|
|
175
|
-
contents: (0,
|
|
175
|
+
contents: (0, _fs().readFileSync)(filePath, 'utf8'),
|
|
176
176
|
language: getLanguage(filePath)
|
|
177
177
|
};
|
|
178
178
|
}
|
|
@@ -202,11 +202,20 @@ function findSchemeNames(projectRoot) {
|
|
|
202
202
|
|
|
203
203
|
function getAllXcodeProjectPaths(projectRoot) {
|
|
204
204
|
const iosFolder = 'ios';
|
|
205
|
-
const pbxprojPaths = (0, _glob().sync)('
|
|
205
|
+
const pbxprojPaths = (0, _glob().sync)('ios/**/*.xcodeproj', {
|
|
206
206
|
cwd: projectRoot,
|
|
207
207
|
ignore: ignoredPaths
|
|
208
|
-
}).filter(project => !/test|example|sample/i.test(project) || path().dirname(project) === iosFolder)
|
|
209
|
-
.sort()
|
|
208
|
+
}).filter(project => !/test|example|sample/i.test(project) || path().dirname(project) === iosFolder) // sort alphabetically to ensure this works the same across different devices (Fail in CI (linux) without this)
|
|
209
|
+
.sort().sort((a, b) => {
|
|
210
|
+
const isAInIos = path().dirname(a) === iosFolder;
|
|
211
|
+
const isBInIos = path().dirname(b) === iosFolder; // preserve previous sort order
|
|
212
|
+
|
|
213
|
+
if (isAInIos && isBInIos || !isAInIos && !isBInIos) {
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return isAInIos ? -1 : 1;
|
|
218
|
+
});
|
|
210
219
|
|
|
211
220
|
if (!pbxprojPaths.length) {
|
|
212
221
|
throw new (_errors().UnexpectedError)(`Failed to locate the ios/*.xcodeproj files relative to path "${projectRoot}".`);
|
|
@@ -237,7 +246,7 @@ function getXcodeProjectPath(projectRoot) {
|
|
|
237
246
|
|
|
238
247
|
function getAllPBXProjectPaths(projectRoot) {
|
|
239
248
|
const projectPaths = getAllXcodeProjectPaths(projectRoot);
|
|
240
|
-
const paths = projectPaths.map(value => path().join(value, 'project.pbxproj')).filter(value => (0,
|
|
249
|
+
const paths = projectPaths.map(value => path().join(value, 'project.pbxproj')).filter(value => (0, _fs().existsSync)(value));
|
|
241
250
|
|
|
242
251
|
if (!paths.length) {
|
|
243
252
|
throw new (_errors().UnexpectedError)(`Failed to locate the ios/*.xcodeproj/project.pbxproj files relative to path "${projectRoot}".`);
|
package/build/ios/Paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ios/Paths.ts"],"names":["ignoredPaths","getAppDelegateHeaderFilePath","projectRoot","using","extra","absolute","cwd","ignore","UnexpectedError","length","warnMultipleFiles","tag","fileName","getAppDelegateFilePath","getAppDelegateObjcHeaderFilePath","getLanguage","filePath","extension","path","extname","getFileInfo","normalize","contents","language","getAppDelegate","getSourceRoot","appDelegate","dirname","findSchemePaths","findSchemeNames","schemePaths","map","schemePath","parse","name","getAllXcodeProjectPaths","iosFolder","pbxprojPaths","filter","project","test","sort","value","join","getXcodeProjectPath","getAllPBXProjectPaths","projectPaths","paths","getPBXProjectPath","getAllInfoPlistPaths","a","b","getInfoPlistPath","getAllEntitlementsPaths","getEntitlementsPath","getSupportingPath","resolve","basename","getExpoPlistPath","supportingPath","usingPath","relative","extraPaths","v","JSON","stringify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAA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QAAM2D,UAAU,GAAG5D,WAAW,GAAGE,KAAK,CAAC2B,GAAN,CAAUgC,CAAC,IAAI7C,IAAI,GAAC2C,QAAL,CAAc3D,WAAd,EAA2B6D,CAA3B,CAAf,CAAH,GAAmD3D,KAAjF;AACA,iCACG,SAAQO,GAAI,EADf,EAEG,kBAAiBC,QAAS,uBAAsBgD,SAAU,qBAAoBI,IAAI,CAACC,SAAL,CAC7EH,UAD6E,CAE7E,EAJJ;AAMD","sourcesContent":["import { pathExistsSync, readFileSync } from 'fs-extra';\nimport { sync as globSync } from 'glob';\nimport * as path from 'path';\n\nimport { UnexpectedError } from '../utils/errors';\nimport { addWarningIOS } from '../utils/warnings';\n\nconst ignoredPaths = ['**/@(Carthage|Pods|vendor|node_modules)/**'];\n\ninterface ProjectFile<L extends string = string> {\n path: string;\n language: L;\n contents: string;\n}\n\ntype AppleLanguage = 'objc' | 'objcpp' | 'swift';\n\nexport type AppDelegateProjectFile = ProjectFile<AppleLanguage>;\n\nexport function getAppDelegateHeaderFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.h', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(\n `Could not locate a valid AppDelegate header at root: \"${projectRoot}\"`\n );\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate-header',\n fileName: 'AppDelegate',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAppDelegateFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.@(m|mm|swift)', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(`Could not locate a valid AppDelegate at root: \"${projectRoot}\"`);\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate',\n fileName: 'AppDelegate',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAppDelegateObjcHeaderFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.h', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(`Could not locate a valid AppDelegate.h at root: \"${projectRoot}\"`);\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate-objc-header',\n fileName: 'AppDelegate.h',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nfunction getLanguage(filePath: string): AppleLanguage {\n const extension = path.extname(filePath);\n switch (extension) {\n case '.mm':\n return 'objcpp';\n case '.m':\n case '.h':\n return 'objc';\n case '.swift':\n return 'swift';\n default:\n throw new UnexpectedError(`Unexpected iOS file extension: ${extension}`);\n }\n}\n\nexport function getFileInfo(filePath: string) {\n return {\n path: path.normalize(filePath),\n contents: readFileSync(filePath, 'utf8'),\n language: getLanguage(filePath),\n };\n}\n\nexport function getAppDelegate(projectRoot: string): AppDelegateProjectFile {\n const filePath = getAppDelegateFilePath(projectRoot);\n return getFileInfo(filePath);\n}\n\nexport function getSourceRoot(projectRoot: string): string {\n const appDelegate = getAppDelegate(projectRoot);\n return path.dirname(appDelegate.path);\n}\n\nexport function findSchemePaths(projectRoot: string): string[] {\n return globSync('ios/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n}\n\nexport function findSchemeNames(projectRoot: string): string[] {\n const schemePaths = findSchemePaths(projectRoot);\n return schemePaths.map(schemePath => path.parse(schemePath).name);\n}\n\nexport function getAllXcodeProjectPaths(projectRoot: string): string[] {\n const iosFolder = 'ios';\n const pbxprojPaths = globSync('**/*.xcodeproj', { cwd: projectRoot, ignore: ignoredPaths })\n .filter(project => !/test|example|sample/i.test(project) || path.dirname(project) === iosFolder)\n .sort(project => (path.dirname(project) === iosFolder ? -1 : 1))\n // sort alphabetically to ensure this works the same across different devices (Fail in CI (linux) without this)\n .sort();\n\n if (!pbxprojPaths.length) {\n throw new UnexpectedError(\n `Failed to locate the ios/*.xcodeproj files relative to path \"${projectRoot}\".`\n );\n }\n return pbxprojPaths.map(value => path.join(projectRoot, value));\n}\n\n/**\n * Get the pbxproj for the given path\n */\nexport function getXcodeProjectPath(projectRoot: string): string {\n const [using, ...extra] = getAllXcodeProjectPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'xcodeproj',\n fileName: '*.xcodeproj',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllPBXProjectPaths(projectRoot: string): string[] {\n const projectPaths = getAllXcodeProjectPaths(projectRoot);\n const paths = projectPaths\n .map(value => path.join(value, 'project.pbxproj'))\n .filter(value => pathExistsSync(value));\n\n if (!paths.length) {\n throw new UnexpectedError(\n `Failed to locate the ios/*.xcodeproj/project.pbxproj files relative to path \"${projectRoot}\".`\n );\n }\n return paths;\n}\n\nexport function getPBXProjectPath(projectRoot: string): string {\n const [using, ...extra] = getAllPBXProjectPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'project-pbxproj',\n fileName: 'project.pbxproj',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllInfoPlistPaths(projectRoot: string): string[] {\n const paths = globSync('ios/*/Info.plist', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n }).sort(\n // longer name means more suffixes, we want the shortest possible one to be first.\n (a, b) => a.length - b.length\n );\n\n if (!paths.length) {\n throw new UnexpectedError(\n `Failed to locate Info.plist files relative to path \"${projectRoot}\".`\n );\n }\n return paths;\n}\n\nexport function getInfoPlistPath(projectRoot: string): string {\n const [using, ...extra] = getAllInfoPlistPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'info-plist',\n fileName: 'Info.plist',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllEntitlementsPaths(projectRoot: string): string[] {\n const paths = globSync('ios/*/*.entitlements', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n return paths;\n}\n\n/**\n * Get the entitlements file path if it exists.\n *\n * @param projectRoot\n */\nexport function getEntitlementsPath(projectRoot: string): string | null {\n const [using, ...extra] = getAllEntitlementsPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'entitlements',\n fileName: '*.entitlements',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using ?? null;\n}\n\nexport function getSupportingPath(projectRoot: string): string {\n return path.resolve(projectRoot, 'ios', path.basename(getSourceRoot(projectRoot)), 'Supporting');\n}\n\nexport function getExpoPlistPath(projectRoot: string): string {\n const supportingPath = getSupportingPath(projectRoot);\n return path.join(supportingPath, 'Expo.plist');\n}\n\nfunction warnMultipleFiles({\n tag,\n fileName,\n projectRoot,\n using,\n extra,\n}: {\n tag: string;\n fileName: string;\n projectRoot?: string;\n using: string;\n extra: string[];\n}) {\n const usingPath = projectRoot ? path.relative(projectRoot, using) : using;\n const extraPaths = projectRoot ? extra.map(v => path.relative(projectRoot, v)) : extra;\n addWarningIOS(\n `paths-${tag}`,\n `Found multiple ${fileName} file paths, using \"${usingPath}\". Ignored paths: ${JSON.stringify(\n extraPaths\n )}`\n );\n}\n"],"file":"Paths.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/ios/Paths.ts"],"names":["ignoredPaths","getAppDelegateHeaderFilePath","projectRoot","using","extra","absolute","cwd","ignore","UnexpectedError","length","warnMultipleFiles","tag","fileName","getAppDelegateFilePath","getAppDelegateObjcHeaderFilePath","getLanguage","filePath","extension","path","extname","getFileInfo","normalize","contents","language","getAppDelegate","getSourceRoot","appDelegate","dirname","findSchemePaths","findSchemeNames","schemePaths","map","schemePath","parse","name","getAllXcodeProjectPaths","iosFolder","pbxprojPaths","filter","project","test","sort","a","b","isAInIos","isBInIos","value","join","getXcodeProjectPath","getAllPBXProjectPaths","projectPaths","paths","getPBXProjectPath","getAllInfoPlistPaths","getInfoPlistPath","getAllEntitlementsPaths","getEntitlementsPath","getSupportingPath","resolve","basename","getExpoPlistPath","supportingPath","usingPath","relative","extraPaths","v","JSON","stringify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;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;;;;;;AAEA,MAAMA,YAAY,GAAG,CAAC,4CAAD,CAArB;;AAYO,SAASC,4BAAT,CAAsCC,WAAtC,EAAmE;AACxE,QAAM,CAACC,KAAD,EAAQ,GAAGC,KAAX,IAAoB,kBAAS,qBAAT,EAAgC;AACxDC,IAAAA,QAAQ,EAAE,IAD8C;AAExDC,IAAAA,GAAG,EAAEJ,WAFmD;AAGxDK,IAAAA,MAAM,EAAEP;AAHgD,GAAhC,CAA1B;;AAMA,MAAI,CAACG,KAAL,EAAY;AACV,UAAM,KAAIK,yBAAJ,EACH,yDAAwDN,WAAY,GADjE,CAAN;AAGD;;AAED,MAAIE,KAAK,CAACK,MAAV,EAAkB;AAChBC,IAAAA,iBAAiB,CAAC;AAChBC,MAAAA,GAAG,EAAE,qBADW;AAEhBC,MAAAA,QAAQ,EAAE,aAFM;AAGhBV,MAAAA,WAHgB;AAIhBC,MAAAA,KAJgB;AAKhBC,MAAAA;AALgB,KAAD,CAAjB;AAOD;;AAED,SAAOD,KAAP;AACD;;AAEM,SAASU,sBAAT,CAAgCX,WAAhC,EAA6D;AAClE,QAAM,CAACC,KAAD,EAAQ,GAAGC,KAAX,IAAoB,kBAAS,iCAAT,EAA4C;AACpEC,IAAAA,QAAQ,EAAE,IAD0D;AAEpEC,IAAAA,GAAG,EAAEJ,WAF+D;AAGpEK,IAAAA,MAAM,EAAEP;AAH4D,GAA5C,CAA1B;;AAMA,MAAI,CAACG,KAAL,EAAY;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,GAAGJ,iBAAiB,CAACvD,WAAD,CAAxC;AACA,SAAOgB,IAAI,GAAC6B,IAAL,CAAUc,cAAV,EAA0B,YAA1B,CAAP;AACD;;AAED,SAASnD,iBAAT,CAA2B;AACzBC,EAAAA,GADyB;AAEzBC,EAAAA,QAFyB;AAGzBV,EAAAA,WAHyB;AAIzBC,EAAAA,KAJyB;AAKzBC,EAAAA;AALyB,CAA3B,EAYG;AACD,QAAM0D,SAAS,GAAG5D,WAAW,GAAGgB,IAAI,GAAC6C,QAAL,CAAc7D,WAAd,EAA2BC,KAA3B,CAAH,GAAuCA,KAApE;AACA,QAAM6D,UAAU,GAAG9D,WAAW,GAAGE,KAAK,CAAC2B,GAAN,CAAUkC,CAAC,IAAI/C,IAAI,GAAC6C,QAAL,CAAc7D,WAAd,EAA2B+D,CAA3B,CAAf,CAAH,GAAmD7D,KAAjF;AACA,iCACG,SAAQO,GAAI,EADf,EAEG,kBAAiBC,QAAS,uBAAsBkD,SAAU,qBAAoBI,IAAI,CAACC,SAAL,CAC7EH,UAD6E,CAE7E,EAJJ;AAMD","sourcesContent":["import { existsSync, readFileSync } from 'fs';\nimport { sync as globSync } from 'glob';\nimport * as path from 'path';\n\nimport { UnexpectedError } from '../utils/errors';\nimport { addWarningIOS } from '../utils/warnings';\n\nconst ignoredPaths = ['**/@(Carthage|Pods|vendor|node_modules)/**'];\n\ninterface ProjectFile<L extends string = string> {\n path: string;\n language: L;\n contents: string;\n}\n\ntype AppleLanguage = 'objc' | 'objcpp' | 'swift';\n\nexport type AppDelegateProjectFile = ProjectFile<AppleLanguage>;\n\nexport function getAppDelegateHeaderFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.h', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(\n `Could not locate a valid AppDelegate header at root: \"${projectRoot}\"`\n );\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate-header',\n fileName: 'AppDelegate',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAppDelegateFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.@(m|mm|swift)', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(`Could not locate a valid AppDelegate at root: \"${projectRoot}\"`);\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate',\n fileName: 'AppDelegate',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAppDelegateObjcHeaderFilePath(projectRoot: string): string {\n const [using, ...extra] = globSync('ios/*/AppDelegate.h', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n\n if (!using) {\n throw new UnexpectedError(`Could not locate a valid AppDelegate.h at root: \"${projectRoot}\"`);\n }\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'app-delegate-objc-header',\n fileName: 'AppDelegate.h',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nfunction getLanguage(filePath: string): AppleLanguage {\n const extension = path.extname(filePath);\n switch (extension) {\n case '.mm':\n return 'objcpp';\n case '.m':\n case '.h':\n return 'objc';\n case '.swift':\n return 'swift';\n default:\n throw new UnexpectedError(`Unexpected iOS file extension: ${extension}`);\n }\n}\n\nexport function getFileInfo(filePath: string) {\n return {\n path: path.normalize(filePath),\n contents: readFileSync(filePath, 'utf8'),\n language: getLanguage(filePath),\n };\n}\n\nexport function getAppDelegate(projectRoot: string): AppDelegateProjectFile {\n const filePath = getAppDelegateFilePath(projectRoot);\n return getFileInfo(filePath);\n}\n\nexport function getSourceRoot(projectRoot: string): string {\n const appDelegate = getAppDelegate(projectRoot);\n return path.dirname(appDelegate.path);\n}\n\nexport function findSchemePaths(projectRoot: string): string[] {\n return globSync('ios/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n}\n\nexport function findSchemeNames(projectRoot: string): string[] {\n const schemePaths = findSchemePaths(projectRoot);\n return schemePaths.map(schemePath => path.parse(schemePath).name);\n}\n\nexport function getAllXcodeProjectPaths(projectRoot: string): string[] {\n const iosFolder = 'ios';\n const pbxprojPaths = globSync('ios/**/*.xcodeproj', { cwd: projectRoot, ignore: ignoredPaths })\n .filter(project => !/test|example|sample/i.test(project) || path.dirname(project) === iosFolder)\n // sort alphabetically to ensure this works the same across different devices (Fail in CI (linux) without this)\n .sort()\n .sort((a, b) => {\n const isAInIos = path.dirname(a) === iosFolder;\n const isBInIos = path.dirname(b) === iosFolder;\n // preserve previous sort order\n if ((isAInIos && isBInIos) || (!isAInIos && !isBInIos)) {\n return 0;\n }\n return isAInIos ? -1 : 1;\n });\n\n if (!pbxprojPaths.length) {\n throw new UnexpectedError(\n `Failed to locate the ios/*.xcodeproj files relative to path \"${projectRoot}\".`\n );\n }\n return pbxprojPaths.map(value => path.join(projectRoot, value));\n}\n\n/**\n * Get the pbxproj for the given path\n */\nexport function getXcodeProjectPath(projectRoot: string): string {\n const [using, ...extra] = getAllXcodeProjectPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'xcodeproj',\n fileName: '*.xcodeproj',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllPBXProjectPaths(projectRoot: string): string[] {\n const projectPaths = getAllXcodeProjectPaths(projectRoot);\n const paths = projectPaths\n .map(value => path.join(value, 'project.pbxproj'))\n .filter(value => existsSync(value));\n\n if (!paths.length) {\n throw new UnexpectedError(\n `Failed to locate the ios/*.xcodeproj/project.pbxproj files relative to path \"${projectRoot}\".`\n );\n }\n return paths;\n}\n\nexport function getPBXProjectPath(projectRoot: string): string {\n const [using, ...extra] = getAllPBXProjectPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'project-pbxproj',\n fileName: 'project.pbxproj',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllInfoPlistPaths(projectRoot: string): string[] {\n const paths = globSync('ios/*/Info.plist', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n }).sort(\n // longer name means more suffixes, we want the shortest possible one to be first.\n (a, b) => a.length - b.length\n );\n\n if (!paths.length) {\n throw new UnexpectedError(\n `Failed to locate Info.plist files relative to path \"${projectRoot}\".`\n );\n }\n return paths;\n}\n\nexport function getInfoPlistPath(projectRoot: string): string {\n const [using, ...extra] = getAllInfoPlistPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'info-plist',\n fileName: 'Info.plist',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using;\n}\n\nexport function getAllEntitlementsPaths(projectRoot: string): string[] {\n const paths = globSync('ios/*/*.entitlements', {\n absolute: true,\n cwd: projectRoot,\n ignore: ignoredPaths,\n });\n return paths;\n}\n\n/**\n * Get the entitlements file path if it exists.\n *\n * @param projectRoot\n */\nexport function getEntitlementsPath(projectRoot: string): string | null {\n const [using, ...extra] = getAllEntitlementsPaths(projectRoot);\n\n if (extra.length) {\n warnMultipleFiles({\n tag: 'entitlements',\n fileName: '*.entitlements',\n projectRoot,\n using,\n extra,\n });\n }\n\n return using ?? null;\n}\n\nexport function getSupportingPath(projectRoot: string): string {\n return path.resolve(projectRoot, 'ios', path.basename(getSourceRoot(projectRoot)), 'Supporting');\n}\n\nexport function getExpoPlistPath(projectRoot: string): string {\n const supportingPath = getSupportingPath(projectRoot);\n return path.join(supportingPath, 'Expo.plist');\n}\n\nfunction warnMultipleFiles({\n tag,\n fileName,\n projectRoot,\n using,\n extra,\n}: {\n tag: string;\n fileName: string;\n projectRoot?: string;\n using: string;\n extra: string[];\n}) {\n const usingPath = projectRoot ? path.relative(projectRoot, using) : using;\n const extraPaths = projectRoot ? extra.map(v => path.relative(projectRoot, v)) : extra;\n addWarningIOS(\n `paths-${tag}`,\n `Found multiple ${fileName} file paths, using \"${usingPath}\". Ignored paths: ${JSON.stringify(\n extraPaths\n )}`\n );\n}\n"],"file":"Paths.js"}
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.setProvisioningProfileForPbxproj = setProvisioningProfileForPbxproj;
|
|
7
7
|
|
|
8
|
-
function
|
|
9
|
-
const data = _interopRequireDefault(require("fs
|
|
8
|
+
function _fs() {
|
|
9
|
+
const data = _interopRequireDefault(require("fs"));
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
_fs = function () {
|
|
12
12
|
return data;
|
|
13
13
|
};
|
|
14
14
|
|
|
@@ -62,7 +62,7 @@ function setProvisioningProfileForPbxproj(projectRoot, {
|
|
|
62
62
|
item.attributes.TargetAttributes[nativeTargetId].ProvisioningStyle = 'Manual';
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
_fs().default.writeFileSync(project.filepath, project.writeSync());
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const ensureQuotes = value => {
|