Skip to content

Commit

Permalink
[docs] Update installing Expo modules guide
Browse files Browse the repository at this point in the history
  • Loading branch information
brentvatne committed May 5, 2022
1 parent dc972a1 commit b5764e2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
4 changes: 3 additions & 1 deletion docs/pages/bare/installing-expo-modules.md
Expand Up @@ -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.

<InstallSection packageName="expo" cmd={["# Install and configure the expo package automatically", "npx install-expo-modules"]} hideBareInstructions />
<InstallSection packageName="expo" cmd={["# Install and configure the expo package automatically", "npx install-expo-modules@latest"]} hideBareInstructions />

-**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.

<InstallSection packageName="expo" cmd={["npm install expo"]} hideBareInstructions />

<br />
Expand Down
46 changes: 23 additions & 23 deletions docs/public/static/diffs/expo-android.diff
Expand Up @@ -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
Expand All @@ -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 =
Expand All @@ -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 {
}
}
}
Expand All @@ -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()
22 changes: 10 additions & 12 deletions docs/public/static/diffs/expo-ios.diff
Expand Up @@ -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<facebook::react::ContextContainer const>();
@@ -50,10 +50,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
Expand All @@ -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
Expand Down

0 comments on commit b5764e2

Please sign in to comment.