Skip to content

Commit

Permalink
deps: Add react-native-unimodules@0.6.0 (no caret).
Browse files Browse the repository at this point in the history
This lets us use individual Expo packages. In particular, we plan to
use expo-apple-authentication soon, for in place of some existing
dependencies, such as (non-exhaustively) react-native-safe-area and
react-native-orientation.

So, add it, without yet using it, following instructions at
https://github.com/unimodules/react-native-unimodules/blob/30da302a8/README.md.

It looks like Unimodules has also gone by the name Universal
Modules, but this may be an old name that has been superseded:
unimodules/unimodules.org@23c53dd...bdc80d9

Note that we omit the caret in 0.6.0, to disallow silent minor
version upgrades. The maintainers are not adhering to semantic
versioning, and they expect that you're using the latest version of
React Native if you're using the latest version of unimodules,
including minor versions; see
https://github.com/unimodules/react-native-unimodules/issues/100#issuecomment-566436685.

In that same comment, a maintainer says that 0.7.0-rc.4 is the
minimum version with AndroidX compatibility. If this is true, then
we may have a slight problem, because 0.7.0-rc.4, just like 0.6.0,
does not work with RN 0.59.10. That would mean we had to do the
AndroidX upgrade (PR zulip#3852) at the same time as the RN v0.60 upgrade
(issue zulip#3548). Greg thinks it's likely that the maintainer is
mistaken that there's a minimum version of unimodules required to
use AndroidX; the AndroidX engineers designed a smooth migration
path such that this shouldn't happen (see Greg's comment at
zulip#3987 (comment)).

A later commit in this series describes another concern with Expo's
handling of version constraints, with expo-application (and others),
with a reference to expo/expo#7728, which
I just filed.

A couple of fixes had to be made to get it to work on Android:

First, pass an additional argument to a constructor in
MainApplication.java, in a fix given by a maintainer at
https://github.com/unimodules/react-native-unimodules/issues/128#issuecomment-606027692.

Second, specify a new dependency for
`unimodules-react-native-adapter` in our own `android/build.gradle`,
in a fix that is necessary because we're locked on version 0.6.0 of
react-native-unimodules. Filed as
https://github.com/unimodules/react-native-unimodules/issues/130.

Also (not Android-specific), ran `yarn yarn-deduplicate` to
deduplicate `ua-parser-js`, following a prompt from
`tools/test deps`.

Fixes: zulip#3987
  • Loading branch information
Chris Bobbe authored and gnprice committed Apr 8, 2020
1 parent 1398cb2 commit cb87f90
Show file tree
Hide file tree
Showing 11 changed files with 305 additions and 8 deletions.
3 changes: 3 additions & 0 deletions android/app/build.gradle
Expand Up @@ -2,6 +2,8 @@ apply plugin: "com.android.application"
apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"

apply from: '../../node_modules/react-native-unimodules/gradle.groovy'

import com.android.build.OutputFile

/**
Expand Down Expand Up @@ -211,6 +213,7 @@ dependencies {
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.facebook.fresco:animated-gif:1.10.0' // For animated GIF support
implementation "com.android.support:customtabs:${rootProject.ext.supportLibVersion}"
addUnimodulesDependencies()

testImplementation 'junit:junit:4.12'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.0'
Expand Down
Expand Up @@ -20,12 +20,17 @@
import io.sentry.RNSentryPackage;
import java.util.Arrays;
import java.util.List;
import org.unimodules.adapters.react.ModuleRegistryAdapter;
import org.unimodules.adapters.react.ReactModuleRegistryProvider;

import com.zulipmobile.generated.BasePackageList;
import com.zulipmobile.notifications.ConversationMap;
import com.zulipmobile.notifications.FCMPushNotifications;
import com.zulipmobile.notifications.NotificationsPackage;

public class MainApplication extends Application implements ReactApplication {
private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(new BasePackageList().getPackageList(), null);

private ConversationMap conversations;
public ConversationMap getConversations() { return conversations; }

Expand All @@ -52,7 +57,8 @@ protected List<ReactPackage> getPackages() {
new RNSoundPackage(),
new RNDeviceInfo(),
new ZulipNativePackage(),
new NotificationsPackage()
new NotificationsPackage(),
new ModuleRegistryAdapter(mModuleRegistryProvider)
);
}

Expand Down
@@ -0,0 +1,15 @@
package com.zulipmobile.generated;

import java.util.Arrays;
import java.util.List;
import org.unimodules.core.interfaces.Package;

public class BasePackageList {
public List<Package> getPackageList() {
return Arrays.<Package>asList(
new expo.modules.constants.ConstantsPackage(),
new expo.modules.filesystem.FileSystemPackage(),
new expo.modules.permissions.PermissionsPackage()
);
}
}
6 changes: 6 additions & 0 deletions android/build.gradle
Expand Up @@ -53,6 +53,12 @@ project(":react-native-device-info").beforeEvaluate {
ext.googlePlayServicesVersion = "16.1.0"
}

project(":unimodules-react-native-adapter").afterEvaluate {
it.dependencies {
implementation 'com.facebook.react:react-native:+'
}
}

subprojects {
afterEvaluate {
if (project.hasProperty("android")) {
Expand Down
4 changes: 4 additions & 0 deletions android/settings.gradle
@@ -1,4 +1,8 @@
rootProject.name = 'ZulipMobile'

apply from: '../node_modules/react-native-unimodules/gradle.groovy'
includeUnimodulesProjects()

include ':@react-native-community_async-storage'
project(':@react-native-community_async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/async-storage/android')
include ':@sentry_react-native'
Expand Down
5 changes: 5 additions & 0 deletions ios/Podfile
Expand Up @@ -2,6 +2,8 @@
# (project > ZulipMobile > Info in Xcode)
platform :ios, '10.3'

require_relative '../node_modules/react-native-unimodules/cocoapods.rb'

# This list will need to change for RN >= v0.60. If you're changing it
# for any other reason, first look at the example Podfile for v0.59 at
# https://github.com/facebook/react-native-website/blob/ded79d2cf/docs/integration-with-existing-apps.md#configuring-cocoapods-dependencies.
Expand Down Expand Up @@ -47,6 +49,9 @@ target 'ZulipMobile' do
pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'
pod 'react-native-simple-toast', :path => '../node_modules/react-native-simple-toast'

# unimodules provides Expo packages individually.
use_unimodules!

target 'ZulipMobileTests' do
inherit! :search_paths
# Pods for testing
Expand Down
107 changes: 106 additions & 1 deletion ios/Podfile.lock
@@ -1,6 +1,16 @@
PODS:
- boost-for-react-native (1.63.0)
- DoubleConversion (1.1.6)
- EXAppLoaderProvider (7.0.0)
- EXConstants (7.0.1):
- UMConstantsInterface
- UMCore
- EXFileSystem (7.0.0):
- UMCore
- UMFileSystemInterface
- EXPermissions (7.0.0):
- UMCore
- UMPermissionsInterface
- Folly (2018.10.22.00):
- boost-for-react-native
- DoubleConversion
Expand Down Expand Up @@ -107,10 +117,29 @@ PODS:
- Sentry/Core (= 4.4.3)
- Sentry/Core (4.4.3)
- Toast (4.0.0)
- UMBarCodeScannerInterface (4.0.0)
- UMCameraInterface (4.0.0)
- UMConstantsInterface (4.0.0)
- UMCore (4.0.0)
- UMFaceDetectorInterface (4.0.0)
- UMFileSystemInterface (4.0.0)
- UMFontInterface (4.0.0)
- UMImageLoaderInterface (4.0.0)
- UMPermissionsInterface (4.0.0)
- UMReactNativeAdapter (4.0.0):
- React
- UMCore
- UMFontInterface
- UMSensorsInterface (4.0.0)
- UMTaskManagerInterface (4.0.0)
- yoga (0.59.10.React)

DEPENDENCIES:
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- EXAppLoaderProvider (from `../node_modules/expo-app-loader-provider/ios`)
- EXConstants (from `../node_modules/expo-constants/ios`)
- EXFileSystem (from `../node_modules/expo-file-system/ios`)
- EXPermissions (from `../node_modules/expo-permissions/ios`)
- Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`)
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
Expand Down Expand Up @@ -144,6 +173,18 @@ DEPENDENCIES:
- "RNSentry (from `../node_modules/@sentry/react-native`)"
- RNSound (from `../node_modules/react-native-sound`)
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
- UMBarCodeScannerInterface (from `../node_modules/unimodules-barcode-scanner-interface/ios`)
- UMCameraInterface (from `../node_modules/unimodules-camera-interface/ios`)
- UMConstantsInterface (from `../node_modules/unimodules-constants-interface/ios`)
- "UMCore (from `../node_modules/@unimodules/core/ios`)"
- UMFaceDetectorInterface (from `../node_modules/unimodules-face-detector-interface/ios`)
- UMFileSystemInterface (from `../node_modules/unimodules-file-system-interface/ios`)
- UMFontInterface (from `../node_modules/unimodules-font-interface/ios`)
- UMImageLoaderInterface (from `../node_modules/unimodules-image-loader-interface/ios`)
- UMPermissionsInterface (from `../node_modules/unimodules-permissions-interface/ios`)
- "UMReactNativeAdapter (from `../node_modules/@unimodules/react-native-adapter/ios`)"
- UMSensorsInterface (from `../node_modules/unimodules-sensors-interface/ios`)
- UMTaskManagerInterface (from `../node_modules/unimodules-task-manager-interface/ios`)
- yoga (from `../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
Expand All @@ -155,6 +196,18 @@ SPEC REPOS:
EXTERNAL SOURCES:
DoubleConversion:
:podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
EXAppLoaderProvider:
:path: !ruby/object:Pathname
path: "../node_modules/expo-app-loader-provider/ios"
EXConstants:
:path: !ruby/object:Pathname
path: "../node_modules/expo-constants/ios"
EXFileSystem:
:path: !ruby/object:Pathname
path: "../node_modules/expo-file-system/ios"
EXPermissions:
:path: !ruby/object:Pathname
path: "../node_modules/expo-permissions/ios"
Folly:
:podspec: "../node_modules/react-native/third-party-podspecs/Folly.podspec"
glog:
Expand Down Expand Up @@ -191,12 +244,52 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-sound"
RNVectorIcons:
:path: "../node_modules/react-native-vector-icons"
UMBarCodeScannerInterface:
:path: !ruby/object:Pathname
path: "../node_modules/unimodules-barcode-scanner-interface/ios"
UMCameraInterface:
:path: !ruby/object:Pathname
path: "../node_modules/unimodules-camera-interface/ios"
UMConstantsInterface:
:path: !ruby/object:Pathname
path: "../node_modules/unimodules-constants-interface/ios"
UMCore:
:path: !ruby/object:Pathname
path: "../node_modules/@unimodules/core/ios"
UMFaceDetectorInterface:
:path: !ruby/object:Pathname
path: "../node_modules/unimodules-face-detector-interface/ios"
UMFileSystemInterface:
:path: !ruby/object:Pathname
path: "../node_modules/unimodules-file-system-interface/ios"
UMFontInterface:
:path: !ruby/object:Pathname
path: "../node_modules/unimodules-font-interface/ios"
UMImageLoaderInterface:
:path: !ruby/object:Pathname
path: "../node_modules/unimodules-image-loader-interface/ios"
UMPermissionsInterface:
:path: !ruby/object:Pathname
path: "../node_modules/unimodules-permissions-interface/ios"
UMReactNativeAdapter:
:path: !ruby/object:Pathname
path: "../node_modules/@unimodules/react-native-adapter/ios"
UMSensorsInterface:
:path: !ruby/object:Pathname
path: "../node_modules/unimodules-sensors-interface/ios"
UMTaskManagerInterface:
:path: !ruby/object:Pathname
path: "../node_modules/unimodules-task-manager-interface/ios"
yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"

SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
DoubleConversion: bb338842f62ab1d708ceb63ec3d999f0f3d98ecd
EXAppLoaderProvider: 5d348813a9cf09b03bbe5b8b55437bc1bfbddbd1
EXConstants: 857aa7b1c84e2878f8402d712061860bca16a697
EXFileSystem: 7e53a2c30a2eb6987ba6d5158ab908f947523228
EXPermissions: df10ad83df2f6b647aec304619354f8ab48d5f63
Folly: de497beb10f102453a1afa9edbf8cf8a251890de
glog: aefd1eb5dda2ab95ba0938556f34b98e2da3a60d
React: 36d0768f9e93be2473b37e7fa64f92c1d5341eef
Expand All @@ -217,8 +310,20 @@ SPEC CHECKSUMS:
RNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4
Sentry: 14bdd673870e8cf64932b149fad5bbbf39a9b390
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
UMBarCodeScannerInterface: d5a6fdc98ed6241225b0a8432a7f4e2b397668bc
UMCameraInterface: 68870a3197fee85bd5afca5609ba4a5b7257d19d
UMConstantsInterface: d25b8e8887ca7aaf568c06caf08f4d40734ee4ef
UMCore: 402cee150324974974f5c32b5404d8af65e4cff5
UMFaceDetectorInterface: 7b4f1a92f0c726b58b086296048efe193b570678
UMFileSystemInterface: aadb9a67aa6470d7ebc06cf04dc54fee6781ac48
UMFontInterface: 2d3c128285086bbed3d2a650f1d698323ef3b25a
UMImageLoaderInterface: 2829a7571a12d2e754c73c55ffe7e327d8402c7d
UMPermissionsInterface: b6a6e96db0f4011a25aaca14e6022529dd3d6e4e
UMReactNativeAdapter: 93c2f520a1cdb6ef3058a7b6a95275a804e0923b
UMSensorsInterface: cf59dd7602764a2419e00167429be3e4be39c61d
UMTaskManagerInterface: 1e70fe58b872355f0ecb44fb81bb1a16484047f0
yoga: 684513b14b03201579ba3cee20218c9d1298b0cc

PODFILE CHECKSUM: 882347e8d497f7575a47b2d21471f49b106eed82
PODFILE CHECKSUM: 762c4b235bcb63c57985514d4c13253fe5e51782

COCOAPODS: 1.8.4
2 changes: 2 additions & 0 deletions ios/ZulipMobile/AppDelegate.h
Expand Up @@ -9,9 +9,11 @@

#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>

@property (nonatomic, strong) UMModuleRegistryAdapter *moduleRegistryAdapter;
@property (nonatomic, strong) UIWindow *window;

@end
12 changes: 12 additions & 0 deletions ios/ZulipMobile/AppDelegate.m
Expand Up @@ -17,12 +17,16 @@
#import <React/RCTLog.h>
#import <RNNotifications.h>
#import <React/RCTPushNotificationManager.h>
#import <UMCore/UMModuleRegistry.h>
#import <UMReactNativeAdapter/UMNativeModulesProxy.h>
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RCTSetLogThreshold(RCTLogLevelError);
self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]];

RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
Expand All @@ -39,6 +43,14 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}

- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge];
// You can inject any extra modules that you would like here, more information at:
// https://facebook.github.io/react-native/docs/native-modules-ios.html#dependency-injection
return extraModules;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
// The template upstream has some `#if DEBUG` goo around this, to
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -61,6 +61,7 @@
"react-native-simple-toast": "^1.0.0",
"react-native-sound": "^0.10.9",
"react-native-text-input-reset": "^1.0.2",
"react-native-unimodules": "0.6.0",
"react-native-vector-icons": "^6.6.0",
"react-native-webview": "^5.0.0",
"react-navigation": "^2.18.3",
Expand Down

0 comments on commit cb87f90

Please sign in to comment.