Skip to content

Commit fd97b6c

Browse files
committed
Added staticLibrary config for plugin.
1 parent 59b1920 commit fd97b6c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/withUseFrameworks.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const path = require('path');
66
const pkg = { name: '@journeyapps/react-native-quick-sqlite', version: 'UNVERSIONED' };
77

88
// Function to modify the Podfile
9-
function modifyPodfile(podfilePath) {
9+
function modifyPodfile(podfilePath: string, staticLibrary: boolean) {
1010
let podfile = fs.readFileSync(podfilePath, 'utf8');
1111
const preinstallScript = `
1212
pre_install do |installer|
@@ -20,21 +20,23 @@ pre_install do |installer|
2020
end
2121
`;
2222
// Ensure script is added only once
23-
if (!podfile.includes('react-native-quick-sqlite')) {
23+
if (staticLibrary && !podfile.includes('react-native-quick-sqlite')) {
2424
podfile = podfile.replace(/target\s+'[^']+'\s+do/, `$&\n${preinstallScript}`);
2525
fs.writeFileSync(podfilePath, podfile, 'utf8');
2626
console.log(`Added pre_install script for react-native-quick-sqlite to Podfile`);
2727
}
2828
}
2929

3030
// Config Plugin
31-
const withUseFrameworks = (config) => {
31+
const withUseFrameworks = (config, options = { staticLibrary: false }) => {
32+
const { staticLibrary } = options;
33+
3234
return withDangerousMod(config, [
3335
'ios',
3436
(config) => {
3537
const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
3638
if (fs.existsSync(podfilePath)) {
37-
modifyPodfile(podfilePath);
39+
modifyPodfile(podfilePath, staticLibrary);
3840
} else {
3941
console.warn(`Podfile not found at ${podfilePath}`);
4042
}
@@ -43,5 +45,9 @@ const withUseFrameworks = (config) => {
4345
]);
4446
};
4547

48+
const pluginWithOptions = (config, options) => {
49+
return withUseFrameworks(config, options);
50+
};
51+
4652
// Export the plugin with Expo's createRunOncePlugin
47-
module.exports = createRunOncePlugin(withUseFrameworks, pkg.name, pkg.version);
53+
module.exports = createRunOncePlugin(pluginWithOptions, pkg.name, pkg.version);

0 commit comments

Comments
 (0)