A collection of utilities written as part of articles on Cocoa with Love
The following features are included in the library.
- CwlStackFrame.swift from Better stack traces in Swift
- CwlSysctl.swift from Gathering system information in Swift with sysctl
- CwlUnanticipatedError.swift from Presenting unanticipated errors to users
- CwlScalarScanner.swift from Swift name demangling: C++ vs Swift for parsing
- CwlRandom.swift from Random number generators in Swift
- CwlMutex.swift from Mutexes and closure capture in Swift
- CwlDispatch.swift from Design patterns for safe timer usage
- CwlResult.swift from Values and errors, part 1: 'Result' in Swift
- CwlDeque.swift from Optimizing a copy-on-write double-ended queue in Swift
- CwlExec.swift from Specifying function execution contexts
- CwlDebugContext.swift from Testing actions over time
This project can be included in your projects in a number of different ways:
The standard restrictions for each of these approaches apply so you'll need to pick an approach based on your situation and preferences.
Minimum requirements are iOS 8 or macOS 10.10.
- 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 to somewhere your in own project's file tree in Xcode
- Drag the "CwlUtils.framework" from the "Products" folder of the "CwlSignal" project to the "Copy Files (Frameworks)" build phases of any target that you want to include this module.
That third step is a little tricky if you're unfamiliar with Xcode but it involves:
- click on your project in the file tree
- click on the target to which you want to add this module
- select the "Build Phases" tab
- if you don't already have a "Copy File" build phase with a "Destination: Frameworks", add one using the "+" button in the top left of the tab
- click the "+" within the "Copy File (Frameworks)" phase and from the list that appears, select the "CwlUtils.framework". There will probably be two frameworks with the same name – macOS and iOS versions – so look for the "CwlUtils.framework" that appears immediately above the corresponding macOS or iOS CwlUtils testing target
This approach generates a concatenated files named CwlUtils.swift that can simply be added to another project (no dynamic frameworks, libraries or other settings required).
This approach will omit the CwlStackFrame.swift, CwlAddressInfo.swift, CwlUnanticipatedError.swift and CwlFrameAddress.c files (since they cannot be included via a single-file approach). If you need these files, please use one of the other inclusion strategies.
- Get the latest version of CwlUtils by running
git clone https://github.com/mattgallagher/CwlUtils.git
on the command-line. - Open the CwlUtils.xcodeproj in Xcode and select the CwlCwlUtilsConcat scheme with a destination of "My Mac" (choose from the Scheme popup in the toolbar or from the "Product" → "Scheme" and "Product" → "Destination" menus in the menubar.
- Build the scheme (Command-B or "Product" → "Build")
- Open the "Products" folder by right-clicking (or Control-click) on the "Products" folder in the project's file tree in Xcode and select "Show in Finder" and open the "Debug" folder in the "Products" folder that this reveals.
Inside a folder located "Concat_internal" should the file "CwlUtils_internal.swift". You can copy this file and include it in any of your own projects, like any other file.
A folder named "Concat_public" should also be present. This version is almost identical to the "Concat_internal" version except that where the "Concat_internal" version strips public
and open
specifiers, the "Concat_public" version leaves these in-place. This allows the "Concat_public" version to be use in the "Sources" folder of Swift playgrounds or otherwise used where the features need to be exported from a module.
Add the following to the dependencies
array in your "Package.swift" file:
.Package(url: "https://github.com/mattgallagher/CwlUtils.git", majorVersion: 1),
Or, if you're using the swift-tools-version:4.0
package manager, add the following to the dependencies
array in your "Package.swift" file:
.package(url: "https://github.com/mattgallagher/CwlUtils.git", majorVersion: 1)
Add the following to your target in your "Podfile":
pod 'CwlUtils', :git => 'https://github.com/mattgallagher/CwlUtils.git'
Add the following line to your Cartfile:
git "https://github.com/mattgallagher/CwlUtils.git" "master"