Example Fluent-SQLite iOS
0xLeif opened this issue · 2 comments
0xLeif commented
FLite is aim to be used with iOS to save data using SQLite.
Vapor 3 is supported and working in the master
branch.
Vapor 4 has the iOS test passing, but fails on an actual iOS project.
FLite 0.2.0 is using Vapor 4
I am getting this error on an iOS project
Fatal error: Unexpected error while running SelectableEventLoop: kqueue(): Too many open files (errno: 24).: file /Users/cri/Library/Developer/Xcode/DerivedData/test-gsikgwqyfpktaldxljjiybotjrwo/SourcePackages/checkouts/swift-nio/Sources/NIO/EventLoop.swift, line 828
2020-07-08 16:59:03.742934-0500 test[94438:1326247] Fatal error: Unexpected error while running SelectableEventLoop: kqueue(): Too many open files (errno: 24).: file /Users/cri/Library/Developer/Xcode/DerivedData/test-gsikgwqyfpktaldxljjiybotjrwo/SourcePackages/checkouts/swift-nio/Sources/NIO/EventLoop.swift, line 828
Here is the example iOS project code
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let semaphore = DispatchSemaphore(value: 0)
var values = [Todo]()
try? FLite.prepare(migration: Todo.self).wait()
try! FLite.add(model: Todo(title: "Hello World", strings: ["hello", "world"])).wait()
FLite.fetch(model: Todo.self)
.whenSuccess { (todos) in
values = todos
semaphore.signal()
}
semaphore.wait()
print("Values: \(values)")
}
}
tanner0101 commented
Hi @0xLeif. My guess is the problem is here: https://github.com/0xLeif/FLite/blob/develop/Sources/FLite/FLite.swift#L30. For maximum concurrency, set the number of threads to System.coreCount
. Since NIO is non-blocking, no more than that is needed.
0xLeif commented
@tanner0101 Awesome that was it! Thanks!!
Values: [Todo id: Optional(1C8E9B2E-33CD-42CC-9FCB-9D557801AA3B)
title: Hello World
someList: ["hello", "world"]]