Skip to content

Commit

Permalink
[autolinking] Use NodeJS to resolve autolinking script location & pop…
Browse files Browse the repository at this point in the history
…ularise it among other imports (#13901)
  • Loading branch information
bbarthec authored Aug 4, 2021
1 parent 941f41a commit 05f2ed0
Show file tree
Hide file tree
Showing 22 changed files with 161 additions and 115 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ configurations.all {
}
}

apply from: "../../node_modules/react-native-unimodules/gradle.groovy"
apply from: new File(["node", "--print", "require.resolve('react-native-unimodules/package.json')"].execute().text.trim(), "../gradle.groovy")

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
Expand Down
2 changes: 1 addition & 1 deletion android/expoview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ configurations.all {
}

// Import gradle helpers for unimodules.
apply from: "../../node_modules/react-native-unimodules/gradle.groovy"
apply from: new File(["node", "--print", "require.resolve('react-native-unimodules/package.json')"].execute().text.trim(), "../gradle.groovy")
// WHEN_VERSIONING_REMOVE_TO_HERE

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ project(":expo-random").projectDir = new File("../packages/expo-random/android")
// WHEN_DISTRIBUTING_REMOVE_TO_HERE

// Import gradle helpers for unimodules.
apply from: '../node_modules/react-native-unimodules/gradle.groovy'
apply from: new File(["node", "--print", "require.resolve('react-native-unimodules/package.json')"].execute().text.trim(), "../gradle.groovy")

// Include unimodules.
includeUnimodulesProjects(
Expand Down
4 changes: 2 additions & 2 deletions apps/bare-expo/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ project.ext.react = [
enableHermes: (findProperty('expo.jsEngine') ?: "jsc") == "hermes", // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute().text.trim(), "../react.gradle");

/**
* Set this to true to create two separate APKs instead of one:
Expand Down Expand Up @@ -255,7 +255,7 @@ class GenerateDynamicMacrosPlugin implements Plugin<Project> {
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute().text.trim(), "../native_modules.gradle");
applyNativeModulesAppBuildGradle(project)

// [Custom]: Add Google Services file
Expand Down
4 changes: 2 additions & 2 deletions apps/bare-expo/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute().text.trim(), "../native_modules.gradle");
applyNativeModulesSettingsGradle(settings)

include(":unimodules-test-core")
Expand All @@ -8,7 +8,7 @@ include(":expo-dev-client")
project(":expo-dev-client").projectDir = new File("../../../packages/expo-dev-client/android")

// Include Expo modules
apply from: '../../../packages/expo-modules-core/scripts/autolinking.gradle'
apply from: new File(["node", "--print", "require.resolve('expo-modules-core/package.json')"].execute().text.trim(), "../scripts/autolinking.gradle");
useExpoModules()

rootProject.name = 'BareExpo'
Expand Down
8 changes: 4 additions & 4 deletions apps/bare-expo/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ platform :ios, '12.0'
inhibit_all_warnings!

# Import the auto-linking packages
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../../../packages/@unimodules/react-native-adapter/scripts/autolinking'
require File.join(`node --print "require.resolve('react-native/package.json')"`, "../scripts/react_native_pods")
require File.join(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`, "../native_modules")
require File.join(`node --print "require.resolve('@unimodules/react-native-adapter/package.json')"`, "../scripts/autolinking")

abstract_target 'BareExpoMain' do
use_expo_modules!
Expand Down Expand Up @@ -38,7 +38,7 @@ abstract_target 'BareExpoMain' do

target 'BareExpo' do
# Enables Flipper.

# Uncomment to opt-in to using Flipper
# Note that we don't call `flipper_post_install`.
# It causes problems with cocoapods. We add the FB_SONARKIT_ENABLED manually instead.
Expand Down
2 changes: 1 addition & 1 deletion apps/bare-expo/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,6 @@ SPEC CHECKSUMS:
Yoga: 7740b94929bbacbddda59bf115b5317e9a161598
ZXingObjC: fdbb269f25dd2032da343e06f10224d62f537bdb

PODFILE CHECKSUM: f331210d64cfd0446d6e7c8df31842a096c50f66
PODFILE CHECKSUM: 0a13ed828b54efc90f2516e3e89a866b85568b21

COCOAPODS: 1.10.1
3 changes: 2 additions & 1 deletion apps/bare-sandbox/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json"].execute().text.trim(), "../native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
4 changes: 2 additions & 2 deletions apps/bare-sandbox/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
rootProject.name = 'bare-sandbox'

apply from: '../node_modules/@unimodules/react-native-adapter/scripts/autolinking.gradle'
apply from: new File(["node", "--print", "require.resolve('@unimodules/react-native-adapter/package.json')"].execute().text.trim(), "../scripts/autolinking.gradle");
useExpoModules([:])

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json"].execute().text.trim(), "../native_modules.gradle");
applyNativeModulesSettingsGradle(settings)

include(":unimodules-test-core")
Expand Down
6 changes: 3 additions & 3 deletions apps/bare-sandbox/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../../../packages/@unimodules/react-native-adapter/scripts/autolinking'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require File.join(`node --print "require.resolve('react-native/package.json')"`, "../scripts/react_native_pods")
require File.join(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`, "../native_modules")
require File.join(`node --print "require.resolve('@unimodules/react-native-adapter/package.json')"`, "../scripts/autolinking")

platform :ios, '11.0'

Expand Down
64 changes: 21 additions & 43 deletions apps/bare-sandbox/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,57 +1,50 @@
PODS:
- boost-for-react-native (1.63.0)
- DoubleConversion (1.1.6)
- EXAppleAuthentication (3.2.0):
- UMCore
- EXApplication (3.2.0):
- UMCore
- EXBlur (9.0.3):
- UMCore
- EXClipboard (1.1.0):
- UMCore
- EXConstants (11.0.0):
- ExpoModulesCore
- UMCore
- EXKeepAwake (9.2.0):
- UMCore
- expo-dev-client (0.3.0):
- expo-dev-client (0.4.5):
- expo-dev-launcher
- expo-dev-menu
- expo-dev-menu-interface
- EXUpdatesInterface
- expo-dev-launcher (0.5.1):
- expo-dev-launcher/Main (= 0.5.1)
- expo-dev-launcher (0.6.5):
- expo-dev-launcher/Main (= 0.6.5)
- expo-dev-menu-interface
- EXUpdatesInterface
- React
- expo-dev-launcher/Main (0.5.1):
- expo-dev-launcher/Main (0.6.5):
- expo-dev-launcher/Unsafe
- expo-dev-menu-interface
- EXUpdatesInterface
- React
- expo-dev-launcher/Unsafe (0.5.1):
- expo-dev-launcher/Unsafe (0.6.5):
- expo-dev-menu-interface
- EXUpdatesInterface
- React
- expo-dev-menu (0.7.0):
- expo-dev-menu (0.7.5):
- expo-dev-menu-interface
- expo-dev-menu/Main (= 0.7.0)
- React
- expo-dev-menu-interface (0.3.1):
- expo-dev-menu/Main (= 0.7.5)
- React
- expo-dev-menu/Main (0.7.0):
- expo-dev-menu-interface (0.3.2)
- expo-dev-menu/Main (0.7.5):
- expo-dev-menu-interface
- expo-dev-menu/Vendored
- React
- expo-dev-menu/Vendored (0.7.0):
- expo-dev-menu/Vendored (0.7.5):
- expo-dev-menu-interface
- React
- ExpoModulesCore (0.1.1):
- React-Core
- EXSplashScreen (0.11.0):
- React-Core
- UMCore
- EXUpdatesInterface (0.1.0)
- EXUpdatesInterface (0.2.2)
- FBLazyVector (0.63.2)
- FBReactNativeSpec (0.63.2):
- Folly (= 2020.01.13.00)
Expand Down Expand Up @@ -333,18 +326,15 @@ PODS:
- UMAppLoader (2.2.0)
- UMCore (7.1.1):
- ExpoModulesCore
- UMReactNativeAdapter (6.3.0):
- UMReactNativeAdapter (6.4.0):
- ExpoModulesCore
- UMTaskManagerInterface (6.2.0):
- UMCore
- Yoga (1.14.0)

DEPENDENCIES:
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- EXAppleAuthentication (from `../../../packages/expo-apple-authentication/ios`)
- EXApplication (from `../../../packages/expo-application/ios`)
- EXBlur (from `../../../packages/expo-blur/ios`)
- EXClipboard (from `../../../packages/expo-clipboard/ios`)
- EXConstants (from `../../../packages/expo-constants/ios`)
- EXKeepAwake (from `../../../packages/expo-keep-awake/ios`)
- expo-dev-client (from `../../../packages/expo-dev-client`)
Expand Down Expand Up @@ -396,18 +386,9 @@ SPEC REPOS:
EXTERNAL SOURCES:
DoubleConversion:
:podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
EXAppleAuthentication:
inhibit_warnings: false
:path: "../../../packages/expo-apple-authentication/ios"
EXApplication:
inhibit_warnings: false
:path: "../../../packages/expo-application/ios"
EXBlur:
inhibit_warnings: false
:path: "../../../packages/expo-blur/ios"
EXClipboard:
inhibit_warnings: false
:path: "../../../packages/expo-clipboard/ios"
EXConstants:
inhibit_warnings: false
:path: "../../../packages/expo-constants/ios"
Expand Down Expand Up @@ -503,19 +484,16 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
DoubleConversion: cde416483dac037923206447da6e1454df403714
EXAppleAuthentication: 5994731faf4a3dd32be4a4b3e9feb930c2fa25c1
EXApplication: 9ff2a206009d6e55bca6c20b3f33d07986b51ef3
EXBlur: 50d490040f3b14898ed8198d5125dc699189f4d9
EXClipboard: c66f7d22ba754496b0fc6b23a2cb9a3e10fa1581
EXConstants: 7025f7965e87340f8e7493edc7062071ff48449f
EXConstants: 0c200d22d140d3f1834dc51c4ebe0465ddaa82c5
EXKeepAwake: f4105ef469be7b283f66ce2d7234bb71ac80cd26
expo-dev-client: 785792b8c8228d7adb8e8a0e7960ea28a254d08b
expo-dev-launcher: 669533ea784dfeb1cb763a49e436d62db63252c1
expo-dev-menu: 1c5a5194cb123e6f90358e815711cfea34524d72
expo-dev-menu-interface: 4fda2fa6d974a518e546ca1193340513b0a8b0e8
ExpoModulesCore: 085657f53b53e86ab71477ba7f5b75fe174ee9e4
expo-dev-client: 6f833f384c5fcc59e96a91268601dabcd16f70f0
expo-dev-launcher: 0b3fe43607f31238f49445e7310e185675061762
expo-dev-menu: c1d43574828f37cb541a0bb52fe7bb7829586147
expo-dev-menu-interface: 59fbd00f527c7ae65aa86144e6c8af3761fc037f
ExpoModulesCore: 82ee658feb15e6804de9f3530c39c62ff900048b
EXSplashScreen: da00ad1d61c395c5c81b252c5987e8f83cba230a
EXUpdatesInterface: 8e4f28434a2e6a75803c4ea0ab12cfb07ebb3438
EXUpdatesInterface: b68e78b912a03fff7901a5f46ec200c45e3506a5
FBLazyVector: 3ef4a7f62e7db01092f9d517d2ebc0d0677c4a37
FBReactNativeSpec: dc7fa9088f0f2a998503a352b0554d69a4391c5a
Folly: b73c3869541e86821df3c387eb0af5f65addfab4
Expand Down Expand Up @@ -545,10 +523,10 @@ SPEC CHECKSUMS:
RNScreens: 21b73c94c9117e1110a79ee0ee80c93ccefed8ce
UMAppLoader: 21af63390e55c82e037fb9752d93114a80ecf16e
UMCore: b531b41645f9250a138583bd0ac52edbc7a0e16c
UMReactNativeAdapter: c3ee775a59120220d5c564716ebc22e9f615b4f2
UMReactNativeAdapter: 5d34de03540c3a22624919492974df6f187d9c55
UMTaskManagerInterface: 2be431101b73604e64fbfffcf759336f9d8fccbb
Yoga: 7740b94929bbacbddda59bf115b5317e9a161598

PODFILE CHECKSUM: a184d50e9f00f43a3562db5398f77274caba3857
PODFILE CHECKSUM: 8d72685ed2d1dcae2f50964c74af7ea7cd4cc72f

COCOAPODS: 1.10.1
2 changes: 1 addition & 1 deletion docs/pages/bare/installing-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Once you have applied the changes from the above diff, the following additional
<div style={{marginTop: -10}} />

- Add the `"Supporting"` directory containing `"Expo.plist"` to your project in Xcode.
- In Xcode, under the Build Phases tab of your main project, expand the phase entitled "Bundle React Native code and images." Add the following to a new line at the bottom of the script: `../node_modules/expo-updates/scripts/create-manifest-ios.sh`
- In Xcode, under the Build Phases tab of your main project, expand the phase entitled "Bundle React Native code and images." Add the following to a new line at the bottom of the script: `` `node --print "require.resolve('expo-updates/package.json').slice(0, -13) + '/scripts/create-manifest-ios.sh'"` `` (supports monorepos and non-default project structure). You can alternatively use this line: `../node_modules/expo-updates/scripts/create-manifest-ios.sh` (supports only default project structure).

<div style={{marginTop: -15}} />

Expand Down
4 changes: 2 additions & 2 deletions docs/pages/guides/setup-native-firebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ After following the iOS and Android setup, you can optionally configure your pro
```rb
# At the top of the file
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native-unimodules/cocoapods'
require File.join(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`, "../native_modules")
require File.join(`node --print "require.resolve('react-native-unimodules/package.json')"`, "../cocoapods.rb")
# ...
Expand Down
23 changes: 12 additions & 11 deletions docs/public/static/diffs/expo-updates-android.diff
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ index e5b1a7d..d06dfd0 100644
project.ext.react = [
enableHermes: false, // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"
+apply from: "../../node_modules/expo-updates/scripts/create-manifest-android.gradle"


-apply from: "../../node_modules/react-native/react.gradle"
+apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute().text.trim(), "../react.gradle")
+apply from: new File(["node", "--print", "require.resolve('expo-updates/package.json')"].execute().text.trim(), "../scripts/create-manifest-android.gradle")

/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
Expand Down Expand Up @@ -39,22 +40,22 @@ index 0151e90..48cc96c 100644
--- a/android/app/src/main/java/com/myapp/MainApplication.java
+++ b/android/app/src/main/java/com/myapp/MainApplication.java
@@ -17,10 +17,14 @@ import java.util.Arrays;

import org.unimodules.adapters.react.ModuleRegistryAdapter;
import org.unimodules.adapters.react.ReactModuleRegistryProvider;
import org.unimodules.core.interfaces.SingletonModule;

+import android.net.Uri;
+import expo.modules.updates.UpdatesController;
+import javax.annotation.Nullable;
+
public class MainApplication extends Application implements ReactApplication {
private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(new BasePackageList().getPackageList(), null);

private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@@ -46,10 +50,28 @@ public class MainApplication extends Application implements ReactApplication {

@Override
protected String getJSMainModuleName() {
return "index";
Expand All @@ -78,12 +79,12 @@ index 0151e90..48cc96c 100644
+ }
+ }
};

@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
@@ -57,10 +79,15 @@ public class MainApplication extends Application implements ReactApplication {

@Override
public void onCreate() {
super.onCreate();
Expand All @@ -95,6 +96,6 @@ index 0151e90..48cc96c 100644
+
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}

/**
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
Loading

0 comments on commit 05f2ed0

Please sign in to comment.