From 2db2061c7e4e48b0684ce71b3eb98b55136cf091 Mon Sep 17 00:00:00 2001 From: Anne van de Venis Date: Tue, 12 Apr 2022 09:01:57 +0200 Subject: [PATCH] deps: update template from react-native --- template/Gemfile.lock | 100 ------------------ template/_flowconfig | 66 ++++++++++++ template/_gitignore | 8 +- template/android/app/build.gradle | 21 +++- .../java/com/helloworld/MainActivity.java | 3 +- .../MainApplicationReactNativeHost.java | 4 +- template/android/app/src/main/jni/Android.mk | 5 +- template/android/build.gradle | 12 ++- template/android/settings.gradle | 2 + .../ios/HelloWorld.xcodeproj/project.pbxproj | 12 ++- template/ios/Podfile | 2 +- template/ios/_xcode.env | 11 ++ template/package.json | 27 +---- 13 files changed, 128 insertions(+), 145 deletions(-) delete mode 100644 template/Gemfile.lock create mode 100644 template/_flowconfig create mode 100644 template/ios/_xcode.env diff --git a/template/Gemfile.lock b/template/Gemfile.lock deleted file mode 100644 index 089d06d0..00000000 --- a/template/Gemfile.lock +++ /dev/null @@ -1,100 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - CFPropertyList (3.0.5) - rexml - activesupport (6.1.5) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) - algoliasearch (1.27.5) - httpclient (~> 2.8, >= 2.8.3) - json (>= 1.5.1) - atomos (0.1.3) - claide (1.1.0) - cocoapods (1.11.3) - addressable (~> 2.8) - claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.11.3) - cocoapods-deintegrate (>= 1.0.3, < 2.0) - cocoapods-downloader (>= 1.4.0, < 2.0) - cocoapods-plugins (>= 1.0.0, < 2.0) - cocoapods-search (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.4.0, < 2.0) - cocoapods-try (>= 1.1.0, < 2.0) - colored2 (~> 3.1) - escape (~> 0.0.4) - fourflusher (>= 2.3.0, < 3.0) - gh_inspector (~> 1.0) - molinillo (~> 0.8.0) - nap (~> 1.0) - ruby-macho (>= 1.0, < 3.0) - xcodeproj (>= 1.21.0, < 2.0) - cocoapods-core (1.11.3) - activesupport (>= 5.0, < 7) - addressable (~> 2.8) - algoliasearch (~> 1.0) - concurrent-ruby (~> 1.1) - fuzzy_match (~> 2.0.4) - nap (~> 1.0) - netrc (~> 0.11) - public_suffix (~> 4.0) - typhoeus (~> 1.0) - cocoapods-deintegrate (1.0.5) - cocoapods-downloader (1.6.2) - cocoapods-plugins (1.0.0) - nap - cocoapods-search (1.0.1) - cocoapods-trunk (1.6.0) - nap (>= 0.8, < 2.0) - netrc (~> 0.11) - cocoapods-try (1.2.0) - colored2 (3.1.2) - concurrent-ruby (1.1.10) - escape (0.0.4) - ethon (0.15.0) - ffi (>= 1.15.0) - ffi (1.15.5) - fourflusher (2.3.1) - fuzzy_match (2.0.4) - gh_inspector (1.1.3) - httpclient (2.8.3) - i18n (1.10.0) - concurrent-ruby (~> 1.0) - json (2.6.1) - minitest (5.15.0) - molinillo (0.8.0) - nanaimo (0.3.0) - nap (1.1.0) - netrc (0.11.0) - public_suffix (4.0.6) - rexml (3.2.5) - ruby-macho (2.5.1) - typhoeus (1.4.0) - ethon (>= 0.9.0) - tzinfo (2.0.4) - concurrent-ruby (~> 1.0) - xcodeproj (1.21.0) - CFPropertyList (>= 2.3.3, < 4.0) - atomos (~> 0.1.3) - claide (>= 1.0.2, < 2.0) - colored2 (~> 3.1) - nanaimo (~> 0.3.0) - rexml (~> 3.2.4) - zeitwerk (2.5.4) - -PLATFORMS - ruby - -DEPENDENCIES - cocoapods (~> 1.11, >= 1.11.2) - -RUBY VERSION - ruby 2.7.4p191 - -BUNDLED WITH - 2.2.27 diff --git a/template/_flowconfig b/template/_flowconfig new file mode 100644 index 00000000..5c531aaa --- /dev/null +++ b/template/_flowconfig @@ -0,0 +1,66 @@ +[ignore] +; We fork some components by platform +.*/*[.]android.js + +; Ignore "BUCK" generated dirs +/\.buckd/ + +; Ignore polyfills +node_modules/react-native/Libraries/polyfills/.* + +; Flow doesn't support platforms +.*/Libraries/Utilities/LoadingView.js + +.*/node_modules/resolve/test/resolver/malformed_package_json/package\.json$ + +[untyped] +.*/node_modules/@react-native-community/cli/.*/.* + +[include] + +[libs] +node_modules/react-native/interface.js +node_modules/react-native/flow/ + +[options] +emoji=true + +exact_by_default=true + +format.bracket_spacing=false + +module.file_ext=.js +module.file_ext=.json +module.file_ext=.ios.js + +munge_underscores=true + +module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' +module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' + +suppress_type=$FlowIssue +suppress_type=$FlowFixMe +suppress_type=$FlowFixMeProps +suppress_type=$FlowFixMeState + +[lints] +sketchy-null-number=warn +sketchy-null-mixed=warn +sketchy-number=warn +untyped-type-import=warn +nonstrict-import=warn +deprecated-type=warn +unsafe-getters-setters=warn +unnecessary-invariant=warn + +[strict] +deprecated-type +nonstrict-import +sketchy-null +unclear-type +unsafe-getters-setters +untyped-import +untyped-type-import + +[version] +^0.175.1 diff --git a/template/_gitignore b/template/_gitignore index 81570d99..344481b2 100644 --- a/template/_gitignore +++ b/template/_gitignore @@ -20,6 +20,7 @@ DerivedData *.hmap *.ipa *.xcuserstate +ios/.xcode.env.local # Android/IntelliJ # @@ -49,9 +50,10 @@ buck-out/ # For more information about the recommended setup visit: # https://docs.fastlane.tools/best-practices/source-control/ -*/fastlane/report.xml -*/fastlane/Preview.html -*/fastlane/screenshots +**/fastlane/report.xml +**/fastlane/Preview.html +**/fastlane/screenshots +**/fastlane/test_output # Bundle artifact *.jsbundle diff --git a/template/android/app/build.gradle b/template/android/app/build.gradle index a173c56b..3081a1f2 100644 --- a/template/android/app/build.gradle +++ b/template/android/app/build.gradle @@ -151,7 +151,8 @@ android { "GENERATED_SRC_DIR=$buildDir/generated/source", "PROJECT_BUILD_DIR=$buildDir", "REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid", - "REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build" + "REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build", + "NODE_MODULES_DIR=$rootDir/../node_modules" cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1" cppFlags "-std=c++17" // Make sure this target name is the same you specify inside the @@ -159,6 +160,11 @@ android { targets "helloworld_appmodules" } } + if (!enableSeparateBuildPerCPUArchitecture) { + ndk { + abiFilters (*reactNativeArchitectures()) + } + } } } @@ -271,9 +277,10 @@ dependencies { } if (enableHermes) { - def hermesPath = "../../node_modules/hermes-engine/android/"; - debugImplementation files(hermesPath + "hermes-debug.aar") - releaseImplementation files(hermesPath + "hermes-release.aar") + //noinspection GradleDynamicVersion + implementation("com.facebook.react:hermes-engine:+") { // From node_modules + exclude group:'com.facebook.fbjni' + } } else { implementation jscFlavor } @@ -286,7 +293,11 @@ if (isNewArchitectureEnabled()) { configurations.all { resolutionStrategy.dependencySubstitution { substitute(module("com.facebook.react:react-native")) - .using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source") + .using(project(":ReactAndroid")) + .because("On New Architecture we're building React Native from source") + substitute(module("com.facebook.react:hermes-engine")) + .using(project(":ReactAndroid:hermes-engine")) + .because("On New Architecture we're building Hermes from source") } } } 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 24f41285..eae5dada 100644 --- a/template/android/app/src/main/java/com/helloworld/MainActivity.java +++ b/template/android/app/src/main/java/com/helloworld/MainActivity.java @@ -17,7 +17,8 @@ protected String getMainComponentName() { /** * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and - * you can specify the rendered you wish to use (Fabric or the older renderer). + * you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer + * (Paper). */ @Override protected ReactActivityDelegate createReactActivityDelegate() { diff --git a/template/android/app/src/main/java/com/helloworld/newarchitecture/MainApplicationReactNativeHost.java b/template/android/app/src/main/java/com/helloworld/newarchitecture/MainApplicationReactNativeHost.java index f555e364..55473c3f 100644 --- a/template/android/app/src/main/java/com/helloworld/newarchitecture/MainApplicationReactNativeHost.java +++ b/template/android/app/src/main/java/com/helloworld/newarchitecture/MainApplicationReactNativeHost.java @@ -16,8 +16,8 @@ import com.facebook.react.bridge.UIManager; import com.facebook.react.fabric.ComponentFactory; import com.facebook.react.fabric.CoreComponentsRegistry; -import com.facebook.react.fabric.EmptyReactNativeConfig; import com.facebook.react.fabric.FabricJSIModuleProvider; +import com.facebook.react.fabric.ReactNativeConfig; import com.facebook.react.uimanager.ViewManagerRegistry; import com.helloworld.BuildConfig; import com.helloworld.newarchitecture.components.MainComponentsRegistry; @@ -105,7 +105,7 @@ public JSIModuleProvider getJSIModuleProvider() { return new FabricJSIModuleProvider( reactApplicationContext, componentFactory, - new EmptyReactNativeConfig(), + ReactNativeConfig.DEFAULT_CONFIG, viewManagerRegistry); } }); diff --git a/template/android/app/src/main/jni/Android.mk b/template/android/app/src/main/jni/Android.mk index 0ae63667..cda13912 100644 --- a/template/android/app/src/main/jni/Android.mk +++ b/template/android/app/src/main/jni/Android.mk @@ -17,7 +17,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) # If you wish to add a custom TurboModule or Fabric component in your app you -# will have to uncomment those lines to include the generated source +# will have to uncomment those lines to include the generated source # files from the codegen (placed in $(GENERATED_SRC_DIR)/codegen/jni) # # LOCAL_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni @@ -28,8 +28,7 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_SHARED_LIBRARIES := \ libfabricjni \ libfbjni \ - libfolly_futures \ - libfolly_json \ + libfolly_runtime \ libglog \ libjsi \ libreact_codegen_rncore \ diff --git a/template/android/build.gradle b/template/android/build.gradle index 8a1d68f9..c6fa898b 100644 --- a/template/android/build.gradle +++ b/template/android/build.gradle @@ -6,16 +6,22 @@ buildscript { minSdkVersion = 21 compileSdkVersion = 31 targetSdkVersion = 31 - ndkVersion = "21.4.7075529" + // For M1 Users we need to use the NDK 24, otherwise we default to the + // side-by-side NDK version from AGP. + if (System.properties['os.arch'] == "aarch64") { + ndkVersion = "24.0.8215888" + } else { + ndkVersion = "21.4.7075529" + } } repositories { google() mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:7.0.4") + classpath("com.android.tools.build:gradle:7.1.1") classpath("com.facebook.react:react-native-gradle-plugin") - classpath("de.undercouch:gradle-download-task:4.1.2") + classpath("de.undercouch:gradle-download-task:5.0.1") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/template/android/settings.gradle b/template/android/settings.gradle index 2f93b711..bd838b9c 100644 --- a/template/android/settings.gradle +++ b/template/android/settings.gradle @@ -6,4 +6,6 @@ includeBuild('../node_modules/react-native-gradle-plugin') if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") { include(":ReactAndroid") project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid') + include(":ReactAndroid:hermes-engine") + project(":ReactAndroid:hermes-engine").projectDir = file('../node_modules/react-native/ReactAndroid/hermes-engine') } diff --git a/template/ios/HelloWorld.xcodeproj/project.pbxproj b/template/ios/HelloWorld.xcodeproj/project.pbxproj index 7dfdffdd..70234ff0 100644 --- a/template/ios/HelloWorld.xcodeproj/project.pbxproj +++ b/template/ios/HelloWorld.xcodeproj/project.pbxproj @@ -256,13 +256,15 @@ files = ( ); inputPaths = ( + "$(SRCROOT)/.xcode.env.local", + "$(SRCROOT)/.xcode.env", ); name = "Bundle React Native code and images"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "set -e\n\nexport NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n"; + shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n"; }; 00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; @@ -436,7 +438,7 @@ "$(inherited)", ); INFOPLIST_FILE = HelloWorldTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -460,7 +462,7 @@ BUNDLE_LOADER = "$(TEST_HOST)"; COPY_PHASE_STRIP = NO; INFOPLIST_FILE = HelloWorldTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -576,7 +578,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", @@ -640,7 +642,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", diff --git a/template/ios/Podfile b/template/ios/Podfile index 01506faf..06a02f93 100644 --- a/template/ios/Podfile +++ b/template/ios/Podfile @@ -1,7 +1,7 @@ require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' -platform :ios, '11.0' +platform :ios, '12.4' install! 'cocoapods', :deterministic_uuids => false target 'HelloWorld' do diff --git a/template/ios/_xcode.env b/template/ios/_xcode.env new file mode 100644 index 00000000..3d5782c7 --- /dev/null +++ b/template/ios/_xcode.env @@ -0,0 +1,11 @@ +# This `.xcode.env` file is versioned and is used to source the environment +# used when running script phases inside Xcode. +# To customize your local environment, you can create an `.xcode.env.local` +# file that is not versioned. + +# NODE_BINARY variable contains the PATH to the node executable. +# +# Customize the NODE_BINARY variable here. +# For example, to use nvm with brew, add the following line +# . "$(brew --prefix nvm)/nvm.sh" --no-use +export NODE_BINARY=$(command -v node) diff --git a/template/package.json b/template/package.json index f49e30c2..a88113de 100644 --- a/template/package.json +++ b/template/package.json @@ -7,40 +7,23 @@ "ios": "react-native run-ios", "start": "react-native start", "test": "jest", - "lint": "eslint . --ext .js,.jsx,.ts,.tsx" + "lint": "eslint ." }, "dependencies": { "react": "17.0.2", - "react-native": "0.68.0" + "react-native": "1000.0.0" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "@react-native-community/eslint-config": "^2.0.0", - "@types/jest": "^26.0.23", - "@types/react-native": "^0.67.3", - "@types/react-test-renderer": "^17.0.1", - "@typescript-eslint/eslint-plugin": "^5.17.0", - "@typescript-eslint/parser": "^5.17.0", "babel-jest": "^26.6.3", "eslint": "^7.32.0", "jest": "^26.6.3", - "metro-react-native-babel-preset": "^0.67.0", - "react-test-renderer": "17.0.2", - "typescript": "^4.4.4" - }, - "resolutions": { - "@types/react": "^17" + "metro-react-native-babel-preset": "^0.70.1", + "react-test-renderer": "17.0.2" }, "jest": { - "preset": "react-native", - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "jsx", - "json", - "node" - ] + "preset": "react-native" } }