1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const path_1 = __importDefault(require("path"));
|
7 | const fs_extra_1 = __importDefault(require("fs-extra"));
|
8 | const Scheme_1 = require("./Scheme");
|
9 | const Xcodeproj_1 = require("./utils/Xcodeproj");
|
10 | function getGoogleMapsApiKey(config) {
|
11 | var _a, _b, _c;
|
12 | return _c = (_b = (_a = config.ios) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.googleMapsApiKey, (_c !== null && _c !== void 0 ? _c : null);
|
13 | }
|
14 | exports.getGoogleMapsApiKey = getGoogleMapsApiKey;
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function getGoogleMobileAdsAppId(config) {
|
23 | var _a, _b, _c;
|
24 | return _c = (_b = (_a = config.ios) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.googleMobileAdsAppId, (_c !== null && _c !== void 0 ? _c : null);
|
25 | }
|
26 | exports.getGoogleMobileAdsAppId = getGoogleMobileAdsAppId;
|
27 | function getGoogleSignInReservedClientId(config) {
|
28 | var _a, _b, _c, _d;
|
29 | return _d = (_c = (_b = (_a = config.ios) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.googleSignIn) === null || _c === void 0 ? void 0 : _c.reservedClientId, (_d !== null && _d !== void 0 ? _d : null);
|
30 | }
|
31 | exports.getGoogleSignInReservedClientId = getGoogleSignInReservedClientId;
|
32 | function getGoogleServicesFile(config) {
|
33 | var _a, _b;
|
34 | return _b = (_a = config.ios) === null || _a === void 0 ? void 0 : _a.googleServicesFile, (_b !== null && _b !== void 0 ? _b : null);
|
35 | }
|
36 | exports.getGoogleServicesFile = getGoogleServicesFile;
|
37 | function setGoogleMapsApiKey(config, infoPlist) {
|
38 | let apiKey = getGoogleMapsApiKey(config);
|
39 | if (apiKey === null) {
|
40 | return infoPlist;
|
41 | }
|
42 | return Object.assign(Object.assign({}, infoPlist), { GMSApiKey: apiKey });
|
43 | }
|
44 | exports.setGoogleMapsApiKey = setGoogleMapsApiKey;
|
45 | function setGoogleMobileAdsAppId(config, infoPlist) {
|
46 | let appId = getGoogleMobileAdsAppId(config);
|
47 | if (appId === null) {
|
48 | return infoPlist;
|
49 | }
|
50 | return Object.assign(Object.assign({}, infoPlist), { GADApplicationIdentifier: appId });
|
51 | }
|
52 | exports.setGoogleMobileAdsAppId = setGoogleMobileAdsAppId;
|
53 | function setGoogleSignInReservedClientId(config, infoPlist) {
|
54 | let reservedClientId = getGoogleSignInReservedClientId(config);
|
55 | if (reservedClientId === null) {
|
56 | return infoPlist;
|
57 | }
|
58 | return Scheme_1.appendScheme(reservedClientId, infoPlist);
|
59 | }
|
60 | exports.setGoogleSignInReservedClientId = setGoogleSignInReservedClientId;
|
61 | function setGoogleConfig(config, infoPlist) {
|
62 | infoPlist = setGoogleMapsApiKey(config, infoPlist);
|
63 | infoPlist = setGoogleMobileAdsAppId(config, infoPlist);
|
64 | infoPlist = setGoogleSignInReservedClientId(config, infoPlist);
|
65 | return infoPlist;
|
66 | }
|
67 | exports.setGoogleConfig = setGoogleConfig;
|
68 | function setGoogleServicesFile(config, projectRoot) {
|
69 | let googleServicesFileRelativePath = getGoogleServicesFile(config);
|
70 | if (googleServicesFileRelativePath === null) {
|
71 | return;
|
72 | }
|
73 | let googleServiceFilePath = path_1.default.resolve(projectRoot, googleServicesFileRelativePath);
|
74 | fs_extra_1.default.copyFileSync(googleServiceFilePath, path_1.default.join(Xcodeproj_1.getSourceRoot(projectRoot), 'GoogleService-Info.plist'));
|
75 | let project = Xcodeproj_1.getPbxproj(projectRoot);
|
76 | let projectName = Xcodeproj_1.getProjectName(projectRoot);
|
77 | project = Xcodeproj_1.addFileToGroup(`${projectName}/GoogleService-Info.plist`, projectName, project);
|
78 | fs_extra_1.default.writeFileSync(project.filepath, project.writeSync());
|
79 | }
|
80 | exports.setGoogleServicesFile = setGoogleServicesFile;
|
81 |
|
\ | No newline at end of file |