Skip to content

Commit c3a0641

Browse files
authored
expo-config-plugin created
1 parent c931691 commit c3a0641

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

plugin/index.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const { withDangerousMod } = require('@expo/config-plugins');
2+
const fs = require('fs');
3+
const path = require('path');
4+
5+
function modifyPodfile(podfilePath) {
6+
let podfile = fs.readFileSync(podfilePath, 'utf8');
7+
8+
const preinstallScript = `
9+
pre_install do |installer|
10+
installer.pod_targets.each do |pod|
11+
if pod.name.eql?('react-native-quick-sqlite')
12+
def pod.build_type
13+
Pod::BuildType.static_library
14+
end
15+
end
16+
end
17+
end
18+
`;
19+
20+
// Ensure we don't add duplicate scripts
21+
if (!podfile.includes('react-native-quick-sqlite')) {
22+
podfile = podfile.replace(/target\s+'[^']+'\s+do/, `$&\n${preinstallScript}`);
23+
fs.writeFileSync(podfilePath, podfile, 'utf8');
24+
}
25+
}
26+
27+
const withPowerSyncQuickSQLite = (config) => {
28+
return withDangerousMod(config, [
29+
'ios',
30+
(config) => {
31+
const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
32+
modifyPodfile(podfilePath);
33+
return config;
34+
},
35+
]);
36+
};
37+
38+
module.exports = withPowerSyncQuickSQLite;

0 commit comments

Comments
 (0)