diff --git a/template/App.tsx b/template/App.tsx index b7adefe3..565db625 100755 --- a/template/App.tsx +++ b/template/App.tsx @@ -8,7 +8,7 @@ * @format */ -import React, {Fragment} from 'react'; +import React from 'react'; import { SafeAreaView, StyleSheet, @@ -28,7 +28,7 @@ import { const App = () => { return ( - + <> { - + ); }; diff --git a/template/_gitignore b/template/_gitignore index 4f5f4db4..aadce1a1 100755 --- a/template/_gitignore +++ b/template/_gitignore @@ -44,6 +44,7 @@ yarn-error.log buck-out/ \.buckd/ *.keystore +!debug.keystore # fastlane # diff --git a/template/android/app/build.gradle b/template/android/app/build.gradle index 7898e7bd..fd68f794 100755 --- a/template/android/app/build.gradle +++ b/template/android/app/build.gradle @@ -176,15 +176,6 @@ android { } } - - packagingOptions { - pickFirst '**/armeabi-v7a/libc++_shared.so' - pickFirst '**/x86/libc++_shared.so' - pickFirst '**/arm64-v8a/libc++_shared.so' - pickFirst '**/x86_64/libc++_shared.so' - pickFirst '**/x86/libjsc.so' - pickFirst '**/armeabi-v7a/libjsc.so' - } } dependencies { @@ -192,11 +183,11 @@ dependencies { implementation "com.facebook.react:react-native:+" // From node_modules if (enableHermes) { - def hermesPath = "../../node_modules/hermesvm/android/"; - debugImplementation files(hermesPath + "hermes-debug.aar") - releaseImplementation files(hermesPath + "hermes-release.aar") + def hermesPath = "../../node_modules/hermes-engine/android/"; + debugImplementation files(hermesPath + "hermes-debug.aar") + releaseImplementation files(hermesPath + "hermes-release.aar") } else { - implementation jscFlavor + implementation jscFlavor } } diff --git a/template/android/app/src/main/java/com/helloworld/MainActivity.java b/template/android/app/src/main/java/com/helloworld/MainActivity.java index 1e9c1894..c7106d57 100755 --- a/template/android/app/src/main/java/com/helloworld/MainActivity.java +++ b/template/android/app/src/main/java/com/helloworld/MainActivity.java @@ -4,12 +4,12 @@ public class MainActivity extends ReactActivity { - /** - * Returns the name of the main component registered from JavaScript. - * This is used to schedule rendering of the component. - */ - @Override - protected String getMainComponentName() { - return "HelloWorld"; - } + /** + * Returns the name of the main component registered from JavaScript. This is used to schedule + * rendering of the component. + */ + @Override + protected String getMainComponentName() { + return "HelloWorld"; + } } diff --git a/template/android/app/src/main/java/com/helloworld/MainApplication.java b/template/android/app/src/main/java/com/helloworld/MainApplication.java index 896a6304..ae1ff7cf 100755 --- a/template/android/app/src/main/java/com/helloworld/MainApplication.java +++ b/template/android/app/src/main/java/com/helloworld/MainApplication.java @@ -1,40 +1,38 @@ package com.helloworld; import android.app.Application; -import android.util.Log; - +import android.content.Context; import com.facebook.react.PackageList; -import com.facebook.hermes.reactexecutor.HermesExecutorFactory; -import com.facebook.react.bridge.JavaScriptExecutorFactory; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; - +import java.lang.reflect.InvocationTargetException; import java.util.List; public class MainApplication extends Application implements ReactApplication { - private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { - @Override - public boolean getUseDeveloperSupport() { - return BuildConfig.DEBUG; - } + private final ReactNativeHost mReactNativeHost = + new ReactNativeHost(this) { + @Override + public boolean getUseDeveloperSupport() { + return BuildConfig.DEBUG; + } - @Override - protected List getPackages() { - @SuppressWarnings("UnnecessaryLocalVariable") - List packages = new PackageList(this).getPackages(); - // Packages that cannot be autolinked yet can be added manually here, for example: - // packages.add(new MyReactNativePackage()); - return packages; - } + @Override + protected List getPackages() { + @SuppressWarnings("UnnecessaryLocalVariable") + List packages = new PackageList(this).getPackages(); + // Packages that cannot be autolinked yet can be added manually here, for example: + // packages.add(new MyReactNativePackage()); + return packages; + } - @Override - protected String getJSMainModuleName() { - return "index"; - } - }; + @Override + protected String getJSMainModuleName() { + return "index"; + } + }; @Override public ReactNativeHost getReactNativeHost() { @@ -45,5 +43,32 @@ public ReactNativeHost getReactNativeHost() { public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); + initializeFlipper(this); // Remove this line if you don't want Flipper enabled + } + + /** + * Loads Flipper in React Native templates. + * + * @param context + */ + private static void initializeFlipper(Context context) { + if (BuildConfig.DEBUG) { + try { + /* + We use reflection here to pick up the class that initializes Flipper, + since Flipper library is not available in release mode + */ + Class aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper"); + aClass.getMethod("initializeFlipper", Context.class).invoke(null, context); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } } } diff --git a/template/android/build.gradle b/template/android/build.gradle index e7732fe0..28f7ec64 100755 --- a/template/android/build.gradle +++ b/template/android/build.gradle @@ -6,14 +6,13 @@ buildscript { minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 - supportLibVersion = "28.0.0" } repositories { google() jcenter() } dependencies { - classpath("com.android.tools.build:gradle:3.4.1") + classpath("com.android.tools.build:gradle:3.4.2") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -34,5 +33,6 @@ allprojects { google() jcenter() + maven { url 'https://jitpack.io' } } } diff --git a/template/android/gradle/wrapper/gradle-wrapper.properties b/template/android/gradle/wrapper/gradle-wrapper.properties index ee69dd68..e0c4de36 100755 --- a/template/android/gradle/wrapper/gradle-wrapper.properties +++ b/template/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/template/ios/HelloWorldTests/HelloWorldTests.m b/template/ios/HelloWorldTests/HelloWorldTests.m index e9db2f11..1b3a4fd2 100755 --- a/template/ios/HelloWorldTests/HelloWorldTests.m +++ b/template/ios/HelloWorldTests/HelloWorldTests.m @@ -12,7 +12,7 @@ #import #define TIMEOUT_SECONDS 600 -#define TEXT_TO_LOOK_FOR @"Welcome to React Native!" +#define TEXT_TO_LOOK_FOR @"Welcome to React" @interface HelloWorldTests : XCTestCase @@ -40,11 +40,13 @@ - (void)testRendersWelcomeScreen BOOL foundElement = NO; __block NSString *redboxError = nil; +#ifdef DEBUG RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { if (level >= RCTLogLevelError) { redboxError = message; } }); +#endif while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; @@ -57,8 +59,10 @@ - (void)testRendersWelcomeScreen return NO; }]; } - + +#ifdef DEBUG RCTSetLogFunction(RCTDefaultLogFunction); +#endif XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); diff --git a/template/ios/Podfile b/template/ios/Podfile index 0fa914ae..7706b836 100755 --- a/template/ios/Podfile +++ b/template/ios/Podfile @@ -3,9 +3,14 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ target 'HelloWorld' do # Pods for HelloWorld + pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector" + pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec" + pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired" + pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety" pod 'React', :path => '../node_modules/react-native/' - pod 'React-Core', :path => '../node_modules/react-native/React' - pod 'React-DevSupport', :path => '../node_modules/react-native/React' + pod 'React-Core', :path => '../node_modules/react-native/' + pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules' + pod 'React-Core/DevSupport', :path => '../node_modules/react-native/' pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS' pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation' pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob' @@ -15,13 +20,15 @@ target 'HelloWorld' do pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings' pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text' pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration' - pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket' + pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/' pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact' pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi' pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor' pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector' - pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga' + pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon" + pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon" + pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga' pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' diff --git a/template/package.json b/template/package.json index 63125d0a..fcb49b54 100755 --- a/template/package.json +++ b/template/package.json @@ -3,25 +3,27 @@ "version": "0.0.1", "private": true, "scripts": { + "android": "react-native run-android", + "ios": "react-native run-ios", "start": "react-native start", "test": "jest" }, "dependencies": { - "react": "16.8.6", - "react-native": "0.60.5" + "react": "16.8.1", + "react-native": "0.61.1" }, "devDependencies": { "@babel/core": "^7.5.0", "@babel/runtime": "^7.5.0", "@react-native-community/eslint-config": "^0.0.3", "@types/jest": "^24.0.18", - "@types/react": "^16.9.2", - "@types/react-native": "^0.60.14", - "@types/react-test-renderer": "^16.9.0", + "@types/react": "16.8.19", + "@types/react-native": "0.60.15", + "@types/react-test-renderer": "16.8.1", "babel-jest": "^24.1.0", "jest": "^24.1.0", - "metro-react-native-babel-preset": "0.54.1", - "react-test-renderer": "16.8.6", + "metro-react-native-babel-preset": "^0.51.1", + "react-test-renderer": "16.8.1", "typescript": "^3.6.3" }, "jest": {