【问题标题】:How to disable autolinking on iOS?如何在 iOS 上禁用自动链接?
【发布时间】:2019-07-12 08:11:38
【问题描述】:

我在我的 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'?

【问题讨论】:

  • 您是否也尝试过cd iospod install
  • 非常感谢。我在哪里可以找到有关它的信息?昨天,我花了大约 3 小时来让它工作......

标签: react-native react-native-ios


【解决方案1】:

现在,react-native 在他的项目中添加了对 CocoaPods 的支持。 (https://github.com/facebook/react-native/releases)

可悲的是,我不知道为什么,但自动链接功能在 iOS 上对我不起作用,但在 Android 上总是会出现低谷。我找到的唯一解决方案是只为 iOS 做一个 react-native 链接(将 android 文件夹重命名为别的东西),然后做 cd iospod install。之后,在大多数情况下,它可以开箱即用,而其他库仍需要更新才能与 RN 0.60 完全集成。

希望这一切都将很快得到解决,但在那之前我们只需要等待并希望这些库能够正常工作而不会出现任何其他并发症

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-22
    • 2018-08-27
    • 2022-01-26
    • 1970-01-01
    • 2013-04-12
    • 1970-01-01
    • 2019-04-07
    • 1970-01-01
    相关资源
    最近更新 更多