当使用自动链接时,只忽略android的react原生库。

问题描述 投票:0回答:1

在0.62.2中,React原生的自动链接增加了所有的反应原生项目。node_modules ios和android都可以使用,通过。

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

但有一个项目我只想在iphone应用中使用 但我不清楚如何告诉build.gradle将这个依赖关系从android中排除出去。即使react native autolinker不直接支持,也应该有办法在build.gradle中程序化地迭代给定变体的 "实现 "依赖,并删除一个?

android gradle react-native-android autolink
1个回答
0
投票

解决方法是添加一个 react-native.config.js 在你的RN项目的顶层,你可以用内容来禁用android上依赖foo的自动链接。

module.exports = {
  dependencies: {
    "foo": {
      platforms: {
        android: null // disable Android platform, other platforms will still autolink if provided
      }
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.