-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.config.js
47 lines (43 loc) · 1.59 KB
/
plugin.config.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
const {
withProjectBuildGradle,
withXcodeProject,
withPodfileProperties,
} = require('@expo/config-plugins');
// Function to modify Android build.gradle
function modifyAndroidBuildGradle(config) {
const lineToAdd = ` apply from: "../node_modules/cbl-reactnative/android/build.gradle"`;
if (!config.modResults.contents.includes(lineToAdd)) {
config.modResults.contents += `\n${lineToAdd}`;
console.debug(config.modResults.contents);
}
return config;
}
// Function to modify iOS Xcode project
function modifyXcodeProject(config) {
const xcodeProject = config.modResults;
// Example modification: adding a build phase for a script
// xcodeProject.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Run Script', null, script);
return config;
}
// Function to modify Podfile properties to include the native module podspec
function includeNativeModulePod(config) {
return withPodfileProperties(config, async (podConfig) => {
const podspecPath = `../node_modules/cbl-reactnative/cbl-reactnative.podspec`;
if (podConfig.modResults.podfileProperties !== undefined && podConfig.modResults.podfileProperties.pod !== undefined) {
podConfig.modResults.podfileProperties.pod(
`'cbl-reactnative', :path => '${podspecPath}'`
);
}
return podConfig;
});
}
module.exports = (config) => {
config = withProjectBuildGradle(config, (gradleConfig) => {
return modifyAndroidBuildGradle(gradleConfig);
});
config = withXcodeProject(config, (xcodeConfig) => {
return modifyXcodeProject(xcodeConfig);
});
config = includeNativeModulePod(config);
return config;
};