警告包**react-native-sqlite-storage**包含无效配置:不允许使用“**依赖项.平台.ios.项目**”

m1m5dgzv  于 2022-12-04  发布在  React
关注(0)|答案(2)|浏览(320)

当npxReact Native启动时-- --重置缓存
警告程序包react-native-sqlite-storage包含无效配置:不允许使用“dependency.platforms.ios.project”。请使用“react-native config”命令验证它是否已正确链接,并就此与软件包维护人员联系。

我的配置:

“React-本机-sqlite-存储”:“^3.3.3”,//截至目前最新

React式原生配置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,
                  }
                ],
            }
        }
    }
}

错误:

react-native-sqlite-storage contains invalid configuration: "dependency.platforms.ios.project" is not allowed

aiqt4smr

aiqt4smr1#

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,
              }
            ],
        }
    }
}

}

du7egjpx

du7egjpx2#

首先,确保在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()"
        }
      }
    }
    ...
  }
  ...
};

如果项目的根目录中没有react-native.config.js文件,请随意创建该文件并将上面的配置放在其中。
然后,执行下列步骤
1-为项目设置patch-package
2-打开node_modules/react-native-sqlite-storage/react-native.config.js
3-编辑如下

ios: {
    project: './platforms/ios/SQLite.xcodeproj'
},

ios: {},

4-在终端运行npx patch-package react-native-sqlite-storage
5-修补程序包生成react-native-sqlite-storage+6.0.1.patch并将其添加到{$root}/patches
6-构建您的项目!

感谢Mitsuharu Emotosharing the code

相关问题