title | description |
---|---|
Install Expo modules |
Learn how to prepare your existing native project to install and use Expo modules and the module API. |
import InstallSection from '/components/plugins/InstallSection';
import { DiffBlock, Terminal } from '/ui/components/Snippet';
import { YesIcon, NoIcon } from '/ui/components/DocIcons';
import { Collapsible } from '/ui/components/Collapsible';
import { Step } from '~/ui/components/Step';
warning These instructions may not work for all projects. Support for integrating Expo modules into existing projects is still experimental. If you encounter issues, create an issue on GitHub
You should have a native project with React Native installed and configured to render a root view. If you don't have this yet, you can follow the "Integration with Existing Apps" guide on the React Native docs and then return here.
First, add the expo
package to your project. Ensure you are using a version of the expo
package that is compatible with the React Native version in your project. Learn more.
<Terminal cmd={['npm install expo']} />
Add the following to your `Podfile` in the `ios` directory: target '' do- use_expo_modules! config = use_native_modules! `} />
@main -class AppDelegate: UIResponder, UIApplicationDelegate { +class AppDelegate: ExpoAppDelegate {
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
- override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
- return true
- super.application(application, didFinishLaunchingWithOptions: launchOptions) } `} />
<DiffBlock raw={`diff --git a/android/app/src/main/java/com//MainApplication.kt b/android/app/src/main/java/com//MainApplication.kt new file mode 100644 index 0000000..2c8525a --- /dev/null +++ b/android/app/src/main/java/com//MainApplication.kt @@ -0,0 +1,19 @@ +package <my.app.package> + +import android.app.Application +import android.content.res.Configuration +import com.facebook.soloader.SoLoader +import expo.modules.ApplicationLifecycleDispatcher + +class MainApplication() : Application() {
- override fun onCreate() {
-
super.onCreate()
-
ApplicationLifecycleDispatcher.onApplicationCreate(this)
- }
- override fun onConfigurationChanged(newConfig: Configuration) {
-
super.onConfigurationChanged(newConfig)
-
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig)
- } +}`} />
<DiffBlock raw={`diff --git a/android/app/src/main/java/com//MainApplication.kt b/android/app/src/main/java/com//MainApplication.kt new file mode 100644 index 0000000..2c8525a --- /dev/null +++ b/android/app/src/main/java/com//MainApplication.kt @@ -0,0 +1,19 @@ class MainApplication() : Application() { override fun onCreate() { super.onCreate()
-
}
ApplicationLifecycleDispatcher.onApplicationCreate(this)
- override fun onConfigurationChanged(newConfig: Configuration) {
-
super.onConfigurationChanged(newConfig)
-
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig)
- }
}} /> Override
onConfigurationChanged` if you have not done so already.