Skip to content

Instantly share code, notes, and snippets.

View pdarcey's full-sized avatar

Paul Darcey pdarcey

View GitHub Profile
@pdarcey
pdarcey / SwiftPackages.md
Created April 19, 2024 07:23
Using and Updating your own Swift Packages in your Project

Using Your Own Swift Packages in Your Project

Create a Package

  • Create a package using, for example these instructions
  • Save and commit, as necessary
  • Push to Github (or other remote service)
  • Set appropriate access to others
  • See instructions below for publishing a release
@pdarcey
pdarcey / SwiftData.md
Last active April 16, 2024 19:00
SwiftData storage on the Mac

SwiftData storage on the Mac

Where does SwiftData store things on the Mac?

Default Storage Location

On iOS, this directory is in the app's own storage location (app_UUID/Library/Application Support) but, on the Mac, it's a shared location in the user's Library.

By default on the Mac, SwiftData stores its model in the /~/Library/Application Support directory as default.store. (It will also add two other files, default.store-shm and default.store-wal, as the model is stored as a SQLite database, and these are these additional files are part of how SQLite works.)

@pdarcey
pdarcey / SwiftUI_Grids.md
Created August 30, 2021 02:26
Getting SwiftUI Grids to adapt to multiple screen sizes/orientations

Usually, you set your grid up with something to generate your [GridItems], often something like:

var items: [GridItem] {
    return Array(repeating: .init(.adaptive(minimum: 250), spacing: 10, alignment: .center), count: 1)
}

See that 1 at the end? That's the important bit!

(Technically, it can be other numbers too and still work, but 1 is kinda what the Grid will be looking for, and what you expect the result to look like, when it adaptive.

@pdarcey
pdarcey / ErrorsGist.md
Last active July 29, 2021 06:18
Unhelpful Errors (mostly Command-line and/or Core Data related)

Core Data unhelpful error: Failed to load model named

CoreData: error:  Failed to load model named LocalStorage

importJSON2/UploadStoreData.swift:51: Fatal error: URL doesn't contain valid data

Illegal instruction: 4
@pdarcey
pdarcey / MapOverlays
Last active September 21, 2023 03:20
All the steps to create and display an overlay on a map
// See comments below
@pdarcey
pdarcey / stringly-typedAPI
Created March 7, 2017 00:24
Stringly-typed API Replacement
// MARK: - Use Enums for getting/setting User Defaults
protocol KeyNameSpaceable {
func namespaced<T: RawRepresentable> (_ key: T) -> String
}
extension KeyNameSpaceable {
func namespaced<T: RawRepresentable> (_ key: T) -> String {
return "\(Self.self).\(key.rawValue)"

Keybase proof

I hereby claim:

  • I am pdarcey on github.
  • I am pdarcey (https://keybase.io/pdarcey) on keybase.
  • I have a public key whose fingerprint is 885D 9035 9A21 FFF6 03B0 E165 C55C B57F 51F8 9ABE

To claim this, I am signing this object: