-
Notifications
You must be signed in to change notification settings - Fork 3
Expo Config Plugin #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c3a0641
expo-config-plugin created
Raiden-16F7 f5b8578
Expo Config Plugin Created
88e8fa2
Cleanup.
Chriztiaan f7099d8
Updated app.plugin.js export.
Chriztiaan e43564e
Only add pre_install entry when staticLibrary option is specified for…
Chriztiaan 4508140
Update funny-crabs-smoke.md
Chriztiaan c818b94
Early guard.
Chriztiaan dcfe9fc
Merge branch 'main' of https://github.com/Raiden-16F7/react-native-qu…
Chriztiaan de1500c
Merge branch 'main' into main
Chriztiaan f1111c6
Moved guard up in call stack.
Chriztiaan c9e04e6
Merge branch 'main' of https://github.com/Raiden-16F7/react-native-qu…
Chriztiaan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 when `staticLibrary` option is specified for the plugin. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./lib/commonjs/withUseFrameworks'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
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: string, staticLibrary: boolean) { | ||
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 (staticLibrary && !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, options = { staticLibrary: false }) => { | ||
const { staticLibrary } = options; | ||
|
||
return withDangerousMod(config, [ | ||
'ios', | ||
(config) => { | ||
const podfilePath = path.join(config.modRequest.platformProjectRoot, 'Podfile'); | ||
if (fs.existsSync(podfilePath)) { | ||
modifyPodfile(podfilePath, staticLibrary); | ||
} else { | ||
console.warn(`Podfile not found at ${podfilePath}`); | ||
} | ||
return config; | ||
} | ||
]); | ||
}; | ||
|
||
const pluginWithOptions = (config, options) => { | ||
return withUseFrameworks(config, options); | ||
}; | ||
|
||
// Export the plugin with Expo's createRunOncePlugin | ||
module.exports = createRunOncePlugin(pluginWithOptions, pkg.name, pkg.version); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.