Settings.bundle does not appear in Settings App

I have two apps, both made on iPad with Swift Playgrounds 4. The newer one was made with the latest release of SP4 and thus uses Swift 5.6, the other uses Swift 5.5 because it was made with a former version of SP4. iPadOS is 15.7.

Both apps make use of a Settings.bundle and both use the same code to register.

@main 
struct MyApp: App {
    init() {
        if !UserDefaults.standard.bool(forKey: "launchedBefore") {
            registerDefaultSettings()
            
            let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"]
            let build = Bundle.main.infoDictionary?["CFBundleVersion"]
            let versionInfo = "\(version!) (\(build!))"
            UserDefaults.standard.set( versionInfo, forKey: "versionInfo")
            
            UserDefaults.standard.set(true, forKey: "launchedBefore")
        }
    }
    
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

private func registerDefaultSettings() {
    guard
        let settingsBundle = Bundle.main.url(forResource: "Root.plist", withExtension: nil),
        let settings = NSDictionary(contentsOf: settingsBundle),
        let keyValues = settings.object(forKey: "PreferenceSpecifiers") as? [[String: AnyObject]]
    else {
        return
    }
    
    var defaultSettings = [String : AnyObject]()
    for keyValue in keyValues {
        if
            let key = keyValue["Key"] as? String,
            let value = keyValue["DefaultValue"] {
            defaultSettings[key] = value
        }
    }
    
    UserDefaults.standard.register(defaults: defaultSettings)
}

The settings of the 5.5 app appear in the Settings App whereas the settings of the 5.6 do not. If I move the Settings.bundle folder from 5.6. to 5.5, the settings for 5.6 appear in 5.5 thus the file structure and contents seem to be syntactically ok).

There was one obvious difference when setting up Settings.bundle in 5.6: SP4 requested to set defaultLocalization in Package.swift.

How do I get the 5.6 Settings.bundle to appear in the Settings App?

Answered by otabuzzman in 731591022

When adding resources using the menu item Insert from..., SP4 puts them into a Recources folder. If it does not exist SP4 creates that folder and adds an entry to Package.swift to process these resources when it builds the app. The entry is .process("Resources").

In my former 5.5 app I put Settings.bundle into the Resources folder and it worked as expected, that is the settings appeared in the Settings App. But in a newer version of SP4, the one with Swift 5.6 support, things seem to have changed. Settings.bundle has to be placed in the top-level folder of the app (as a folder-sibbling of Resources) and Package.swift needs one more entry:

.process("Resources"),
.copy("Settings.bundle")
Accepted Answer

When adding resources using the menu item Insert from..., SP4 puts them into a Recources folder. If it does not exist SP4 creates that folder and adds an entry to Package.swift to process these resources when it builds the app. The entry is .process("Resources").

In my former 5.5 app I put Settings.bundle into the Resources folder and it worked as expected, that is the settings appeared in the Settings App. But in a newer version of SP4, the one with Swift 5.6 support, things seem to have changed. Settings.bundle has to be placed in the top-level folder of the app (as a folder-sibbling of Resources) and Package.swift needs one more entry:

.process("Resources"),
.copy("Settings.bundle")
Settings.bundle does not appear in Settings App
 
 
Q