Swiftpack.co - Package - bscothern/Once


GitHub license Carthage compatibleSPM

A simple thread safe replacement for Dispatch Once and pthread_once for Swift.

Carthage Usage

Include this line in your Cartfile:

github "bscothern/Once"

Swift Package Manager

Update your Package.swift to include this to your package dependencies:

.package(url: "https://github.com/bscothern/Once.git", from: "1.3.1")


import Once

let once = Once()

func foo() {
    once.runOnce {
        // Do stuff that should only execute the first time foo() is called.
    // Do stuff


Stars: 5
Help us keep the lights on


Used By

Total: 0


v1.3.1 - Oct 6, 2018

Swift 4.2 is now used for Xcode projects.

The latest iOS, macOS, tvOS, and watchOS are targeted.

v1.3.0 - May 9, 2018

Linux Support

v1.2.0 - Apr 13, 2018

Simplified use of C module, includes, etc.

v1.1.0 - Mar 22, 2018

Added SPM Support

v1.0.0 - Jan 25, 2018