当 npx react-native 启动时 -- --reset-cache
警告包react-native-sqlite-storage包含无效配置:不允许使用“dependency.platforms.ios.project”。请使用“react-native config”命令验证其是否正确链接,并就此联系软件包维护人员。
我的配置:
"react-native-sqlite-storage": "^3.3.3", // 目前最新的
react-native.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,
}
],
}
}
}
}
错误:
首先,确保
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-为您的项目设置补丁包
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'
},
到
ios: {},
5-patch-package 制作
react-native-sqlite-storage+6.0.1.patch
并将其添加到 {$root}/patches
6-构建您的项目!
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,
}
],
}
}
}
}
这段代码对我有用,没有警告 也许也适合你
module.exports = {
dependency: {
platforms: {
ios: {
// project: './platforms/ios/SQLite.xcodeproj'
},
android: {
sourceDir: './platforms/android',
// packageImportPath: "import io.liteglue.SQLitePluginPackage;",
// packageInstance: "new SQLitePluginPackage()"
},
windows: {
sourceDir: './platforms/windows',
solutionFile: 'SQLitePlugin.sln',
projects: [
{
projectFile: 'SQLitePlugin/SQLitePlugin.vcxproj',
directDependency: true,
}
],
}
}
}
}