Skip to content

Commit d486af7

Browse files
committed
Merge remote-tracking branch 'raiden-fork/main' into raiden-fork
2 parents 0d40b3a + 88e8fa2 commit d486af7

File tree

6 files changed

+370
-13
lines changed

6 files changed

+370
-13
lines changed

.changeset/funny-crabs-smoke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@journeyapps/react-native-quick-sqlite": patch
3+
---
4+
5+
Added expo config plugin, that automatically applies podfile changes needed for use_frameworks.

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,19 @@
55
This repository is a fork of [react-native-quick-sqlite](https://github.com/ospfranco/react-native-quick-sqlite?tab=readme-ov-file) that includes custom SQLite extensions built specifically for **PowerSync**. It has been modified to meet the needs of **PowerSync**, adding features or behaviors that are different from the original repository.
66

77
It is **not** intended to be used independently, use [PowerSync React Native SDK](https://github.com/powersync-ja/powersync-js/tree/main/packages/react-native) and install this alongside it as a peer dependency.
8+
9+
### For Expo
10+
11+
#### iOS with `use_frameworks!`
12+
13+
If your iOS project uses `use_frameworks!`, add the config plugin to your **app.json** or **app.config.js**:
14+
15+
```json
16+
{
17+
"expo": {
18+
"plugins": [["@journeyapps/react-native-quick-sqlite"]]
19+
}
20+
}
21+
```
22+
23+
This plugin automatically configures the necessary build settings for `react-native-quick-sqlite` to work with `use_frameworks!`.

app.plugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./src/withUseFrameworks').default;

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"ios",
1919
"cpp",
2020
"meta.json",
21+
"app.plugin.js",
2122
"react-native-quick-sqlite.podspec",
2223
"!android/build",
2324
"!android/.cxx",
@@ -49,6 +50,7 @@
4950
"homepage": "https://github.com/powersync-ja/react-native-quick-sqlite#readme",
5051
"devDependencies": {
5152
"@changesets/cli": "^2.26.2",
53+
"@expo/config-plugins": "^9.0.17",
5254
"prettier": "^3.3.3",
5355
"react": "18.3.1",
5456
"react-native": "0.76.2",

src/withUseFrameworks.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const { ConfigPlugin, withDangerousMod, createRunOncePlugin } = require('@expo/config-plugins');
2+
const fs = require('fs');
3+
const path = require('path');
4+
5+
// Define package metadata
6+
const pkg = { name: '@journeyapps/react-native-quick-sqlite', version: 'UNVERSIONED' };
7+
8+
// Function to modify the Podfile
9+
function modifyPodfile(podfilePath) {
10+
let podfile = fs.readFileSync(podfilePath, 'utf8');
11+
const preinstallScript = `
12+
pre_install do |installer|
13+
installer.pod_targets.each do |pod|
14+
if pod.name.eql?('react-native-quick-sqlite')
15+
def pod.build_type
16+
Pod::BuildType.static_library
17+
end
18+
end
19+
end
20+
end
21+
`;
22+
// Ensure script is added only once
23+
if (!podfile.includes('react-native-quick-sqlite')) {
24+
podfile = podfile.replace(/target\s+'[^']+'\s+do/, `$&\n${preinstallScript}`);
25+
fs.writeFileSync(podfilePath, podfile, 'utf8');
26+
console.log(`Added pre_install script for react-native-quick-sqlite to Podfile`);
27+
}
28+
}
29+
30+
// Config Plugin
31+
const withUseFrameworks = (config) => {
32+
return withDangerousMod(config, [
33+
'ios',
34+
(config) => {
35+
const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
36+
if (fs.existsSync(podfilePath)) {
37+
modifyPodfile(podfilePath);
38+
} else {
39+
console.warn(`Podfile not found at ${podfilePath}`);
40+
}
41+
return config;
42+
}
43+
]);
44+
};
45+
46+
// Export the plugin with Expo's createRunOncePlugin
47+
module.exports = createRunOncePlugin(withUseFrameworks, pkg.name, pkg.version);

0 commit comments

Comments
 (0)