Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- (BOOL)setKey:(NSString*)key; is not work #838

Closed
ProMonkeyZ opened this issue Nov 3, 2022 · 3 comments
Closed

- (BOOL)setKey:(NSString*)key; is not work #838

ProMonkeyZ opened this issue Nov 3, 2022 · 3 comments

Comments

@ProMonkeyZ
Copy link

my project is swift/oc mix project,I have a private pods project. the project's podspec file like this:

Pod::Spec.new do |s|
  s.name = 'ZYCommon'
  s.version = '0.1.2'
  s.frameworks = 'UIKit', 'Metal', 'MetalKit', 'OpenGLES', 'QuartzCore', 'Speech', 'SystemConfiguration', 'GLKit', 'CoreTelephony'
  s.libraries = 'bz2.1.0', 'c++', 'c++abi', 'z.1.2.5', 'z', 'resolv.9', 'swiftCore'
  s.requires_arc = true
  s.pod_target_xcconfig = {"DEFINES_MODULE"=>"YES", "BUILD_LIBRARY_FOR_DISTRIBUTION"=>"YES", "SWIFT_INCLUDE_PATHS"=>"ZYCommon/Classes/**/*"}
  s.source = {:git=>"git@gitlab.zhangyue-inc.com:ios_ireader_binary/ZYCommon.git", :tag=>"0.1.2"}
  s.vendored_frameworks = 'ZYCommon/Frameworks/UserFeedBack.framework', 'ZYCommon/Frameworks/WebP.framework', 'ZYCommon/Frameworks/ZYLayoutEngine.framework'
  s.vendored_libraries = 'ZYCommon/Librarys/**/*.a'
  s.resources = 'ZYCommon/Assets/*'
  s.swift_versions = '5.0'

  s.dependency 'FMDB'
  s.dependency 'FMDB/SQLCipher'

  s.platform = :ios, '9.0'

  s.ios.vendored_frameworks = 'ios/ZYCommon.xcframework'
end

the podfile:

use_frameworks! :linkage => :static
target myProject do
    pod 'ZYCommon'
end

i use fmdb:

        _databaseQueue = [FMDatabaseQueue databaseQueueWithPath:path];
        if (result == 0) {
            [_databaseQueue inDatabase:^(FMDatabase * _Nonnull db) {
                char cKey[44] =  {88,106,78,7220,387,848,852,862t,86,730,104,108,99,83,81,51,78,49,82,53,81,85,78,65,87,109,112,69,100,69,66,89,100,84,73,51,81,110,74,50,74,85,99,121};
                NSData *keyData = [NSData dataWithBytes:cKey length:44];
                [db setKey:[keyData base64EncodedString]];
            }];
        }

but setKey always return NO. the inner func rc return SQLITE_MISUSE. but when i change use_frameworks! :linkage => :static to use_modular_headers! , every thing will be ok. so , i think my db password is right. may i have a suggestion frome you , thanks very much !

- (BOOL)setKeyWithData:(NSData *)keyData {
#ifdef SQLITE_HAS_CODEC
    if (!keyData) {
        return NO;
    }
    
    int rc = sqlite3_key(_db, [keyData bytes], (int)[keyData length]);
    
    return (rc == SQLITE_OK);
#else
#pragma unused(keyData)
    return NO;
#endif
}
@lzcuriosity
Copy link

lzcuriosity commented Nov 3, 2022 via email

@ProMonkeyZ
Copy link
Author

您的邮件已经收到,我会尽快查阅,谢谢!Best Wishes!

嗯嗯, 感谢. 我这边是做了工程的组件化之后, 私有pod库里面引用了FMDB/SQLCipher, 然后这个库编译为了二xcframework, 所以在podfile里面只能用use_frameworks! :linkage => :static的方式引入三方库. 不知道这个设置为什么会导致给数据库设置密码不能正确工作, 源码里面因为都是c, 也不能断点跟随, 希望您可以关注一下.

@ProMonkeyZ
Copy link
Author

谢谢你的回复, 问题我找到了.
是因为我同时依赖了s.dependency 'FMDB'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants