-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathmacos.js
86 lines (79 loc) · 2.61 KB
/
macos.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// @ts-check
const { withMod } = require("@expo/config-plugins");
/**
* @import {
* ExportedConfig,
* ExportedConfigWithProps,
* Mod,
* ModConfig,
* } from "@expo/config-plugins";
* @typedef {ExportedConfigWithProps & { macos?: { infoPlist?: Record<string, unknown> }}} ExportedConfigWithPropsMac
*/
const macosPlatform = /** @type {keyof ModConfig} */ ("macos");
/**
* Provides the `ReactNativeHost` file for modification.
* @param {ExportedConfig} config Exported config
* @param {Mod} action Method to run on the mod when the config is compiled
* @returns {ExportedConfig} Modified config
*/
function withReactNativeHost(config, action) {
return withMod(config, {
platform: macosPlatform,
mod: "reactNativeHost",
action,
});
}
/**
* Provides the `AppDelegate` file for modification.
* @see {@link https://github.com/expo/expo/blob/sdk-51/packages/%40expo/config-plugins/src/plugins/ios-plugins.ts#L101}
* @param {ExportedConfig} config Exported config
* @param {Mod} action Method to run on the mod when the config is compiled
* @returns {ExportedConfig} Modified config
*/
function withAppDelegate(config, action) {
return withMod(config, {
platform: macosPlatform,
mod: "appDelegate",
action,
});
}
/**
* Provides the `Info.plist` file for modification.
* @see {@link https://github.com/expo/expo/blob/sdk-51/packages/%40expo/config-plugins/src/plugins/ios-plugins.ts#L116}
* @param {ExportedConfig} config Exported config
* @param {Mod} action Method to run on the mod when the config is compiled
* @returns {ExportedConfig} Modified config
*/
function withInfoPlist(config, action) {
return withMod(config, {
platform: macosPlatform,
mod: "infoPlist",
async action(cfg) {
/** @type {ExportedConfigWithPropsMac} */
const config = await action(cfg);
if (!config.macos) {
config.macos = {};
}
config.macos.infoPlist = config.modResults;
return config;
},
});
}
/**
* Provides the main `.xcodeproj` for modification.
* @see {@link https://github.com/expo/expo/blob/sdk-51/packages/%40expo/config-plugins/src/plugins/ios-plugins.ts#L173}
* @param {ExportedConfig} config Exported config
* @param {Mod} action Method to run on the mod when the config is compiled
* @returns {ExportedConfig} Modified config
*/
function withXcodeProject(config, action) {
return withMod(config, {
platform: macosPlatform,
mod: "xcodeproj",
action,
});
}
exports.withAppDelegate = withAppDelegate;
exports.withInfoPlist = withInfoPlist;
exports.withXcodeProject = withXcodeProject;
exports.withReactNativeHost = withReactNativeHost;