From b5764e22ad204fc44bed55cfeb38c78bb2bbdbcf Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Thu, 5 May 2022 13:58:21 -0700 Subject: [PATCH] [docs] Update installing Expo modules guide --- docs/pages/bare/installing-expo-modules.md | 4 +- docs/public/static/diffs/expo-android.diff | 46 +++++++++++----------- docs/public/static/diffs/expo-ios.diff | 22 +++++------ 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/docs/pages/bare/installing-expo-modules.md b/docs/pages/bare/installing-expo-modules.md index 488e912b281a7..b94f967ece658 100644 --- a/docs/pages/bare/installing-expo-modules.md +++ b/docs/pages/bare/installing-expo-modules.md @@ -19,13 +19,15 @@ If you have an existing project without Expo modules installed (perhaps created Aside from initializing a new project with `expo-cli`, the easiest way to get up and running is with the `install-expo-modules` command. - + - ✅ **When the command succeeds**, you will be able to add any Expo module in your app! Proceed to [Usage](#usage) for more information. - ❌ **If the command fails**, please follow the manual installation instructions. Updating code programmatically can be tricky, and if your project deviates significantly from a default React Native project, then you need to perform manual installation and adapt the instructions here to your codebase. ## Manual installation +The following instructions apply to installing the latest version of Expo modules in React Native 0.68. +
diff --git a/docs/public/static/diffs/expo-android.diff b/docs/public/static/diffs/expo-android.diff index 4378e7d770bd2..3fd91f153b393 100644 --- a/docs/public/static/diffs/expo-android.diff +++ b/docs/public/static/diffs/expo-android.diff @@ -2,25 +2,21 @@ diff --git a/android/app/src/main/java/com/myapp/MainActivity.java b/android/app index 557797a..2ccae2e 100644 --- a/android/app/src/main/java/com/myapp/MainActivity.java +++ b/android/app/src/main/java/com/myapp/MainActivity.java -@@ -1,4 +1,6 @@ +@@ -1,4 +1,5 @@ package com.myapp; +import expo.modules.ReactActivityDelegateWrapper; -+import com.facebook.react.ReactActivityDelegate; import com.facebook.react.ReactActivity; - -@@ -12,4 +14,11 @@ public class MainActivity extends ReactActivity { - protected String getMainComponentName() { - return "Example"; + import com.facebook.react.ReactActivityDelegate; +@@ -21,7 +22,7 @@ public class MainActivity extends ReactActivity { + */ + @Override + protected ReactActivityDelegate createReactActivityDelegate() { +- return new MainActivityDelegate(this, getMainComponentName()); ++ return new ReactActivityDelegateWrapper(this, new MainActivityDelegate(this, getMainComponentName())); } -+ -+ @Override -+ protected ReactActivityDelegate createReactActivityDelegate() { -+ return new ReactActivityDelegateWrapper(this, -+ new ReactActivityDelegate(this, getMainComponentName()) -+ ); -+ } - } + + public static class MainActivityDelegate extends ReactActivityDelegate { diff --git a/android/app/src/main/java/com/myapp/MainApplication.java b/android/app/src/main/java/com/myapp/MainApplication.java index fd8ec88..73cbea8 100644 --- a/android/app/src/main/java/com/myapp/MainApplication.java @@ -33,7 +29,7 @@ index fd8ec88..73cbea8 100644 import android.app.Application; import android.content.Context; -@@ -14,7 +17,7 @@ import java.util.List; +@@ -16,7 +19,7 @@ import java.util.List; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = @@ -42,24 +38,28 @@ index fd8ec88..73cbea8 100644 @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; -@@ -33,7 +36,7 @@ public class MainApplication extends Application implements ReactApplication { +@@ -35,10 +38,10 @@ public class MainApplication extends Application implements ReactApplication { protected String getJSMainModuleName() { return "index"; } - }; + }); + private final ReactNativeHost mNewArchitectureNativeHost = +- new MainApplicationReactNativeHost(this); ++ new ReactNativeHostWrapper(this, new MainApplicationReactNativeHost(this)); + @Override public ReactNativeHost getReactNativeHost() { -@@ -45,6 +48,7 @@ public class MainApplication extends Application implements ReactApplication { - super.onCreate(); +@@ -56,6 +59,7 @@ public class MainApplication extends Application implements ReactApplication { + ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; SoLoader.init(this, /* native exopackage */ false); initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); + ApplicationLifecycleDispatcher.onApplicationCreate(this); } /** -@@ -77,4 +81,10 @@ public class MainApplication extends Application implements ReactApplication { +@@ -88,4 +92,10 @@ public class MainApplication extends Application implements ReactApplication { } } } @@ -74,10 +74,10 @@ diff --git a/android/settings.gradle b/android/settings.gradle index 47725a0..e787ab1 100644 --- a/android/settings.gradle +++ b/android/settings.gradle -@@ -1,3 +1,6 @@ - rootProject.name = 'Example' - apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) - include ':app' +@@ -7,3 +7,6 @@ if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") + include(":ReactAndroid") + project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid') + } + +apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle") +useExpoModules() \ No newline at end of file diff --git a/docs/public/static/diffs/expo-ios.diff b/docs/public/static/diffs/expo-ios.diff index f604b313ad920..f46574ab4afd4 100644 --- a/docs/public/static/diffs/expo-ios.diff +++ b/docs/public/static/diffs/expo-ios.diff @@ -12,22 +12,20 @@ index ef1de86..d3d75b0 100644 @property (nonatomic, strong) UIWindow *window; -diff --git a/ios/MyApp/AppDelegate.m b/ios/MyApp/AppDelegate.m +diff --git a/ios/MyApp/AppDelegate.mm b/ios/MyApp/AppDelegate.mm index da9f60a..0164063 100644 ---- a/ios/MyApp/AppDelegate.m -+++ b/ios/MyApp/AppDelegate.m -@@ -31,8 +31,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( - InitializeFlipper(application); - #endif +--- a/ios/MyApp/AppDelegate.mm ++++ b/ios/MyApp/AppDelegate.mm +@@ -31,7 +31,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( + { + RCTAppSetupPrepareApp(application); - RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; -- RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge + RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions]; -+ RCTRootView *rootView = [self.reactDelegate createRootViewWithBridge:bridge - moduleName:@"MyApp" - initialProperties:nil]; -@@ -43,10 +43,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( + #if RCT_NEW_ARCH_ENABLED + _contextContainer = std::make_shared(); +@@ -50,10 +50,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( } self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; @@ -49,7 +47,7 @@ index 99b1b8d..71524e2 100644 require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' --platform :ios, '10.0' +-platform :ios, '11.0' +platform :ios, '12.0' target 'ModuleDiff' do