Tencent / wcdb

WCDB is a cross-platform database framework developed by WeChat.
Other
10.83k stars 1.41k forks source link

WCTTokenizerNameWCDB is nil #349

Closed Graphicooooone closed 5 years ago

Graphicooooone commented 6 years ago

The language of WCDB

Objective-C

The version of WCDB

v1.0.5

The platform of WCDB

iOS

The installation of WCDB

Cocoapods

What's the issue?

There are many TFS Class similar to WCTSampleFTSData in my project. I tried to do the same thing with demo, but the project crashed at startup. The information is as follows. Could it be that WCTTokenizerNameWCDB is nil causing?

wechatimg512

Graphicooooone commented 6 years ago

@RingoD thx

RingoD commented 6 years ago

As the tutorial said, you should add -objc_load or -all_load to add the extern variable for static lib.

Graphicooooone commented 6 years ago

But I installed WCDB through Cocoapods, and there already exists "-all_load" and "-objc" in the project.

Graphicooooone commented 6 years ago

Cocoapods automatically added "-objc" for me and I manually added "-all_load" still have the same problem.

RingoD commented 6 years ago

Maybe you should provide a project that can reproduce this problem or try to upgrade to v1.0.6

Graphicooooone commented 6 years ago

Ok, after receiving the reply of issue, I tried cocoapod again and updated it to v1.0.6, but the same problem still exists. This is the demo I pulled from the project model, and when I run it, I get the same error message. [WCDB_FTS.zip](https://github.com/Tencent/wcdb/files/2288952/WCDB_FTS.zip)

Graphicooooone commented 6 years ago

@RingoD thanks

RingoD commented 6 years ago

Thanks for your attention.

I think it's kind of bug in static lib and WCDB.

The order of file initialization can not be sure. BUT the ORM and external variable are related to it.

It's already fixed in next version.

Currently, you can use dynamic framework instead. e.g. Carthage

RingoD commented 6 years ago

It's fixed by dynamic framework of v1.0.7

Graphicooooone commented 6 years ago

@RingoD I am using version v.1.0.7.5 of WCDB and the problem has not been solved

RingoD commented 6 years ago

What does your podfile look like? And what's the console output of pod install?

Graphicooooone commented 6 years ago

podfile:

platform :ios, '9.0' inhibit_all_warnings!

target 'Memento' do

...

DataBase

pod 'WCDB'

...

end

Graphicooooone commented 6 years ago

... Installing WCDB (1.0.7.5) ...

Generating Pods project Integrating client project

[!] Please close any current Xcode sessions and use Memento.xcworkspace for this project from now on. Sending stats Pod installation complete! There are 19 dependencies from the Podfile and 22 total pods installed.

Graphicooooone commented 6 years ago

@RingoD This is information about my podfile and the command line after executing 'pod install' I'm sorry for not replying to you in time thanks.

RingoD commented 6 years ago

Did you add -ObjC in your linker flag?

Graphicooooone commented 6 years ago

I've already added

RingoD commented 6 years ago

Then I think it should be the construct order problem of static lib. There are three ways to fix.

  1. Use raw string instead WCTTokenizerNameWCDB. The value of WCTTokenizerNameWCDB should be @"WCDB";
  2. Add use_frameworks! into your podfile to port WCDB to dynamic framework;
  3. Wait for the next major version of WCDB with new implementation;

You can choose one of them for your favor.

Graphicooooone commented 6 years ago

I think I will use the first method to solve the problem for the time being, but there is a problem if there are multiple FTS files in the project, is it allowed to use the same "WCDB" as WCTTokenizerNameWCDB

Graphicooooone commented 6 years ago

source code NSString *const WCTTokenizerNameWCDB = @(WCDB::FTS::WCTModule::Name);

RingoD commented 6 years ago

Yes, there will not be any problem.

RingoD commented 5 years ago

It's fixed by redesigning the ORM feature to avoid global constructor. It will be released in next version.

JHCarpediem commented 3 years ago

It's fixed by redesigning the ORM feature to avoid global constructor. It will be released in next version.

1.Use raw string instead WCTTokenizerNameWCDB. The value of WCTTokenizerNameWCDB should be @"WCDB"; make bug: [WCDB][ERROR]Code:2, Type:Abort, Msg:Tokenize name is not registered

JHCarpediem commented 3 years ago

I think I will use the first method to solve the problem for the time being, but there is a problem if there are multiple FTS files in the project, is it allowed to use the same "WCDB" as WCTTokenizerNameWCDB

The first method make that :[WCDB][ERROR]Code:2, Type:Abort, Msg:Tokenize name is not registered