因为中文密码压缩的时候,可能用的是不同的字符编码,所以有时候会出现不同系统下解压显示『密码错误』的信息。
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 How to install and uninstall packages in Xcode
Right here: add through pasting a github URL. All done.
I love it when there’s an official way of managing packages. The evolution of even package management systems are just too much.
And how to uninstall: from the +/- button here. Not as friendly. Why couldn’t they have added a “remove package” option on the leftnav?
Xcode cannot Preview “the preview preflight must belong to at least one target in the current scheme in order to use previews”
This happens after moving the swift files around.
Solution: simply quit Xcode and reload so that it can re-source the new location of the files.
Or command + B to rebuild. Sometimes those formatting errors are just not caught up and not rebuilt yet.
My Bash Set Up
Every once in a while I end up moving to a new setup, and have to do this all over again. Here for my own reference:
1. Color scheme
First, the color scheme I like:
Continue readingBash history search autocomplete
https://github.com/junegunn/fzf#using-homebrew
Worth installing everywhere. On OSX, simply:
$ brew install fzf
# To install useful key bindings and fuzzy completion:
$(brew --prefix)/opt/fzf/install