@expo/config-plugins 5.0.3 → 6.0.0
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/build/Plugin.types.d.ts +7 -7
- package/build/Plugin.types.js +0 -9
- package/build/Plugin.types.js.map +1 -1
- package/build/android/AllowBackup.js +0 -15
- package/build/android/AllowBackup.js.map +1 -1
- package/build/android/BuildProperties.js +2 -16
- package/build/android/BuildProperties.js.map +1 -1
- package/build/android/Colors.js +3 -25
- package/build/android/Colors.js.map +1 -1
- package/build/android/EasBuild.js +2 -22
- package/build/android/EasBuild.js.map +1 -1
- package/build/android/EasBuildGradleScript.js.map +1 -1
- package/build/android/GoogleMapsApiKey.js +0 -12
- package/build/android/GoogleMapsApiKey.js.map +1 -1
- package/build/android/GoogleServices.js +10 -48
- package/build/android/GoogleServices.js.map +1 -1
- package/build/android/IntentFilters.d.ts +1 -1
- package/build/android/IntentFilters.js +8 -24
- package/build/android/IntentFilters.js.map +1 -1
- package/build/android/Manifest.d.ts +19 -19
- package/build/android/Manifest.js +7 -66
- package/build/android/Manifest.js.map +1 -1
- package/build/android/Name.js +6 -27
- package/build/android/Name.js.map +1 -1
- package/build/android/Orientation.js +2 -12
- package/build/android/Orientation.js.map +1 -1
- package/build/android/Package.js +26 -111
- package/build/android/Package.js.map +1 -1
- package/build/android/Paths.d.ts +2 -2
- package/build/android/Paths.js +0 -47
- package/build/android/Paths.js.map +1 -1
- package/build/android/Permissions.js +8 -52
- package/build/android/Permissions.js.map +1 -1
- package/build/android/PrimaryColor.js +0 -18
- package/build/android/PrimaryColor.js.map +1 -1
- package/build/android/Properties.d.ts +1 -1
- package/build/android/Properties.js +0 -9
- package/build/android/Properties.js.map +1 -1
- package/build/android/Resources.d.ts +4 -4
- package/build/android/Resources.js +9 -29
- package/build/android/Resources.js.map +1 -1
- package/build/android/Scheme.d.ts +1 -1
- package/build/android/Scheme.js +13 -66
- package/build/android/Scheme.js.map +1 -1
- package/build/android/StatusBar.js +5 -33
- package/build/android/StatusBar.js.map +1 -1
- package/build/android/Strings.js +0 -14
- package/build/android/Strings.js.map +1 -1
- package/build/android/Styles.js +7 -34
- package/build/android/Styles.js.map +1 -1
- package/build/android/Updates.d.ts +2 -0
- package/build/android/Updates.js +50 -47
- package/build/android/Updates.js.map +1 -1
- package/build/android/Version.js +3 -29
- package/build/android/Version.js.map +1 -1
- package/build/android/WindowSoftInputMode.js +0 -14
- package/build/android/WindowSoftInputMode.js.map +1 -1
- package/build/android/codeMod.js +6 -22
- package/build/android/codeMod.js.map +1 -1
- package/build/android/index.js +0 -94
- package/build/android/index.js.map +1 -1
- package/build/index.js +2 -65
- package/build/index.js.map +1 -1
- package/build/ios/Bitcode.d.ts +1 -1
- package/build/ios/Bitcode.js +8 -28
- package/build/ios/Bitcode.js.map +1 -1
- package/build/ios/BuildProperties.js +2 -14
- package/build/ios/BuildProperties.js.map +1 -1
- package/build/ios/BuildScheme.js +2 -34
- package/build/ios/BuildScheme.js.map +1 -1
- package/build/ios/BundleIdentifier.js +13 -72
- package/build/ios/BundleIdentifier.js.map +1 -1
- package/build/ios/DeviceFamily.js +6 -24
- package/build/ios/DeviceFamily.js.map +1 -1
- package/build/ios/Entitlements.js +4 -45
- package/build/ios/Entitlements.js.map +1 -1
- package/build/ios/Google.d.ts +2 -2
- package/build/ios/Google.js +11 -66
- package/build/ios/Google.js.map +1 -1
- package/build/ios/IosConfig.types.d.ts +6 -11
- package/build/ios/IosConfig.types.js.map +1 -1
- package/build/ios/Locales.d.ts +3 -3
- package/build/ios/Locales.js +12 -43
- package/build/ios/Locales.js.map +1 -1
- package/build/ios/Maps.js +15 -53
- package/build/ios/Maps.js.map +1 -1
- package/build/ios/Name.js +7 -31
- package/build/ios/Name.js.map +1 -1
- package/build/ios/Orientation.js +2 -10
- package/build/ios/Orientation.js.map +1 -1
- package/build/ios/Paths.d.ts +2 -2
- package/build/ios/Paths.js +8 -73
- package/build/ios/Paths.js.map +1 -1
- package/build/ios/Permissions.js +1 -16
- package/build/ios/Permissions.js.map +1 -1
- package/build/ios/ProvisioningProfile.d.ts +1 -1
- package/build/ios/ProvisioningProfile.js +0 -18
- package/build/ios/ProvisioningProfile.js.map +1 -1
- package/build/ios/RequiresFullScreen.js +19 -31
- package/build/ios/RequiresFullScreen.js.map +1 -1
- package/build/ios/Scheme.js +12 -34
- package/build/ios/Scheme.js.map +1 -1
- package/build/ios/Swift.js +16 -50
- package/build/ios/Swift.js.map +1 -1
- package/build/ios/Target.js +0 -30
- package/build/ios/Target.js.map +1 -1
- package/build/ios/Updates.js +10 -49
- package/build/ios/Updates.js.map +1 -1
- package/build/ios/UsesNonExemptEncryption.js +4 -10
- package/build/ios/UsesNonExemptEncryption.js.map +1 -1
- package/build/ios/Version.js +4 -11
- package/build/ios/Version.js.map +1 -1
- package/build/ios/XcodeProjectFile.js +5 -23
- package/build/ios/XcodeProjectFile.js.map +1 -1
- package/build/ios/codeMod.js +19 -60
- package/build/ios/codeMod.js.map +1 -1
- package/build/ios/index.js +0 -97
- package/build/ios/index.js.map +1 -1
- package/build/ios/utils/Xcodeproj.d.ts +6 -6
- package/build/ios/utils/Xcodeproj.js +15 -101
- package/build/ios/utils/Xcodeproj.js.map +1 -1
- package/build/ios/utils/getInfoPlistPath.js +2 -15
- package/build/ios/utils/getInfoPlistPath.js.map +1 -1
- package/build/ios/utils/string.js +0 -1
- package/build/ios/utils/string.js.map +1 -1
- package/build/plugins/android-plugins.d.ts +2 -2
- package/build/plugins/android-plugins.js +11 -42
- package/build/plugins/android-plugins.js.map +1 -1
- package/build/plugins/createBaseMod.d.ts +3 -3
- package/build/plugins/createBaseMod.js +8 -25
- package/build/plugins/createBaseMod.js.map +1 -1
- package/build/plugins/ios-plugins.d.ts +2 -2
- package/build/plugins/ios-plugins.js +8 -48
- package/build/plugins/ios-plugins.js.map +1 -1
- package/build/plugins/mod-compiler.js +21 -72
- package/build/plugins/mod-compiler.js.map +1 -1
- package/build/plugins/withAndroidBaseMods.d.ts +1 -1
- package/build/plugins/withAndroidBaseMods.js +4 -89
- package/build/plugins/withAndroidBaseMods.js.map +1 -1
- package/build/plugins/withDangerousMod.js +0 -5
- package/build/plugins/withDangerousMod.js.map +1 -1
- package/build/plugins/withIosBaseMods.d.ts +1 -1
- package/build/plugins/withIosBaseMods.js +26 -118
- package/build/plugins/withIosBaseMods.js.map +1 -1
- package/build/plugins/withMod.d.ts +1 -1
- package/build/plugins/withMod.js +24 -59
- package/build/plugins/withMod.js.map +1 -1
- package/build/plugins/withPlugins.js +0 -9
- package/build/plugins/withPlugins.js.map +1 -1
- package/build/plugins/withRunOnce.js +3 -9
- package/build/plugins/withRunOnce.js.map +1 -1
- package/build/plugins/withStaticPlugin.js +21 -43
- package/build/plugins/withStaticPlugin.js.map +1 -1
- package/build/utils/BuildProperties.types.d.ts +2 -2
- package/build/utils/BuildProperties.types.js.map +1 -1
- package/build/utils/Updates.d.ts +3 -1
- package/build/utils/Updates.js +18 -77
- package/build/utils/Updates.js.map +1 -1
- package/build/utils/XML.d.ts +1 -1
- package/build/utils/XML.js +7 -44
- package/build/utils/XML.js.map +1 -1
- package/build/utils/commonCodeMod.js +2 -10
- package/build/utils/commonCodeMod.js.map +1 -1
- package/build/utils/errors.d.ts +1 -1
- package/build/utils/errors.js +3 -11
- package/build/utils/errors.js.map +1 -1
- package/build/utils/fs.js +1 -12
- package/build/utils/fs.js.map +1 -1
- package/build/utils/generateCode.d.ts +1 -1
- package/build/utils/generateCode.js +8 -25
- package/build/utils/generateCode.js.map +1 -1
- package/build/utils/history.d.ts +1 -1
- package/build/utils/history.js +0 -6
- package/build/utils/history.js.map +1 -1
- package/build/utils/matchBrackets.d.ts +3 -3
- package/build/utils/matchBrackets.js +2 -17
- package/build/utils/matchBrackets.js.map +1 -1
- package/build/utils/modules.js +0 -10
- package/build/utils/modules.js.map +1 -1
- package/build/utils/obj.js +0 -4
- package/build/utils/obj.js.map +1 -1
- package/build/utils/plugin-resolver.js +25 -69
- package/build/utils/plugin-resolver.js.map +1 -1
- package/build/utils/sortObject.js +4 -10
- package/build/utils/sortObject.js.map +1 -1
- package/build/utils/versions.js +0 -10
- package/build/utils/versions.js.map +1 -1
- package/build/utils/warnings.js +1 -9
- package/build/utils/warnings.js.map +1 -1
- package/package.json +5 -5
package/build/ios/Locales.js
CHANGED
|
@@ -7,69 +7,49 @@ exports.getLocales = getLocales;
|
|
|
7
7
|
exports.getResolvedLocalesAsync = getResolvedLocalesAsync;
|
|
8
8
|
exports.setLocalesAsync = setLocalesAsync;
|
|
9
9
|
exports.withLocales = void 0;
|
|
10
|
-
|
|
11
10
|
function _jsonFile() {
|
|
12
11
|
const data = _interopRequireDefault(require("@expo/json-file"));
|
|
13
|
-
|
|
14
12
|
_jsonFile = function () {
|
|
15
13
|
return data;
|
|
16
14
|
};
|
|
17
|
-
|
|
18
15
|
return data;
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
function _fs() {
|
|
22
18
|
const data = _interopRequireDefault(require("fs"));
|
|
23
|
-
|
|
24
19
|
_fs = function () {
|
|
25
20
|
return data;
|
|
26
21
|
};
|
|
27
|
-
|
|
28
22
|
return data;
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
function _path() {
|
|
32
25
|
const data = require("path");
|
|
33
|
-
|
|
34
26
|
_path = function () {
|
|
35
27
|
return data;
|
|
36
28
|
};
|
|
37
|
-
|
|
38
29
|
return data;
|
|
39
30
|
}
|
|
40
|
-
|
|
41
31
|
function _iosPlugins() {
|
|
42
32
|
const data = require("../plugins/ios-plugins");
|
|
43
|
-
|
|
44
33
|
_iosPlugins = function () {
|
|
45
34
|
return data;
|
|
46
35
|
};
|
|
47
|
-
|
|
48
36
|
return data;
|
|
49
37
|
}
|
|
50
|
-
|
|
51
38
|
function _warnings() {
|
|
52
39
|
const data = require("../utils/warnings");
|
|
53
|
-
|
|
54
40
|
_warnings = function () {
|
|
55
41
|
return data;
|
|
56
42
|
};
|
|
57
|
-
|
|
58
43
|
return data;
|
|
59
44
|
}
|
|
60
|
-
|
|
61
45
|
function _Xcodeproj() {
|
|
62
46
|
const data = require("./utils/Xcodeproj");
|
|
63
|
-
|
|
64
47
|
_Xcodeproj = function () {
|
|
65
48
|
return data;
|
|
66
49
|
};
|
|
67
|
-
|
|
68
50
|
return data;
|
|
69
51
|
}
|
|
70
|
-
|
|
71
52
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
72
|
-
|
|
73
53
|
const withLocales = config => {
|
|
74
54
|
return (0, _iosPlugins().withXcodeProject)(config, async config => {
|
|
75
55
|
config.modResults = await setLocalesAsync(config, {
|
|
@@ -79,51 +59,44 @@ const withLocales = config => {
|
|
|
79
59
|
return config;
|
|
80
60
|
});
|
|
81
61
|
};
|
|
82
|
-
|
|
83
62
|
exports.withLocales = withLocales;
|
|
84
|
-
|
|
85
63
|
function getLocales(config) {
|
|
86
64
|
var _config$locales;
|
|
87
|
-
|
|
88
65
|
return (_config$locales = config.locales) !== null && _config$locales !== void 0 ? _config$locales : null;
|
|
89
66
|
}
|
|
90
|
-
|
|
91
67
|
async function setLocalesAsync(config, {
|
|
92
68
|
projectRoot,
|
|
93
69
|
project
|
|
94
70
|
}) {
|
|
95
71
|
const locales = getLocales(config);
|
|
96
|
-
|
|
97
72
|
if (!locales) {
|
|
98
73
|
return project;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
74
|
+
}
|
|
75
|
+
// possibly validate CFBundleAllowMixedLocalizations is enabled
|
|
102
76
|
const localesMap = await getResolvedLocalesAsync(projectRoot, locales);
|
|
103
77
|
const projectName = (0, _Xcodeproj().getProjectName)(projectRoot);
|
|
104
|
-
const supportingDirectory = (0, _path().join)(projectRoot, 'ios', projectName, 'Supporting');
|
|
78
|
+
const supportingDirectory = (0, _path().join)(projectRoot, 'ios', projectName, 'Supporting');
|
|
105
79
|
|
|
80
|
+
// TODO: Should we delete all before running? Revisit after we land on a lock file.
|
|
106
81
|
const stringName = 'InfoPlist.strings';
|
|
107
|
-
|
|
108
82
|
for (const [lang, localizationObj] of Object.entries(localesMap)) {
|
|
109
|
-
const dir = (0, _path().join)(supportingDirectory, `${lang}.lproj`);
|
|
110
|
-
|
|
83
|
+
const dir = (0, _path().join)(supportingDirectory, `${lang}.lproj`);
|
|
84
|
+
// await fs.ensureDir(dir);
|
|
111
85
|
await _fs().default.promises.mkdir(dir, {
|
|
112
86
|
recursive: true
|
|
113
87
|
});
|
|
114
88
|
const strings = (0, _path().join)(dir, stringName);
|
|
115
89
|
const buffer = [];
|
|
116
|
-
|
|
117
90
|
for (const [plistKey, localVersion] of Object.entries(localizationObj)) {
|
|
118
91
|
buffer.push(`${plistKey} = "${localVersion}";`);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
92
|
+
}
|
|
93
|
+
// Write the file to the file system.
|
|
122
94
|
await _fs().default.promises.writeFile(strings, buffer.join('\n'));
|
|
123
|
-
const groupName = `${projectName}/Supporting/${lang}.lproj`;
|
|
124
|
-
|
|
125
|
-
const group = (0, _Xcodeproj().ensureGroupRecursively)(project, groupName);
|
|
95
|
+
const groupName = `${projectName}/Supporting/${lang}.lproj`;
|
|
96
|
+
// deep find the correct folder
|
|
97
|
+
const group = (0, _Xcodeproj().ensureGroupRecursively)(project, groupName);
|
|
126
98
|
|
|
99
|
+
// Ensure the file doesn't already exist
|
|
127
100
|
if (!(group !== null && group !== void 0 && group.children.some(({
|
|
128
101
|
comment
|
|
129
102
|
}) => comment === stringName))) {
|
|
@@ -137,13 +110,10 @@ async function setLocalesAsync(config, {
|
|
|
137
110
|
});
|
|
138
111
|
}
|
|
139
112
|
}
|
|
140
|
-
|
|
141
113
|
return project;
|
|
142
114
|
}
|
|
143
|
-
|
|
144
115
|
async function getResolvedLocalesAsync(projectRoot, input) {
|
|
145
116
|
const locales = {};
|
|
146
|
-
|
|
147
117
|
for (const [lang, localeJsonPath] of Object.entries(input)) {
|
|
148
118
|
if (typeof localeJsonPath === 'string') {
|
|
149
119
|
try {
|
|
@@ -158,7 +128,6 @@ async function getResolvedLocalesAsync(projectRoot, input) {
|
|
|
158
128
|
locales[lang] = localeJsonPath;
|
|
159
129
|
}
|
|
160
130
|
}
|
|
161
|
-
|
|
162
131
|
return locales;
|
|
163
132
|
}
|
|
164
133
|
//# sourceMappingURL=Locales.js.map
|
package/build/ios/Locales.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Locales.js","names":["withLocales","config","withXcodeProject","modResults","setLocalesAsync","projectRoot","modRequest","project","getLocales","locales","localesMap","getResolvedLocalesAsync","projectName","getProjectName","supportingDirectory","join","stringName","lang","localizationObj","Object","entries","dir","fs","promises","mkdir","recursive","strings","buffer","plistKey","localVersion","push","writeFile","groupName","group","ensureGroupRecursively","children","some","comment","addResourceFileToGroup","filepath","relative","isBuildFile","verbose","input","localeJsonPath","JsonFile","readAsync","addWarningIOS"],"sources":["../../src/ios/Locales.ts"],"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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Locales.js","names":["withLocales","config","withXcodeProject","modResults","setLocalesAsync","projectRoot","modRequest","project","getLocales","locales","localesMap","getResolvedLocalesAsync","projectName","getProjectName","supportingDirectory","join","stringName","lang","localizationObj","Object","entries","dir","fs","promises","mkdir","recursive","strings","buffer","plistKey","localVersion","push","writeFile","groupName","group","ensureGroupRecursively","children","some","comment","addResourceFileToGroup","filepath","relative","isBuildFile","verbose","input","localeJsonPath","JsonFile","readAsync","addWarningIOS"],"sources":["../../src/ios/Locales.ts"],"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"],"mappings":";;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;E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4B,mBAAQ,CAACC,SAAS,CAAC,IAAA/B,YAAI,EAACV,WAAW,EAAEuC,cAAc,CAAC,CAAC;MAC7E,CAAC,CAAC,MAAM;QACN;QACA,IAAAG,yBAAa,EACV,WAAU9B,IAAK,EAAC,EAChB,qDAAoDA,IAAK,EAAC,EAC3D,wEAAwE,CACzE;MACH;IACF,CAAC,MAAM;MACL;MACA;MACAR,OAAO,CAACQ,IAAI,CAAC,GAAG2B,cAAc;IAChC;EACF;EAEA,OAAOnC,OAAO;AAChB"}
|
package/build/ios/Maps.js
CHANGED
|
@@ -13,114 +13,89 @@ exports.removeGoogleMapsAppDelegateInit = removeGoogleMapsAppDelegateInit;
|
|
|
13
13
|
exports.removeMapsCocoaPods = removeMapsCocoaPods;
|
|
14
14
|
exports.setGoogleMapsApiKey = setGoogleMapsApiKey;
|
|
15
15
|
exports.withMaps = void 0;
|
|
16
|
-
|
|
17
16
|
function _fs() {
|
|
18
17
|
const data = _interopRequireDefault(require("fs"));
|
|
19
|
-
|
|
20
18
|
_fs = function () {
|
|
21
19
|
return data;
|
|
22
20
|
};
|
|
23
|
-
|
|
24
21
|
return data;
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
function _path() {
|
|
28
24
|
const data = _interopRequireDefault(require("path"));
|
|
29
|
-
|
|
30
25
|
_path = function () {
|
|
31
26
|
return data;
|
|
32
27
|
};
|
|
33
|
-
|
|
34
28
|
return data;
|
|
35
29
|
}
|
|
36
|
-
|
|
37
30
|
function _resolveFrom() {
|
|
38
31
|
const data = _interopRequireDefault(require("resolve-from"));
|
|
39
|
-
|
|
40
32
|
_resolveFrom = function () {
|
|
41
33
|
return data;
|
|
42
34
|
};
|
|
43
|
-
|
|
44
35
|
return data;
|
|
45
36
|
}
|
|
46
|
-
|
|
47
37
|
function _iosPlugins() {
|
|
48
38
|
const data = require("../plugins/ios-plugins");
|
|
49
|
-
|
|
50
39
|
_iosPlugins = function () {
|
|
51
40
|
return data;
|
|
52
41
|
};
|
|
53
|
-
|
|
54
42
|
return data;
|
|
55
43
|
}
|
|
56
|
-
|
|
57
44
|
function _withDangerousMod() {
|
|
58
45
|
const data = require("../plugins/withDangerousMod");
|
|
59
|
-
|
|
60
46
|
_withDangerousMod = function () {
|
|
61
47
|
return data;
|
|
62
48
|
};
|
|
63
|
-
|
|
64
49
|
return data;
|
|
65
50
|
}
|
|
66
|
-
|
|
67
51
|
function _generateCode() {
|
|
68
52
|
const data = require("../utils/generateCode");
|
|
69
|
-
|
|
70
53
|
_generateCode = function () {
|
|
71
54
|
return data;
|
|
72
55
|
};
|
|
73
|
-
|
|
74
56
|
return data;
|
|
75
57
|
}
|
|
76
|
-
|
|
77
58
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
59
|
+
const debug = require('debug')('expo:config-plugins:ios:maps');
|
|
78
60
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
61
|
+
// Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules), and SDK +44 React AppDelegate subscriber.
|
|
82
62
|
const MATCH_INIT = /(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[\[RCTBridge alloc\])|(\[self\.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions\])/g;
|
|
83
63
|
exports.MATCH_INIT = MATCH_INIT;
|
|
84
64
|
const withGoogleMapsKey = (0, _iosPlugins().createInfoPlistPlugin)(setGoogleMapsApiKey, 'withGoogleMapsKey');
|
|
85
|
-
|
|
86
65
|
const withMaps = config => {
|
|
87
66
|
config = withGoogleMapsKey(config);
|
|
88
|
-
const apiKey = getGoogleMapsApiKey(config);
|
|
67
|
+
const apiKey = getGoogleMapsApiKey(config);
|
|
68
|
+
// Technically adds react-native-maps (Apple maps) and google maps.
|
|
89
69
|
|
|
90
70
|
debug('Google Maps API Key:', apiKey);
|
|
91
71
|
config = withMapsCocoaPods(config, {
|
|
92
72
|
useGoogleMaps: !!apiKey
|
|
93
|
-
});
|
|
73
|
+
});
|
|
94
74
|
|
|
75
|
+
// Adds/Removes AppDelegate setup for Google Maps API on iOS
|
|
95
76
|
config = withGoogleMapsAppDelegate(config, {
|
|
96
77
|
apiKey
|
|
97
78
|
});
|
|
98
79
|
return config;
|
|
99
80
|
};
|
|
100
|
-
|
|
101
81
|
exports.withMaps = withMaps;
|
|
102
|
-
|
|
103
82
|
function getGoogleMapsApiKey(config) {
|
|
104
83
|
var _config$ios$config$go, _config$ios, _config$ios$config;
|
|
105
|
-
|
|
106
84
|
return (_config$ios$config$go = (_config$ios = config.ios) === null || _config$ios === void 0 ? void 0 : (_config$ios$config = _config$ios.config) === null || _config$ios$config === void 0 ? void 0 : _config$ios$config.googleMapsApiKey) !== null && _config$ios$config$go !== void 0 ? _config$ios$config$go : null;
|
|
107
85
|
}
|
|
108
|
-
|
|
109
86
|
function setGoogleMapsApiKey(config, {
|
|
110
87
|
GMSApiKey,
|
|
111
88
|
...infoPlist
|
|
112
89
|
}) {
|
|
113
90
|
const apiKey = getGoogleMapsApiKey(config);
|
|
114
|
-
|
|
115
91
|
if (apiKey === null) {
|
|
116
92
|
return infoPlist;
|
|
117
93
|
}
|
|
118
|
-
|
|
119
|
-
|
|
94
|
+
return {
|
|
95
|
+
...infoPlist,
|
|
120
96
|
GMSApiKey: apiKey
|
|
121
97
|
};
|
|
122
98
|
}
|
|
123
|
-
|
|
124
99
|
function addGoogleMapsAppDelegateImport(src) {
|
|
125
100
|
const newSrc = [];
|
|
126
101
|
newSrc.push('#if __has_include(<GoogleMaps/GoogleMaps.h>)', '#import <GoogleMaps/GoogleMaps.h>', '#endif');
|
|
@@ -133,14 +108,12 @@ function addGoogleMapsAppDelegateImport(src) {
|
|
|
133
108
|
comment: '//'
|
|
134
109
|
});
|
|
135
110
|
}
|
|
136
|
-
|
|
137
111
|
function removeGoogleMapsAppDelegateImport(src) {
|
|
138
112
|
return (0, _generateCode().removeContents)({
|
|
139
113
|
tag: 'react-native-maps-import',
|
|
140
114
|
src
|
|
141
115
|
});
|
|
142
116
|
}
|
|
143
|
-
|
|
144
117
|
function addGoogleMapsAppDelegateInit(src, apiKey) {
|
|
145
118
|
const newSrc = [];
|
|
146
119
|
newSrc.push('#if __has_include(<GoogleMaps/GoogleMaps.h>)', ` [GMSServices provideAPIKey:@"${apiKey}"];`, '#endif');
|
|
@@ -153,19 +126,17 @@ function addGoogleMapsAppDelegateInit(src, apiKey) {
|
|
|
153
126
|
comment: '//'
|
|
154
127
|
});
|
|
155
128
|
}
|
|
156
|
-
|
|
157
129
|
function removeGoogleMapsAppDelegateInit(src) {
|
|
158
130
|
return (0, _generateCode().removeContents)({
|
|
159
131
|
tag: 'react-native-maps-init',
|
|
160
132
|
src
|
|
161
133
|
});
|
|
162
134
|
}
|
|
135
|
+
|
|
163
136
|
/**
|
|
164
137
|
* @param src The contents of the Podfile.
|
|
165
138
|
* @returns Podfile with Google Maps added.
|
|
166
139
|
*/
|
|
167
|
-
|
|
168
|
-
|
|
169
140
|
function addMapsCocoaPods(src) {
|
|
170
141
|
return (0, _generateCode().mergeContents)({
|
|
171
142
|
tag: 'react-native-maps',
|
|
@@ -176,27 +147,26 @@ function addMapsCocoaPods(src) {
|
|
|
176
147
|
comment: '#'
|
|
177
148
|
});
|
|
178
149
|
}
|
|
179
|
-
|
|
180
150
|
function removeMapsCocoaPods(src) {
|
|
181
151
|
return (0, _generateCode().removeContents)({
|
|
182
152
|
tag: 'react-native-maps',
|
|
183
153
|
src
|
|
184
154
|
});
|
|
185
155
|
}
|
|
186
|
-
|
|
187
156
|
function isReactNativeMapsInstalled(projectRoot) {
|
|
188
157
|
const resolved = _resolveFrom().default.silent(projectRoot, 'react-native-maps/package.json');
|
|
189
|
-
|
|
190
158
|
return resolved ? _path().default.dirname(resolved) : null;
|
|
191
159
|
}
|
|
192
|
-
|
|
193
160
|
function isReactNativeMapsAutolinked(config) {
|
|
194
161
|
// Only add the native code changes if we know that the package is going to be linked natively.
|
|
195
162
|
// This is specifically for monorepo support where one app might have react-native-maps (adding it to the node_modules)
|
|
196
163
|
// but another app will not have it installed in the package.json, causing it to not be linked natively.
|
|
197
164
|
// This workaround only exists because react-native-maps doesn't have a config plugin vendored in the package.
|
|
165
|
+
|
|
198
166
|
// TODO: `react-native-maps` doesn't use Expo autolinking so we cannot safely disable the module.
|
|
199
|
-
return true;
|
|
167
|
+
return true;
|
|
168
|
+
|
|
169
|
+
// return (
|
|
200
170
|
// !config._internal?.autolinkedModules ||
|
|
201
171
|
// config._internal.autolinkedModules.includes('react-native-maps')
|
|
202
172
|
// );
|
|
@@ -207,16 +177,14 @@ const withMapsCocoaPods = (config, {
|
|
|
207
177
|
}) => {
|
|
208
178
|
return (0, _withDangerousMod().withDangerousMod)(config, ['ios', async config => {
|
|
209
179
|
const filePath = _path().default.join(config.modRequest.platformProjectRoot, 'Podfile');
|
|
210
|
-
|
|
211
180
|
const contents = await _fs().default.promises.readFile(filePath, 'utf-8');
|
|
212
|
-
let results;
|
|
181
|
+
let results;
|
|
182
|
+
// Only add the block if react-native-maps is installed in the project (best effort).
|
|
213
183
|
// Generally prebuild runs after a yarn install so this should always work as expected.
|
|
214
|
-
|
|
215
184
|
const googleMapsPath = isReactNativeMapsInstalled(config.modRequest.projectRoot);
|
|
216
185
|
const isLinked = isReactNativeMapsAutolinked(config);
|
|
217
186
|
debug('Is Expo Autolinked:', isLinked);
|
|
218
187
|
debug('react-native-maps path:', googleMapsPath);
|
|
219
|
-
|
|
220
188
|
if (isLinked && googleMapsPath && useGoogleMaps) {
|
|
221
189
|
try {
|
|
222
190
|
results = addMapsCocoaPods(contents);
|
|
@@ -224,22 +192,18 @@ const withMapsCocoaPods = (config, {
|
|
|
224
192
|
if (error.code === 'ERR_NO_MATCH') {
|
|
225
193
|
throw new Error(`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.`);
|
|
226
194
|
}
|
|
227
|
-
|
|
228
195
|
throw error;
|
|
229
196
|
}
|
|
230
197
|
} else {
|
|
231
198
|
// If the package is no longer installed, then remove the block.
|
|
232
199
|
results = removeMapsCocoaPods(contents);
|
|
233
200
|
}
|
|
234
|
-
|
|
235
201
|
if (results.didMerge || results.didClear) {
|
|
236
202
|
await _fs().default.promises.writeFile(filePath, results.contents);
|
|
237
203
|
}
|
|
238
|
-
|
|
239
204
|
return config;
|
|
240
205
|
}]);
|
|
241
206
|
};
|
|
242
|
-
|
|
243
207
|
const withGoogleMapsAppDelegate = (config, {
|
|
244
208
|
apiKey
|
|
245
209
|
}) => {
|
|
@@ -253,7 +217,6 @@ const withGoogleMapsAppDelegate = (config, {
|
|
|
253
217
|
if (error.code === 'ERR_NO_MATCH') {
|
|
254
218
|
throw new Error(`Cannot add Google Maps to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.`);
|
|
255
219
|
}
|
|
256
|
-
|
|
257
220
|
throw error;
|
|
258
221
|
}
|
|
259
222
|
} else {
|
|
@@ -263,7 +226,6 @@ const withGoogleMapsAppDelegate = (config, {
|
|
|
263
226
|
} else {
|
|
264
227
|
throw new Error(`Cannot setup Google Maps because the project AppDelegate is not a supported language: ${config.modResults.language}`);
|
|
265
228
|
}
|
|
266
|
-
|
|
267
229
|
return config;
|
|
268
230
|
});
|
|
269
231
|
};
|
package/build/ios/Maps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maps.js","names":["debug","require","MATCH_INIT","withGoogleMapsKey","createInfoPlistPlugin","setGoogleMapsApiKey","withMaps","config","apiKey","getGoogleMapsApiKey","withMapsCocoaPods","useGoogleMaps","withGoogleMapsAppDelegate","ios","googleMapsApiKey","GMSApiKey","infoPlist","addGoogleMapsAppDelegateImport","src","newSrc","push","mergeContents","tag","join","anchor","offset","comment","removeGoogleMapsAppDelegateImport","removeContents","addGoogleMapsAppDelegateInit","removeGoogleMapsAppDelegateInit","addMapsCocoaPods","removeMapsCocoaPods","isReactNativeMapsInstalled","projectRoot","resolved","resolveFrom","silent","path","dirname","isReactNativeMapsAutolinked","withDangerousMod","filePath","modRequest","platformProjectRoot","contents","fs","promises","readFile","results","googleMapsPath","isLinked","error","code","Error","didMerge","didClear","writeFile","withAppDelegate","includes","modResults","language"],"sources":["../../src/ios/Maps.ts"],"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 =\n /(?:(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"],"mappings":";;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;AAEA,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAD,CAAP,CAAiB,8BAAjB,CAAd,C,CAEA;;;AACO,MAAMC,UAAU,GACrB,2MADK;;AAGP,MAAMC,iBAAiB,GAAG,IAAAC,mCAAA,EAAsBC,mBAAtB,EAA2C,mBAA3C,CAA1B;;AAEO,MAAMC,QAAsB,GAAIC,MAAD,IAAY;EAChDA,MAAM,GAAGJ,iBAAiB,CAACI,MAAD,CAA1B;EAEA,MAAMC,MAAM,GAAGC,mBAAmB,CAACF,MAAD,CAAlC,CAHgD,CAIhD;;EAEAP,KAAK,CAAC,sBAAD,EAAyBQ,MAAzB,CAAL;EACAD,MAAM,GAAGG,iBAAiB,CAACH,MAAD,EAAS;IAAEI,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PlistPlugin","setGoogleMapsApiKey","withMaps","config","apiKey","getGoogleMapsApiKey","withMapsCocoaPods","useGoogleMaps","withGoogleMapsAppDelegate","ios","googleMapsApiKey","GMSApiKey","infoPlist","addGoogleMapsAppDelegateImport","src","newSrc","push","mergeContents","tag","join","anchor","offset","comment","removeGoogleMapsAppDelegateImport","removeContents","addGoogleMapsAppDelegateInit","removeGoogleMapsAppDelegateInit","addMapsCocoaPods","removeMapsCocoaPods","isReactNativeMapsInstalled","projectRoot","resolved","resolveFrom","silent","path","dirname","isReactNativeMapsAutolinked","withDangerousMod","filePath","modRequest","platformProjectRoot","contents","fs","promises","readFile","results","googleMapsPath","isLinked","error","code","Error","didMerge","didClear","writeFile","withAppDelegate","includes","modResults","language"],"sources":["../../src/ios/Maps.ts"],"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 =\n /(?:(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"],"mappings":";;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAoF;AAEpF,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,8BAA8B,CAAuB;;AAEpF;AACO,MAAMC,UAAU,GACrB,2MAA2M;AAAC;AAE9M,MAAMC,iBAAiB,GAAG,IAAAC,mCAAqB,EAACC,mBA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H;IACH;IACA,OAAOtD,MAAM;EACf,CAAC,CAAC;AACJ,CAAC"}
|
package/build/ios/Name.js
CHANGED
|
@@ -8,37 +8,27 @@ exports.setDisplayName = setDisplayName;
|
|
|
8
8
|
exports.setName = setName;
|
|
9
9
|
exports.setProductName = setProductName;
|
|
10
10
|
exports.withProductName = exports.withName = exports.withDisplayName = void 0;
|
|
11
|
-
|
|
12
11
|
function _iosPlugins() {
|
|
13
12
|
const data = require("../plugins/ios-plugins");
|
|
14
|
-
|
|
15
13
|
_iosPlugins = function () {
|
|
16
14
|
return data;
|
|
17
15
|
};
|
|
18
|
-
|
|
19
16
|
return data;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
function _Target() {
|
|
23
19
|
const data = require("./Target");
|
|
24
|
-
|
|
25
20
|
_Target = function () {
|
|
26
21
|
return data;
|
|
27
22
|
};
|
|
28
|
-
|
|
29
23
|
return data;
|
|
30
24
|
}
|
|
31
|
-
|
|
32
25
|
function _Xcodeproj() {
|
|
33
26
|
const data = require("./utils/Xcodeproj");
|
|
34
|
-
|
|
35
27
|
_Xcodeproj = function () {
|
|
36
28
|
return data;
|
|
37
29
|
};
|
|
38
|
-
|
|
39
30
|
return data;
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
const withDisplayName = (0, _iosPlugins().createInfoPlistPluginWithPropertyGuard)(setDisplayName, {
|
|
43
33
|
infoPlistProperty: 'CFBundleDisplayName',
|
|
44
34
|
expoConfigProperty: 'name'
|
|
@@ -48,78 +38,66 @@ const withName = (0, _iosPlugins().createInfoPlistPluginWithPropertyGuard)(setNa
|
|
|
48
38
|
infoPlistProperty: 'CFBundleName',
|
|
49
39
|
expoConfigProperty: 'name'
|
|
50
40
|
}, 'withName');
|
|
51
|
-
/** Set the PRODUCT_NAME variable in the xcproj file based on the app.json name property. */
|
|
52
41
|
|
|
42
|
+
/** Set the PRODUCT_NAME variable in the xcproj file based on the app.json name property. */
|
|
53
43
|
exports.withName = withName;
|
|
54
|
-
|
|
55
44
|
const withProductName = config => {
|
|
56
45
|
return (0, _iosPlugins().withXcodeProject)(config, config => {
|
|
57
46
|
config.modResults = setProductName(config, config.modResults);
|
|
58
47
|
return config;
|
|
59
48
|
});
|
|
60
49
|
};
|
|
61
|
-
|
|
62
50
|
exports.withProductName = withProductName;
|
|
63
|
-
|
|
64
51
|
function getName(config) {
|
|
65
52
|
return typeof config.name === 'string' ? config.name : null;
|
|
66
53
|
}
|
|
54
|
+
|
|
67
55
|
/**
|
|
68
56
|
* CFBundleDisplayName is used for most things: the name on the home screen, in
|
|
69
57
|
* notifications, and others.
|
|
70
58
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
59
|
function setDisplayName(configOrName, {
|
|
74
60
|
CFBundleDisplayName,
|
|
75
61
|
...infoPlist
|
|
76
62
|
}) {
|
|
77
63
|
let name = null;
|
|
78
|
-
|
|
79
64
|
if (typeof configOrName === 'string') {
|
|
80
65
|
name = configOrName;
|
|
81
66
|
} else {
|
|
82
67
|
name = getName(configOrName);
|
|
83
68
|
}
|
|
84
|
-
|
|
85
69
|
if (!name) {
|
|
86
70
|
return infoPlist;
|
|
87
71
|
}
|
|
88
|
-
|
|
89
|
-
|
|
72
|
+
return {
|
|
73
|
+
...infoPlist,
|
|
90
74
|
CFBundleDisplayName: name
|
|
91
75
|
};
|
|
92
76
|
}
|
|
77
|
+
|
|
93
78
|
/**
|
|
94
79
|
* CFBundleName is recommended to be 16 chars or less and is used in lists, eg:
|
|
95
80
|
* sometimes on the App Store
|
|
96
81
|
*/
|
|
97
|
-
|
|
98
|
-
|
|
99
82
|
function setName(config, {
|
|
100
83
|
CFBundleName,
|
|
101
84
|
...infoPlist
|
|
102
85
|
}) {
|
|
103
86
|
const name = getName(config);
|
|
104
|
-
|
|
105
87
|
if (!name) {
|
|
106
88
|
return infoPlist;
|
|
107
89
|
}
|
|
108
|
-
|
|
109
|
-
|
|
90
|
+
return {
|
|
91
|
+
...infoPlist,
|
|
110
92
|
CFBundleName: name
|
|
111
93
|
};
|
|
112
94
|
}
|
|
113
|
-
|
|
114
95
|
function setProductName(config, project) {
|
|
115
96
|
var _getName;
|
|
116
|
-
|
|
117
97
|
const name = (0, _Xcodeproj().sanitizedName)((_getName = getName(config)) !== null && _getName !== void 0 ? _getName : '');
|
|
118
|
-
|
|
119
98
|
if (!name) {
|
|
120
99
|
return project;
|
|
121
100
|
}
|
|
122
|
-
|
|
123
101
|
const quotedName = ensureQuotes(name);
|
|
124
102
|
const [, nativeTarget] = (0, _Target().findFirstNativeTarget)(project);
|
|
125
103
|
(0, _Xcodeproj().getBuildConfigurationsForListId)(project, nativeTarget.buildConfigurationList).forEach(([, item]) => {
|
|
@@ -127,12 +105,10 @@ function setProductName(config, project) {
|
|
|
127
105
|
});
|
|
128
106
|
return project;
|
|
129
107
|
}
|
|
130
|
-
|
|
131
108
|
const ensureQuotes = value => {
|
|
132
109
|
if (!value.match(/^['"]/)) {
|
|
133
110
|
return `"${value}"`;
|
|
134
111
|
}
|
|
135
|
-
|
|
136
112
|
return value;
|
|
137
113
|
};
|
|
138
114
|
//# sourceMappingURL=Name.js.map
|