A collection of utilities written as part of articles on Cocoa with Love
- Better stack traces in Swift
- Gathering system information in Swift with sysctl
- Presenting unanticipated errors to users
- Swift name demangling: C++ vs Swift for parsing
- Random number generators in Swift
- Mutexes and closure capture in Swift
- Design patterns for safe timer usage
- Values and errors, part 1: 'Result' in Swift
- Optimizing a copy-on-write double-ended queue in Swift
- Specifying function execution contexts
- Specifying function execution contexts
- Testing actions over time
- In a subdirectory of your project's directory, run
git clone https://github.com/mattgallagher/CwlUtils.git
- Drag the "CwlUtils.xcodeproj" file from the Finder into your own project's file tree in Xcode
- Click on your project in the file tree to access project settings and click on the target to which you want to add CwlUtils.
- Click on the "Build Phases" tab and if you don't already have a "Copy Files" build phase with a "Destination: Frameworks", add one using the "+" in the top left of the tab.
- Still on the "Build Phases" tab, add "CwlUtils.framework" to the "Copy Files, Destination: Frameworks" step. NOTE: there may be multiple "CwlUtils.framework" files in the list, including one for macOS and one for iOS. You should select the "CwlUtils.framework" that appears above the corresponding CwlUtils macOS or iOS testing target.
- Optional step: Adding the "CwlUtils.xcodeproj" file to your project's file tree will also add all of its schemes to your scheme list in Xcode. You can hide these from your scheme list from the menubar by selecting "Product" -> "Scheme" -> "Manage Schemes" (or typing Command-Shift-,) and unselecting the checkboxes in the "Show" column next to the CwlUtils scheme names.
- In Swift files where you want to use CwlUtils code, write
import CwlUtils
at the top.
Note about step (1): it is not required to create the checkout inside your project's directory but if you check the code out in a shared location and then open it in multiple parent projects simultaneously, Xcode will complain – it's usually easier to create a new copy inside each of your projects.