wcdb
wcdb copied to clipboard
关于 API call with invalid database connection pointer 错误
The language of WCDB
Objective-C
The version of WCDB
1.0.7.5
The platform of WCDB
iOS
The installation of WCDB
Cocoapods
What's the issue?
刚碰到了 "API call with invalid database connection pointer" 这个错误,数据库没创建成功,数据库文件是 0 字节。报错如下:
2020-05-25 11:20:51.267524+0800 PodProject[9381:2416284] RIMDatabaseManager.mm:131 -[RIMDatabaseManager setLoggerTypes:]_block_invoke_2 🚦[Database] SQL: PRAGMA locking_mode
2020-05-25 11:20:51.267614+0800 PodProject[9381:2416284] [logging] API call with invalid database connection pointer
2020-05-25 11:20:51.267645+0800 PodProject[9381:2416284] [logging] misuse at line 125820 of [378230ae7f]
2020-05-25 11:20:51.267805+0800 PodProject[9381:2416284] RIMDatabaseManager.mm:123 -[RIMDatabaseManager setLoggerTypes:]_block_invoke 🚦[Database] ❌ Error: Code:21, Type:SQLite, Msg:not an error, Tag:0, ExtCode:0, SQL:PRAGMA synchronous='NORMAL', Path:/var/mobile/Containers/Data/Application/CC57D5E2-07B9-4E28-93CB-9B2385517762/Library/RIM/15377fcb99d18f2fc05d0221a94142b8/IM.db, Op:4
2020-05-25 11:20:51.268478+0800 PodProject[9381:2416284] RIMDatabaseManager.mm:131 -[RIMDatabaseManager setLoggerTypes:]_block_invoke_2 🚦[Database] SQL: PRAGMA locking_mode
2020-05-25 11:20:51.268531+0800 PodProject[9381:2416284] [logging] API call with invalid database connection pointer
2020-05-25 11:20:51.269041+0800 PodProject[9381:2416284] [logging] misuse at line 125820 of [378230ae7f]
2020-05-25 11:20:51.269201+0800 PodProject[9381:2416284] RIMDatabaseManager.mm:123 -[RIMDatabaseManager setLoggerTypes:]_block_invoke 🚦[Database] ❌ Error: Code:21, Type:SQLite, Msg:not an error, Tag:0, ExtCode:0, SQL:PRAGMA synchronous='NORMAL', Path:/var/mobile/Containers/Data/Application/CC57D5E2-07B9-4E28-93CB-9B2385517762/Library/RIM/15377fcb99d18f2fc05d0221a94142b8/IM.db, Op:4
2020-05-25 11:20:51.272433+0800 PodProject[9381:2416498] RIMDatabaseManager.mm:131 -[RIMDatabaseManager setLoggerTypes:]_block_invoke_2 🚦[Database] SQL: PRAGMA locking_mode
2020-05-25 11:20:51.272506+0800 PodProject[9381:2416498] [logging] API call with invalid database connection pointer
2020-05-25 11:20:51.278517+0800 PodProject[9381:2416498] [logging] misuse at line 125820 of [378230ae7f]
2020-05-25 11:20:51.278655+0800 PodProject[9381:2416498] RIMDatabaseManager.mm:123 -[RIMDatabaseManager setLoggerTypes:]_block_invoke 🚦[Database] ❌ Error: Code:21, Type:SQLite, Msg:not an error, Tag:0, ExtCode:0, SQL:PRAGMA synchronous='NORMAL', Path:/var/mobile/Containers/Data/Application/CC57D5E2-07B9-4E28-93CB-9B2385517762/Library/RIM/15377fcb99d18f2fc05d0221a94142b8/IM.db, Op:4
2020-05-25 11:20:51.289634+0800 PodProject[9381:2416498] RIMDatabaseManager.mm:131 -[RIMDatabaseManager setLoggerTypes:]_block_invoke_2 🚦[Database] SQL: PRAGMA locking_mode
2020-05-25 11:20:51.316685+0800 PodProject[9381:2416498] [logging] API call with invalid database connection pointer
2020-05-25 11:20:51.316762+0800 PodProject[9381:2416498] [logging] misuse at line 125820 of [378230ae7f]
2020-05-25 11:20:51.316946+0800 PodProject[9381:2416498] RIMDatabaseManager.mm:123 -[RIMDatabaseManager setLoggerTypes:]_block_invoke 🚦[Database] ❌ Error: Code:21, Type:SQLite, Msg:not an error, Tag:0, ExtCode:0, SQL:PRAGMA synchronous='NORMAL', Path:/var/mobile/Containers/Data/Application/CC57D5E2-07B9-4E28-93CB-9B2385517762/Library/RIM/15377fcb99d18f2fc05d0221a94142b8/IM.db, Op:4
搜索了下 issues, https://github.com/Tencent/wcdb/issues/317 提到加 -all_load
flag,试了下可行。
但是我之前的项目没有加过 -all_load
也没出现过这个问题,再检查了下项目设置,发现 Podfile
中设置了 use_frameworks! :linkage => :static
,移除 :linkage => :static
参数后也解决了问题(没添加 -all_load
)。
use_frameworks!
参数是 CocoaPods 1.9 加的新特性,我不确定这个问题是 CocoaPods 的问题还是 WCDB 的 podspec 需要额外设置什么。
有解决么
上面不是写了么,项目编译参数里加 -all_load
或者 移除 Podfile
中的 :linkage => :static
这样可以解决,我这边成功了:
-framework "WCDBSwift" -framework "sqliterk" -force_load $(BUILT_PRODUCTS_DIR)/WCDBOptimizedSQLCipher/sqlcipher.framework/sqlcipher
个人觉得 -all_load太暴力,链接所有的文件,不同的三方库很容易造成符号冲突。duplicate symbol xxx...
这样可以解决,我这边成功了:
-framework "WCDBSwift" -framework "sqliterk" -force_load $(BUILT_PRODUCTS_DIR)/WCDBOptimizedSQLCipher/sqlcipher.framework/sqlcipher
实测有效
这样可以解决,我这边成功了:
-framework "WCDBSwift" -force_load $(BUILT_PRODUCTS_DIR)/WCDBOptimizedSQLCipher/sqlcipher.framework/sqlcipher
this helped me.
直接运行可以,但是打包的时候报错了 Showing All Errors Only Build input file cannot be found: '***(路径)/BuildProductsPath/DailyBuild-iphoneos/WCDBOptimizedSQLCipher/sqlcipher.framework/sqlcipher'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?
同问,XCode没升级之前都正常,升级到15.2之后运行可以,打包会报错。 Build input file cannot be found: '***(路径)/BuildProductsPath/DailyBuild-iphoneos/WCDBOptimizedSQLCipher/sqlcipher.framework/sqlcipher'.
@Habit21D 你好,你的问题解决了吗,怎么能正常打包
@Habit21D 你好,你的问题解决了吗,怎么能正常打包
去Build Phases里,找到Run Scipt,往OutPut Files里增加$(BUILT_PRODUCTS_DIR)/WCDBOptimizedSQLCipher/sqlcipher.framework/sqlcipher。就可以打包了。 但是编译的时候会报sqlcipher重复了,所以编译的时候去掉这项,打包的时候加上这项