Menu

SwiftPM's Bundle.module crashes your Mac app on every machine but yours
πŸ“°

SwiftPM's Bundle.module crashes your Mac app on every machine but yours

DEV Community: swiftΒ·Ritesh SethiaΒ·about 14 hours ago
#OJINga66
#devtoswift#devto#dev#bundle#build
Reading 0:00
15s threshold

I shipped a Mac app. It was signed, notarized, stapled, and verified by

Gatekeeper. 378 tests passed. I installed it from the DMG on my own machine and

used it for an hour.

A friend downloaded it. It crashed on launch. Not misbehaved β€” crashed,

instantly, every time, before a window appeared.

The cause is a generated accessor that most people never read, and it will do

the same thing to your app if you build a .app out of Swift Package Manager

targets that have resources.

What SwiftPM generates

When a target declares resources: , SwiftPM writes a file called

resource_bundle_accessor.swift into the build directory and compiles it into

your module. That file is what Bundle.module resolves to. It looks roughly

like this:

extension Foundation . Bundle { static let module : Bundle = { let bundleName = "Arazio_ArazioCore" let overrides : [ URL ] = [ /* SWIFT_PACKAGE_RESOURCE_BUNDLE_PATH, if set */ ] let candidates = overrides + [ Bundle . main . resourceURL , Bundle ( for : BundleFinder . self ) .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.