Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-crabs-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@journeyapps/react-native-quick-sqlite": patch
---

Added expo config plugin, that automatically applies podfile changes needed for use_frameworks.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,19 @@
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.

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.

### For Expo

#### iOS with `use_frameworks!`

If your iOS project uses `use_frameworks!`, add the config plugin to your **app.json** or **app.config.js**:

```json
{
"expo": {
"plugins": [["@journeyapps/react-native-quick-sqlite"]]
}
}
```

This plugin automatically configures the necessary build settings for `react-native-quick-sqlite` to work with `use_frameworks!`.
1 change: 1 addition & 0 deletions app.plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/commonjs/withUseFrameworks');
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"ios",
"cpp",
"meta.json",
"app.plugin.js",
"react-native-quick-sqlite.podspec",
"!android/build",
"!android/.cxx",
Expand Down Expand Up @@ -49,6 +50,7 @@
"homepage": "https://github.com/powersync-ja/react-native-quick-sqlite#readme",
"devDependencies": {
"@changesets/cli": "^2.26.2",
"@expo/config-plugins": "^9.0.17",
"prettier": "^3.3.3",
"react": "18.3.1",
"react-native": "0.76.2",
Expand Down
47 changes: 47 additions & 0 deletions src/withUseFrameworks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const { ConfigPlugin, withDangerousMod, createRunOncePlugin } = require('@expo/config-plugins');
const fs = require('fs');
const path = require('path');

// Define package metadata
const pkg = { name: '@journeyapps/react-native-quick-sqlite', version: 'UNVERSIONED' };

// Function to modify the Podfile
function modifyPodfile(podfilePath) {
let podfile = fs.readFileSync(podfilePath, 'utf8');
const preinstallScript = `
pre_install do |installer|
installer.pod_targets.each do |pod|
if pod.name.eql?('react-native-quick-sqlite')
def pod.build_type
Pod::BuildType.static_library
end
end
end
end
`;
// Ensure script is added only once
if (!podfile.includes('react-native-quick-sqlite')) {
podfile = podfile.replace(/target\s+'[^']+'\s+do/, `$&\n${preinstallScript}`);
fs.writeFileSync(podfilePath, podfile, 'utf8');
console.log(`Added pre_install script for react-native-quick-sqlite to Podfile`);
}
}

// Config Plugin
const withUseFrameworks = (config) => {
return withDangerousMod(config, [
'ios',
(config) => {
const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');
if (fs.existsSync(podfilePath)) {
modifyPodfile(podfilePath);
} else {
console.warn(`Podfile not found at ${podfilePath}`);
}
return config;
}
]);
};

// Export the plugin with Expo's createRunOncePlugin
module.exports = createRunOncePlugin(withUseFrameworks, pkg.name, pkg.version);
Loading