objectbox / objectbox-swift

Swift database - fast, simple and lightweight (iOS, macOS)
https://swift.objectbox.io
Apache License 2.0
452 stars 30 forks source link

1.6.0 let store = try Store(directoryPath: directory.path) 这个方法不能使用? #52

Closed 624990742 closed 1 month ago

624990742 commented 3 years ago

我使用的是1.6.0,我在使用的时候用这个方法创建“let store = try Store(directoryPath: directory.path)”会报错误 Incorrect argument labels in call (have 'directoryPath:', expected'model:directory:maxDbSizeInKByte:fileMode:maxReaders:readOnly:')这个是怎么回事?

greenrobot commented 3 years ago

Could you try to translate to English, please?

624990742 commented 3 years ago

I use 1.6.0. When I use this method to create "let store = try store (directorypath: directory. Path)", an error will be reported Incorrect parameter label in call (with 'directorypath:', expected 'model: directory:maxDbSizeInKByte :fileM ode:maxReaders What's the matter with this?

greenrobot commented 3 years ago

Thanks for your effort. It is covered by this FAQ.

marcocebrian commented 3 years ago

@greenrobot I am facing the exact same issue here.

The project compiles perfectly with just one entity defined.

Could you give an insight on things to check? With a perfectly compiled project, it is still complaining for the same reason the moment I add the line:

let store = try Store(directoryPath: directory.path) Xcode: 12.5.1

Thanks!

marcocebrian commented 3 years ago

So, I realised I missed one step using CocoaPods and now it is working fine. I am noting it down in case it helps someone else:

As per the documentation, you have to execute a second step. A ruby script after pod install: Pods/ObjectBox/setup.rb

greenrobot-team commented 1 month ago

As for the original issue:

When I use this method to create "let store = try store (directorypath: directory. Path)", an error will be reported Incorrect parameter label in call (with 'directorypath:', expected 'model: directory:maxDbSizeInKByte :fileM ode:maxReaders What's the matter with this?

This means the generated Store initializer is missing, which accepts the directoryPath argument. Make sure that the project is set up correctly and build at least once to generate code. I added an explicit step (similar to our main docs) for this: https://swift.objectbox.io/getting-started#generate-objectbox-code

Closing this issue due to inactivity. :zzz: Feel free to comment with more details or submit a new issue.