This is usually because you edited a file that should have been generated instead. In which case Xcode will stay confused until you clear the cache (and generated files along with it) and rebuild.
Continue readingYearly Archives: 2024
How to route iPhone/Simulator traffic through Proxyman on Mac
Proxyman has this nice menu under “Certificate” where you can select configuration for either physical device or simulators:
Continue readingSwift: Why You Shouldn’t Make Mock Classes Public for Tests
Because you’ll run into weird access control problems.
For example, you may be setting a public property of a class, be po
logging the new value out in console no problem, and still be getting the old value in expecting tests, right in the next line.
Setting wildcard subdomain on Cloudflare DNS doesn’t work
If you use the Full (Strict) mode, you may run into Invalid SSL certificate 526
on www or other subdomains. Even though their official documentation claims that adding a A record with *
should work, it didn’t for me.
The solution is to add Redirect Rules for them.
Continue readingXCode: How To Get More Than 1 Build Error At A Time
Though this means that there might be phantom errors that are not real, but are caused by the dependency’s build failure.
How to clear xcode build cache
If your deleted files are still being complained about “Build input files cannot be found”:
Continue readingDifference between Task and async let
Task is for “fire-and-forget” use cases, which means you don’t need to handle the result when it’s done processing:
Task {
await fetchData(for: user)
}
Async let is for parallel processing where you do have to process the results:
async let a = callA()
async let b = callB()
let results = await a + b
How to auto generate id with GRDB.swift
And how to only create a table if it doesn’t already exist: as with sqlite, use ifNotExists
:
db.create(table: "todo", ifNotExists: true) { t in
t.autoIncrementedPrimaryKey("id")
t.column("name", .text).notNull()
}
Singleton pattern in Swift for DbManager
With the example of GRDB, a lightweight sqlite wrapper:
class DbManager {
static let sharedInstance = DbManager()
var dbPath: String! <--- !!!
var dbQueue: DatabaseQueue!
private init() {
do {
dbQueue = try connectToDatabase()
try createTable()
} catch {
print(error)
}
}
}
Continue reading