Skip to content

Commit 34c2053

Browse files
authored
chore: allow to customize ios and android sdk versions (#4)
1 parent ef05403 commit 34c2053

File tree

4 files changed

+114
-2
lines changed

4 files changed

+114
-2
lines changed

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,63 @@ const riveRef = useRef<HybridView<RiveViewProps, RiveViewMethods>>(null);
6363
/>
6464
```
6565

66+
## Native SDK Version Customization
67+
68+
> **⚠️ Advanced Usage:** Customizing native SDK versions is intended for advanced users only. Using non-default versions may cause build-time errors, or compatibility issues. Always review and update custom versions when upgrading react-native-rive.
69+
70+
By default, react-native-rive uses specific versions of the Rive native SDKs defined in the library's `package.json` (`runtimeVersions.ios` and `runtimeVersions.android`). You can customize these versions if needed.
71+
72+
### Vanilla React Native
73+
74+
Add the appropriate properties to your configuration files:
75+
76+
**iOS** - Add to `ios/Podfile.properties.json`:
77+
78+
```json
79+
{
80+
"RiveRuntimeIOSVersion": "6.13.0"
81+
}
82+
```
83+
84+
**Android** - Add to `android/gradle.properties`:
85+
86+
```properties
87+
Rive_RiveRuntimeAndroidVersion=10.6.0
88+
```
89+
90+
### Expo
91+
92+
Use an inline config plugin in your `app.config.ts`:
93+
94+
```typescript
95+
import { withPodfileProperties, withGradleProperties } from '@expo/config-plugins';
96+
97+
export default {
98+
expo: {
99+
// ... other config
100+
plugins: [
101+
(config) => {
102+
config = withPodfileProperties(config, (config) => {
103+
config.modResults['RiveRuntimeIOSVersion'] = '6.13.0';
104+
return config;
105+
});
106+
107+
config = withGradleProperties(config, (config) => {
108+
config.modResults.push({
109+
type: 'property',
110+
key: 'Rive_RiveRuntimeAndroidVersion',
111+
value: '10.6.0',
112+
});
113+
return config;
114+
});
115+
116+
return config;
117+
},
118+
],
119+
},
120+
};
121+
```
122+
66123
## Error Handling
67124

68125
All Rive operations can be wrapped in try/catch blocks for error handling:

Rive.podspec

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

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

5+
rive_ios_version = nil
6+
7+
if ENV['RIVE_RUNTIME_IOS_VERSION']
8+
rive_ios_version = ENV['RIVE_RUNTIME_IOS_VERSION']
9+
end
10+
11+
if !rive_ios_version && defined?($RiveRuntimeIOSVersion)
12+
rive_ios_version = $RiveRuntimeIOSVersion
13+
end
14+
15+
if !rive_ios_version && defined?(Pod::Config) && Pod::Config.respond_to?(:instance)
16+
podfile_properties_path = File.join(Pod::Config.instance.installation_root, 'Podfile.properties.json')
17+
if File.exist?(podfile_properties_path)
18+
podfile_properties = JSON.parse(File.read(podfile_properties_path)) rescue {}
19+
rive_ios_version = podfile_properties['RiveRuntimeIOSVersion'] if podfile_properties['RiveRuntimeIOSVersion']
20+
end
21+
end
22+
23+
if !rive_ios_version && package['runtimeVersions'] && package['runtimeVersions']['ios']
24+
rive_ios_version = package['runtimeVersions']['ios']
25+
end
26+
27+
if !rive_ios_version
28+
raise "Internal Error: Failed to determine Rive iOS SDK version. Please ensure package.json contains 'runtimeVersions.ios'"
29+
end
30+
31+
Pod::UI.puts "react-native-rive: Rive iOS SDK #{rive_ios_version}"
32+
533
Pod::Spec.new do |s|
634
s.name = "Rive"
735
s.version = package["version"]
@@ -18,7 +46,7 @@ Pod::Spec.new do |s|
1846
load 'nitrogen/generated/ios/Rive+autolinking.rb'
1947
add_nitrogen_files(s)
2048

21-
s.dependency "RiveRuntime", "6.12.0"
49+
s.dependency "RiveRuntime", rive_ios_version
2250

2351
install_modules_dependencies(s)
2452
end

android/build.gradle

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,33 @@ repositories {
122122

123123
def kotlin_version = getExtOrDefault("kotlinVersion")
124124

125+
def getRiveAndroidVersion() {
126+
if (rootProject.ext.has('RiveRuntimeAndroidVersion')) {
127+
return rootProject.ext.get('RiveRuntimeAndroidVersion')
128+
}
129+
130+
if (project.hasProperty('Rive_RiveRuntimeAndroidVersion')) {
131+
return project.property('Rive_RiveRuntimeAndroidVersion')
132+
}
133+
134+
def packageJson = file("${projectDir}/../package.json")
135+
if (packageJson.exists()) {
136+
def json = new groovy.json.JsonSlurper().parseText(packageJson.text)
137+
if (json.runtimeVersions?.android) {
138+
return json.runtimeVersions.android
139+
}
140+
}
141+
142+
throw new GradleException("Failed to determine Rive Android SDK version. Please ensure package.json contains 'runtimeVersions.android'")
143+
}
144+
145+
def riveAndroidVersion = getRiveAndroidVersion()
146+
println "react-native-rive: Rive Android SDK ${riveAndroidVersion}"
147+
125148
dependencies {
126149
implementation "com.facebook.react:react-android"
127150
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
128-
implementation 'app.rive:rive-android:10.5.0'
151+
implementation "app.rive:rive-android:${riveAndroidVersion}"
129152
implementation "androidx.startup:startup-runtime:1.2.0"
130153
implementation project(":react-native-nitro-modules")
131154
}

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
"url": "https://github.com/rive-app/rive-nitro-react-native/issues"
6060
},
6161
"homepage": "https://github.com/rive-app/rive-nitro-react-native#readme",
62+
"runtimeVersions": {
63+
"ios": "6.12.0",
64+
"android": "10.5.0"
65+
},
6266
"publishConfig": {
6367
"registry": "https://registry.npmjs.org/"
6468
},

0 commit comments

Comments
 (0)