sindresorhus / Defaults

💾 Swifty and modern UserDefaults
https://swiftpackageindex.com/sindresorhus/Defaults/documentation/defaults
MIT License
1.93k stars 115 forks source link

"Cannot find 'OSAllocatedUnfairLock' in scope" when archiving #173

Closed jordibruin closed 2 months ago

jordibruin commented 2 months ago

Getting this error in the last week when trying to archive macOS, iOS or visionOS builds. This is on the latest version of main.

@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, visionOS 1.0, *) final class AllocatedUnfairLock: Lock { private let _lock = OSAllocatedUnfairLock()

    override init() {
        super.init()
    }

    override func lock() {
        _lock.lock()
    }

    override func unlock() {
        _lock.unlock()
    }
}
jordibruin commented 2 months ago

Manually adding

import os

to the top of the utilities file fixes this.

jordibruin commented 2 months ago

Made a PR, but I think there must be something we're missing because I would assume you run into this as well.

https://github.com/sindresorhus/Defaults/pull/174

sindresorhus commented 2 months ago

https://github.com/sindresorhus/Defaults/releases/tag/v9.0.0-beta.2

In debug, we import import OSLog, which implicitly imports os. This does not happen in production, hence the error. Implicit imports are the worst...