UNPKG

@woosmap/expo-plugin-geofencing-batch

Version:
77 lines (76 loc) 3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withIOSSdk = void 0; const config_plugins_1 = require("@expo/config-plugins"); const withSDKInfoPlist = (config, props) => { return (0, config_plugins_1.withInfoPlist)(config, (config) => { delete config.modResults.woosmap; const { locationAlwaysAndWhenInUsePermission, locationAlwaysPermission, locationWhenInUsePermission, } = props; //Permission if (!Array.isArray(config.modResults.UIBackgroundModes)) { config.modResults.UIBackgroundModes = []; } if (!config.modResults.UIBackgroundModes.includes("location")) { config.modResults.UIBackgroundModes.push("location"); } if (!config.modResults.NSLocationAlwaysAndWhenInUseUsageDescription && locationAlwaysAndWhenInUsePermission) { config.modResults.NSLocationAlwaysAndWhenInUseUsageDescription = locationAlwaysAndWhenInUsePermission; } if (!config.modResults.NSLocationAlwaysUsageDescription && locationAlwaysPermission) { config.modResults.NSLocationAlwaysUsageDescription = locationAlwaysPermission; } if (!config.modResults.NSLocationWhenInUseUsageDescription && locationWhenInUsePermission) { config.modResults.NSLocationWhenInUseUsageDescription = locationWhenInUsePermission; } return config; }); }; const { mergeContents, } = require("@expo/config-plugins/build/utils/generateCode"); const fs = require("fs"); const path = require("path"); async function readFileAsync(path) { return fs.promises.readFile(path, "utf8"); } async function saveFileAsync(path, content) { return fs.promises.writeFile(path, content, "utf8"); } function disableAdIDSupport(src) { return mergeContents({ tag: `M1 Mac patch`, src, newSrc: ` installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings["ONLY_ACTIVE_ARCH"] = "NO" end end`, anchor: /post_install/, offset: 1, comment: "# run application on ARM-based system-on-a-chip simulator", }).contents; } const withSDKDangerousMod = (config, props) => { return (0, config_plugins_1.withDangerousMod)(config, [ "ios", async (config) => { const file = path.join(config.modRequest.platformProjectRoot, "Podfile"); const contents = await readFileAsync(file); await saveFileAsync(file, disableAdIDSupport(contents)); return config; }, ]); }; const withIOSSdk = (config, props) => { config = withSDKInfoPlist(config, props); // config = withSDKEntitlements(config, props); // config = withSDKXcodeProject(config, props); config = withSDKDangerousMod(config, props); return config; }; exports.withIOSSdk = withIOSSdk;