Unity artifacts must be added before building the React Native app.
unity/android/unityLibrary-release.aar
The filename of the AAR can be edited in
build.gradle
located in the same directory, to switch betweendebug
andrelease
variants of your Unity artifact.
unity/ios/UnityFramework.xcframework/ios-arm64/UnityFramework.framework
(Device SDK)unity/ios/UnityFramework.xcframework/ios-x86_64-simulator/UnityFramework.framework
(Simulator SDK)
-
Export an Android project from Unity to somewhere on your computer.
-
Open the generated project in Android Studio.
-
Go to Build Variants and change Active Build Variant to Release:
-
Press Execute Gradle Task in the Gradle panel. Type in
gradle build
and execute. -
Find
unityLibrary-release.aar
atunityLibrary/build/outputs/aar/unityLibrary-release.aar
. -
Copy this file into the React Native project.
unity/android/unityLibrary-release.aar
-
Export an iOS project from Unity to somewhere on your computer.
-
Open the generated project in Xcode.
-
Go to Edit Scheme and change Build Configuration to Release:
-
Build the project:
- ⌘ + B
-
Find the resulting framework by right-clicking UnityFramework in the project explorer and Show in Finder:
-
Copy this framework into the React Native project.
unity/ios/UnityFramework.xcframework/ios-arm64/UnityFramework.framework
-
Repeat steps 1 to 6 for iOS Simulator if necessary.
- Make sure to select Simulator SDK in Unity player settings before exporting.