MCPcopy Create free account
hub / github.com/react-native-maps/react-native-maps / withGoogleMapsAppDelegate

Function withGoogleMapsAppDelegate

plugin/src/ios.ts:148–184  ·  view source on GitHub ↗
(config, {apiKey})

Source from the content-addressed store, hash-verified

146const withGoogleMapsAppDelegate: ConfigPlugin<{
147 apiKey: string | null | undefined;
148}> = (config, {apiKey}) => {
149 return withAppDelegate(config, conf => {
150 if (!apiKey) {
151 conf.modResults.contents = removeGoogleMapsAppDelegateImport(
152 conf.modResults.contents,
153 ).contents;
154 conf.modResults.contents = removeGoogleMapsAppDelegateInit(
155 conf.modResults.contents,
156 ).contents;
157 return conf;
158 }
159
160 if (conf.modResults.language !== 'swift') {
161 throw new Error(
162 `Cannot setup Google Maps because the project AppDelegate is not a supported language: ${conf.modResults.language}`,
163 );
164 }
165
166 try {
167 conf.modResults.contents = addGoogleMapsAppDelegateImport(
168 conf.modResults.contents,
169 ).contents;
170 conf.modResults.contents = addGoogleMapsAppDelegateInit(
171 conf.modResults.contents,
172 apiKey,
173 ).contents;
174 } catch (error: any) {
175 if (error.code === 'ERR_NO_MATCH') {
176 throw new Error(
177 "Cannot add Google Maps to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.",
178 );
179 }
180 throw error;
181 }
182 return conf;
183 });
184};

Callers 1

withMapsIOSFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…