@@ -6,7 +6,7 @@ const path = require('path');
6
6
const pkg = { name : '@journeyapps/react-native-quick-sqlite' , version : 'UNVERSIONED' } ;
7
7
8
8
// Function to modify the Podfile
9
- function modifyPodfile ( podfilePath ) {
9
+ function modifyPodfile ( podfilePath : string , staticLibrary : boolean ) {
10
10
let podfile = fs . readFileSync ( podfilePath , 'utf8' ) ;
11
11
const preinstallScript = `
12
12
pre_install do |installer|
@@ -20,21 +20,23 @@ pre_install do |installer|
20
20
end
21
21
` ;
22
22
// Ensure script is added only once
23
- if ( ! podfile . includes ( 'react-native-quick-sqlite' ) ) {
23
+ if ( staticLibrary && ! podfile . includes ( 'react-native-quick-sqlite' ) ) {
24
24
podfile = podfile . replace ( / t a r g e t \s + ' [ ^ ' ] + ' \s + d o / , `$&\n${ preinstallScript } ` ) ;
25
25
fs . writeFileSync ( podfilePath , podfile , 'utf8' ) ;
26
26
console . log ( `Added pre_install script for react-native-quick-sqlite to Podfile` ) ;
27
27
}
28
28
}
29
29
30
30
// Config Plugin
31
- const withUseFrameworks = ( config ) => {
31
+ const withUseFrameworks = ( config , options = { staticLibrary : false } ) => {
32
+ const { staticLibrary } = options ;
33
+
32
34
return withDangerousMod ( config , [
33
35
'ios' ,
34
36
( config ) => {
35
37
const podfilePath = path . join ( config . modRequest . platformProjectRoot , 'Podfile' ) ;
36
38
if ( fs . existsSync ( podfilePath ) ) {
37
- modifyPodfile ( podfilePath ) ;
39
+ modifyPodfile ( podfilePath , staticLibrary ) ;
38
40
} else {
39
41
console . warn ( `Podfile not found at ${ podfilePath } ` ) ;
40
42
}
@@ -43,5 +45,9 @@ const withUseFrameworks = (config) => {
43
45
] ) ;
44
46
} ;
45
47
48
+ const pluginWithOptions = ( config , options ) => {
49
+ return withUseFrameworks ( config , options ) ;
50
+ } ;
51
+
46
52
// 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