仅适用于一个平台(android或ios)的本机负载依赖性

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

我正在一个项目中,需要为iOS上的功能添加特定的依赖关系,我想避免将此库包含在android捆绑包中。可能吗?更改android或ios项目的名称并运行'react-native link';)

库为react-native-text-detector

react-native dependency-management
1个回答
0
投票

我不确定这是否能回答您的问题,但您可以执行类似的操作

let textDetector;

if(Platform.OS === "ios"){
    textDetector = require("react-native-text-detector");
}

然后使用它时,请确保检查它是否未定义

© www.soinside.com 2019 - 2024. All rights reserved.