(config, {apiKey})
| 146 | const 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 | }; |
no test coverage detected
searching dependent graphs…