如何禁用 iOS 上的自动链接?
How to disable autolinking on iOS?
我在我的 React Native 项目 (v0.6) 中安装了 react-native-localization。库还不支持自动链接器,所以我需要在 react-native.config.js.
中为 iOS 和 Android 禁用它
我已经尝试在 react-native.config.js 中添加依赖项。之后,我执行了 react-native link react-native-localization
命令并构建了一个应用程序。
这是我的 react-native.config.js 文件:
'use strict';
const ios = require('@react-native-community/cli-platform-ios');
const android = require('@react-native-community/cli-platform-android');
module.exports = {
dependencies: {
'react-native-localization': {
platforms: {
android: null, // disable Android platform, other platforms will still autolink if provided
ios: null,
},
},
},
commands: [...ios.commands, ...android.commands],
platforms: {
ios: {
linkConfig: ios.linkConfig,
projectConfig: ios.projectConfig,
dependencyConfig: ios.dependencyConfig,
},
android: {
linkConfig: android.linkConfig,
projectConfig: android.projectConfig,
dependencyConfig: android.dependencyConfig,
},
},
/**
* Used when running RNTester (with React Native from source)
*/
reactNativePath: '.',
project: {
ios: {
project: './RNTester/RNTester.xcodeproj',
},
android: {
sourceDir: './RNTester',
},
},
};
模拟器错误说:
"请检查您的配置。您 运行 'react-native link'?
像现在一样,react-native 已经在他的项目中添加了对 CocoaPods 的支持。 (https://github.com/facebook/react-native/releases)
遗憾的是,我不知道为什么,但是自动 linking 功能在 iOS 上对我来说从来没有用过,但在 Android 上总是很糟糕。我找到的唯一解决方案是仅对 iOS 执行 react-native link(将 android 文件夹重命名为其他名称),然后执行 cd ios
和 pod install
。在那之后,在大多数情况下,它会开箱即用,而其他库仍需要更新才能与 RN 0.60 完全集成。
希望所有这些问题都能尽快得到解决,但在那之前我们只需要等待并希望这些库能够正常工作
我在我的 React Native 项目 (v0.6) 中安装了 react-native-localization。库还不支持自动链接器,所以我需要在 react-native.config.js.
中为 iOS 和 Android 禁用它我已经尝试在 react-native.config.js 中添加依赖项。之后,我执行了 react-native link react-native-localization
命令并构建了一个应用程序。
这是我的 react-native.config.js 文件:
'use strict';
const ios = require('@react-native-community/cli-platform-ios');
const android = require('@react-native-community/cli-platform-android');
module.exports = {
dependencies: {
'react-native-localization': {
platforms: {
android: null, // disable Android platform, other platforms will still autolink if provided
ios: null,
},
},
},
commands: [...ios.commands, ...android.commands],
platforms: {
ios: {
linkConfig: ios.linkConfig,
projectConfig: ios.projectConfig,
dependencyConfig: ios.dependencyConfig,
},
android: {
linkConfig: android.linkConfig,
projectConfig: android.projectConfig,
dependencyConfig: android.dependencyConfig,
},
},
/**
* Used when running RNTester (with React Native from source)
*/
reactNativePath: '.',
project: {
ios: {
project: './RNTester/RNTester.xcodeproj',
},
android: {
sourceDir: './RNTester',
},
},
};
模拟器错误说: "请检查您的配置。您 运行 'react-native link'?
像现在一样,react-native 已经在他的项目中添加了对 CocoaPods 的支持。 (https://github.com/facebook/react-native/releases)
遗憾的是,我不知道为什么,但是自动 linking 功能在 iOS 上对我来说从来没有用过,但在 Android 上总是很糟糕。我找到的唯一解决方案是仅对 iOS 执行 react-native link(将 android 文件夹重命名为其他名称),然后执行 cd ios
和 pod install
。在那之后,在大多数情况下,它会开箱即用,而其他库仍需要更新才能与 RN 0.60 完全集成。
希望所有这些问题都能尽快得到解决,但在那之前我们只需要等待并希望这些库能够正常工作