@@ -6,7 +6,7 @@ const path = require('path');
66const 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 = `
1212pre_install do |installer|
@@ -20,21 +20,23 @@ pre_install do |installer|
2020end
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 ( / t a r g e t \s + ' [ ^ ' ] + ' \s + d o / , `$&\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