Last 12 weeks · 0 commits
4 of 6 standards met
Since updating to XCode 16, the following error is thrown in the Defaults package: "Accessing StateObject's object without being installed on a View. This will create a new instance each time." !image I'm using the package in one view only: Am I using it wrong? Before, in XCode 15, this error did not show up. And I'm using the latest main branch commit.
Repro project: https://github.com/nxtbgthng/DefaultsPlaygroundsRepro Summary App crashes on iOS device at launch when is imported in the app target and Defaults is present. dyld error: Library not loaded: /usr/lib/swift/libLiveExecutionResultsLogger.dylib Deeper cause (symbol-level) The parameter-pack overload pulls in Swift pack runtime symbols: _swift_allocateMetadataPack _swift_allocateWitnessTablePack On iOS device these symbols are not provided by libswiftCore; with Playgrounds present they resolve to libLiveExecutionResultsLogger in the SDK, which is absent on device → crash. The only object referencing those symbols is Defaults.o (from the Defaults package). Notes Removing Playgrounds or removing Defaults makes the app launch. This happens even if the pack overload is not called in app code. Likely fix direction Avoid parameter-pack overload on iOS device (or provide fixed-arity overloads for iOS, keep pack overload for simulator/macOS).
Repository: sindresorhus/Defaults. Description: 💾 Swifty and modern UserDefaults Stars: 2440, Forks: 155. Primary language: Swift. Languages: Swift (100%). License: MIT. Homepage: https://swiftpackageindex.com/sindresorhus/Defaults/documentation/defaults Topics: ios, macos, nsuserdefaults, storage, swift-package, swift-package-manager, swiftui-components, swifty, userdefaults. Latest release: 9.0.6 (4mo ago). Open PRs: 3, open issues: 18. Last activity: 1mo ago. Community health: 71%. Top contributors: sindresorhus, hank121314, kitwtnb, fredyshox, leoMehlig, shimastripe, LarsJK, AnderGoig, ThatsJustCheesy, jordibruin and others.
Swift
I am getting the following error [NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSString' (0x1e1552fd8) [/System/Library/Frameworks/Foundation.framework]' for key '*****', even though it was not explicitly included in the client allowed classes set: '{( )}'. This will be disallowed in the future. I think this is an error in Defaults as I am using defaults to save a custom object and the object conforms to __DefaultsSerializable*_ if found this Specifying the type here fixed it: override static var allowedTopLevelClasses: [AnyClass] { return [NSArray.self, NSString.self] }
Since using this library, we are seeing some crash reports which look related to KVO and UserDefaults. We haven't been able to reproduce them but are seeing crash reports on all iOS versions (although more on iOS 15). Has anyone seen something similar or any pointers on how to fix this (happy to submit a PR)? Here are some ideas/observations/infos: All crashes happen on a background queue, which might suggest it is some concurrency issue. UserDefaults is thread safe, but maybe KVO isn't? We are also using Zephry and previously a lot of the crashes originated in that library, but after dispatching all access to UserDefaults to the main thread the crashes stopped. We are using the observation feature from Defaults in a few places.
Every few days, I get this popup while using the Defaults package in my various projects. It forces the build to fail, and then I have to click this error and hit trust and enable. After doing this, you can then build the application as normal. Notes: I searched online and found this Chinese blog post that talks about the same error with potential remediation steps, but figured I would open this here. https://zhaoxin.pro/technology/Swift.html