warn 包 **react-native-sqlite-storage** 包含无效配置:不允许“**dependency.platforms.ios.project**”

Abb*_*ani 5 reactjs react-native react-native-sqlite-storage

当npx react-native启动时 -- --reset-cache

warn 包react-native-sqlite-storage包含无效配置:不允许“ dependency.platforms.ios.project ”。请使用“ react-native config ”命令验证其是否正确链接,并就此联系软件包维护人员。

我的配置:

"react-native-sqlite-storage": "^3.3.3", // 目前最新的

反应本机.config.js:

    module.exports = {
    dependency: {
        platforms: {
            ios: {
                project: './platforms/ios/SQLite.xcodeproj'
            },
            android: {
                sourceDir: './platforms/android'
            },
            windows: {
                sourceDir: './platforms/windows',
                solutionFile: 'SQLitePlugin.sln',
                projects: [
                  {
                    projectFile: 'SQLitePlugin/SQLitePlugin.vcxproj',
                    directDependency: true,
                  }
                ],
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

错误:

react-native-sqlite-storage 包含无效配置:不允许“dependency.platforms.ios.project”

Abo*_*zlR 6

首先,确保文件中有以下配置react-native.config.js

module.exports = {
  ...,
  dependencies: {
    ...,
    "react-native-sqlite-storage": {
      platforms: {
        android: {
          sourceDir:
            "../node_modules/react-native-sqlite-storage/platforms/android-native",
          packageImportPath: "import io.liteglue.SQLitePluginPackage;",
          packageInstance: "new SQLitePluginPackage()"
        }
      }
    }
    ...
  }
  ...
};
Run Code Online (Sandbox Code Playgroud)

笔记

如果您的项目根目录中没有该react-native.config.js文件,请随意创建它并将上面的配置放入其中。

然后,执行以下步骤

1 -为您的项目设置补丁包

2 -npx patch-package react-native-sqlite-storage在终端运行

3 - 打开node_modules/react-native-sqlite-storage/react-native.config.js

4 -编辑如下

ios: {
    project: './platforms/ios/SQLite.xcodeproj'
},
Run Code Online (Sandbox Code Playgroud)

ios: {},
Run Code Online (Sandbox Code Playgroud)

5 -patch-package 制作react-native-sqlite-storage+6.0.1.patch并添加到{$root}/patches

6 -构建您的项目!

感谢Mitsuharu Emoto分享代码


Abb*_*ani 3

react-native.config.js: 推荐或删除部分ios

  module.exports = {
dependency: {
    platforms: {

      // ios: {
       //     project: './platforms/ios/SQLite.xcodeproj'
       // },
        android: {
            sourceDir: './platforms/android'
        },
        windows: {
            sourceDir: './platforms/windows',
            solutionFile: 'SQLitePlugin.sln',
            projects: [
              {
                projectFile: 'SQLitePlugin/SQLitePlugin.vcxproj',
                directDependency: true,
              }
            ],
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

}