mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
Implement changes to enable native modules auto linking (#24506)
Summary: Replaces #24099 (original PR became detached for some reason) Implements the template changes required to enable native modules auto-linking for both Android & iOS. Requires the following to be merged first and an updated CLI to be published: - [x] https://github.com/react-native-community/react-native-cli/pull/254 - [x] https://github.com/react-native-community/react-native-cli/pull/256 - [x] https://github.com/react-native-community/react-native-cli/pull/258 cc grabbou thymikee orta for review - [ ] https://github.com/facebook/react-native/pull/24517 update CLI version) [TEMPLATE] [FEATURE] - Enable auto-initialization/linking of react native modules for new projects Pull Request resolved: https://github.com/facebook/react-native/pull/24506 Differential Revision: D15062701 Pulled By: cpojer fbshipit-source-id: 65296cbec2925405fe8033de71910325e0c719bc
This commit is contained in:
committed by
Facebook Github Bot
parent
706f67a882
commit
261197d857
@@ -190,3 +190,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
|
||||
from configurations.compile
|
||||
into 'libs'
|
||||
}
|
||||
|
||||
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
|
||||
|
||||
@@ -2,13 +2,12 @@ package com.helloworld;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.facebook.react.PackageList;
|
||||
import com.facebook.react.ReactApplication;
|
||||
import com.facebook.react.ReactNativeHost;
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.shell.MainReactPackage;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MainApplication extends Application implements ReactApplication {
|
||||
@@ -21,9 +20,11 @@ public class MainApplication extends Application implements ReactApplication {
|
||||
|
||||
@Override
|
||||
protected List<ReactPackage> getPackages() {
|
||||
return Arrays.<ReactPackage>asList(
|
||||
new MainReactPackage()
|
||||
);
|
||||
@SuppressWarnings("UnnecessaryLocalVariable")
|
||||
List<ReactPackage> 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
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
rootProject.name = 'HelloWorld'
|
||||
|
||||
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
|
||||
include ':app'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
platform :ios, '9.0'
|
||||
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
|
||||
|
||||
target 'HelloWorld' do
|
||||
# Pods for HelloWorld
|
||||
@@ -31,6 +32,8 @@ target 'HelloWorld' do
|
||||
inherit! :search_paths
|
||||
# Pods for testing
|
||||
end
|
||||
|
||||
use_native_modules!
|
||||
end
|
||||
|
||||
target 'HelloWorld-tvOS' do
|
||||
|
||||
Reference in New Issue
Block a user