Skip to content

Commit f227074

Browse files
committed
feat: add native SDK version customization
1 parent 5e36284 commit f227074

File tree

4 files changed

+128
-2
lines changed

4 files changed

+128
-2
lines changed

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This library is a wrapper around the iOS/Android runtime, providing a component
1919
- 🏃 [Migration Guides](#migration-guides)
2020
- 👨‍💻 [Contributing](#contributing)
2121
- :question: [Issues](#issues)
22+
- :wrench: [Native SDK Version Customization](#native-sdk-version-customization)
2223

2324
## Rive Overview
2425

@@ -77,3 +78,90 @@ We love contributions! Check out our [contributing docs](./CONTRIBUTING.md) to g
7778
## Issues
7879

7980
Have an issue with using the runtime, or want to suggest a feature/API to help make your development life better? Log an issue in our [issues](https://github.com/rive-app/rive-react-native/issues) tab! You can also browse older issues and discussion threads there to see solutions that may have worked for common problems.
81+
82+
## Native SDK Version Customization
83+
84+
> **⚠️ Advanced Configuration**
85+
> This section is for advanced users who need to use specific versions of the Rive native SDKs. In most cases, you should use the default versions that come with the library. Only customize these versions if you have a specific requirement and understand the potential compatibility implications.
86+
>
87+
> **Important:** If you customize the native SDK versions and later update `rive-react-native` to a newer version, you should revisit your custom version settings. The custom versions you specified may not be compatible with the updated `rive-react-native` version. Always check the default versions in the new release and test thoroughly.
88+
89+
### Default Behavior
90+
91+
By default, `rive-react-native` uses the native SDK versions specified in `package.json`:
92+
93+
```json
94+
"runtimeVersions": {
95+
"ios": "6.12.0",
96+
"android": "10.4.5"
97+
}
98+
```
99+
100+
These versions are tested and known to work well with this version of `rive-react-native`.
101+
102+
### Customizing Versions
103+
104+
You can override these default versions using platform-specific configuration files:
105+
106+
#### iOS (Vanilla React Native)
107+
108+
Create or edit `ios/Podfile.properties.json`:
109+
110+
```json
111+
{
112+
"RiveRuntimeIOSVersion": "6.13.0"
113+
}
114+
```
115+
116+
Then run:
117+
```bash
118+
cd ios && pod install
119+
```
120+
121+
#### Android (Vanilla React Native)
122+
123+
Add to `android/gradle.properties`:
124+
125+
```properties
126+
Rive_RiveRuntimeAndroidVersion=10.5.0
127+
```
128+
129+
#### Expo Projects
130+
131+
For Expo projects, use config plugins in your `app.config.ts`:
132+
133+
```typescript
134+
import { ExpoConfig, ConfigContext } from 'expo/config';
135+
import { withPodfileProperties } from '@expo/config-plugins';
136+
import { withGradleProperties } from '@expo/config-plugins';
137+
138+
export default ({ config }: ConfigContext): ExpoConfig => ({
139+
...config,
140+
plugins: [
141+
[
142+
withPodfileProperties,
143+
{
144+
RiveRuntimeIOSVersion: '6.13.0',
145+
},
146+
],
147+
[
148+
withGradleProperties,
149+
{
150+
Rive_RiveRuntimeAndroidVersion: '10.5.0',
151+
},
152+
],
153+
],
154+
});
155+
```
156+
157+
### Version Resolution Priority
158+
159+
The library resolves versions in the following order:
160+
161+
**iOS:**
162+
1. `ios/Podfile.properties.json``RiveRuntimeIOSVersion`
163+
2. `package.json``runtimeVersions.ios` (default)
164+
165+
**Android:**
166+
1. `android/gradle.properties``Rive_RiveRuntimeAndroidVersion`
167+
2. `package.json``runtimeVersions.android` (default)

android/build.gradle

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,25 @@ repositories {
128128

129129
def kotlin_version = getExtOrDefault('kotlinVersion')
130130

131+
def getRiveAndroidVersion() {
132+
if (project.hasProperty("Rive_RiveRuntimeAndroidVersion")) {
133+
return project.property("Rive_RiveRuntimeAndroidVersion")
134+
}
135+
136+
def packageJsonFile = new File(projectDir, '../package.json')
137+
if (packageJsonFile.exists()) {
138+
def packageJson = new groovy.json.JsonSlurper().parseText(packageJsonFile.text)
139+
if (packageJson.runtimeVersions?.android) {
140+
return packageJson.runtimeVersions.android
141+
}
142+
}
143+
144+
throw new GradleException("Could not determine Rive Android SDK version. Please add 'runtimeVersions.android' to package.json")
145+
}
146+
147+
def riveAndroidVersion = getRiveAndroidVersion()
148+
println "rive-react-native: Using Rive Android SDK ${riveAndroidVersion}"
149+
131150
dependencies {
132151
// noinspection GradleDynamicVersion
133152
def lifecycle_version = "2.6.1"
@@ -138,7 +157,7 @@ dependencies {
138157
implementation 'androidx.core:core-ktx:1.12.0'
139158
implementation 'androidx.appcompat:appcompat:1.6.1'
140159
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
141-
implementation 'app.rive:rive-android:10.4.5'
160+
implementation "app.rive:rive-android:${riveAndroidVersion}"
142161
implementation "androidx.startup:startup-runtime:1.1.1"
143162
implementation 'com.android.volley:volley:1.2.0'
144163
}

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"name": "rive-react-native",
33
"version": "9.6.2",
4+
"runtimeVersions": {
5+
"ios": "6.12.0",
6+
"android": "10.4.5"
7+
},
48
"workspaces": [
59
"example"
610
],

rive-react-native.podspec

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ require "json"
22

33
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
44

5+
# Resolve Rive iOS SDK version
6+
podfile_properties_path = File.join(__dir__, "ios", "Podfile.properties.json")
7+
if File.exist?(podfile_properties_path)
8+
podfile_properties = JSON.parse(File.read(podfile_properties_path))
9+
rive_ios_version = podfile_properties["RiveRuntimeIOSVersion"]
10+
end
11+
12+
rive_ios_version ||= package["runtimeVersions"]["ios"]
13+
14+
if rive_ios_version.nil?
15+
raise "Could not determine Rive iOS SDK version. Please add 'runtimeVersions.ios' to package.json"
16+
end
17+
18+
Pod::UI.puts "rive-react-native: Using Rive iOS SDK #{rive_ios_version}"
19+
520
Pod::Spec.new do |s|
621
s.name = "rive-react-native"
722
s.version = package["version"]
@@ -18,5 +33,5 @@ Pod::Spec.new do |s|
1833
s.swift_version = "5.0"
1934

2035
s.dependency "React-Core"
21-
s.dependency "RiveRuntime", "6.12.0"
36+
s.dependency "RiveRuntime", rive_ios_version
2237
end

0 commit comments

Comments
 (0)