UNPKG

4.3 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6const path_1 = __importDefault(require("path"));
7const fs_extra_1 = __importDefault(require("fs-extra"));
8const Scheme_1 = require("./Scheme");
9const Xcodeproj_1 = require("./utils/Xcodeproj");
10function 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}
14exports.getGoogleMapsApiKey = getGoogleMapsApiKey;
15// NOTE(brentvatne): if the developer has installed the google ads sdk and does
16// not provide an app id their app will crash. Standalone apps get around this by
17// providing some default value, we will instead here assume that the user can
18// do the right thing if they have installed the package. This is a slight discrepancy
19// that arises in ejecting because it's possible for the package to be installed and
20// not crashing in the managed workflow, then you eject and the app crashes because
21// you don't have an id to fall back to.
22function 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}
26exports.getGoogleMobileAdsAppId = getGoogleMobileAdsAppId;
27function 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}
31exports.getGoogleSignInReservedClientId = getGoogleSignInReservedClientId;
32function 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}
36exports.getGoogleServicesFile = getGoogleServicesFile;
37function 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}
44exports.setGoogleMapsApiKey = setGoogleMapsApiKey;
45function 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}
52exports.setGoogleMobileAdsAppId = setGoogleMobileAdsAppId;
53function setGoogleSignInReservedClientId(config, infoPlist) {
54 let reservedClientId = getGoogleSignInReservedClientId(config);
55 if (reservedClientId === null) {
56 return infoPlist;
57 }
58 return Scheme_1.appendScheme(reservedClientId, infoPlist);
59}
60exports.setGoogleSignInReservedClientId = setGoogleSignInReservedClientId;
61function setGoogleConfig(config, infoPlist) {
62 infoPlist = setGoogleMapsApiKey(config, infoPlist);
63 infoPlist = setGoogleMobileAdsAppId(config, infoPlist);
64 infoPlist = setGoogleSignInReservedClientId(config, infoPlist);
65 return infoPlist;
66}
67exports.setGoogleConfig = setGoogleConfig;
68function 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}
80exports.setGoogleServicesFile = setGoogleServicesFile;
81//# sourceMappingURL=Google.js.map
\No newline at end of file