Fix "Settings could not be opened" after the LumaControl rename - #2
Merged
Merged
Conversation
The gear button and reopening the app showed "Settings could not be opened -
The app's preference panes failed to load from its interface file."
Root cause: the rebrand changed PRODUCT_NAME to LumaControl and, in the same
commit, pinned SWIFT_MODULE_NAME = XDRMonitorControl. Those two settings feed
different parts of the build:
* PRODUCT_MODULE_NAME follows PRODUCT_NAME, and that is the module ibtool
bakes into the compiled storyboard, because every scene is declared with
customModuleProvider="target".
* SWIFT_MODULE_NAME is what the Swift compiler uses for -module-name, so the
pane classes became XDRMonitorControl.MainPrefsViewController at runtime.
The storyboard therefore asked for LumaControl.MainPrefsViewController, AppKit
found no such class, logged "Unknown class ... in Interface Builder file",
handed back a bare NSViewController, and the `as?` cast in main.swift produced
nil for all five panes. AppDelegate dropped every pane and raised the alert.
Dropping SWIFT_MODULE_NAME lets the Swift module follow PRODUCT_NAME again, so
the two cannot drift apart. The only other reference to the old module name was
the test target's `@testable import`.
Adds MonitorControlTests/SettingsPanesTests.swift, which loads the five scenes
exactly the way main.swift does and also compares each pane class's runtime
module against the app's own name. Putting the pin back makes it fail with all
five panes nil and the mismatched module name spelled out, so this cannot
regress silently again.
Verified: 14/14 tests pass; the compiled storyboard and the app binary now both
name _TtC11LumaControl23MainPrefsViewController; the Settings window opens on
the installed 0.3.0 (build 44) build.
Greptile SummaryThis PR repairs Settings pane loading after the application rename by allowing the Swift module name to follow
Confidence Score: 5/5The PR appears safe to merge and consistently fixes the storyboard-to-runtime module mismatch. The app’s Debug and Release configurations now derive the same
|
| Filename | Overview |
|---|---|
| MonitorControl.xcodeproj/project.pbxproj | Removes the conflicting app module override in both configurations and registers the new regression test source. |
| MonitorControlTests/SettingsPanesTests.swift | Adds hosted-app tests covering all five Settings storyboard scenes and module-name alignment. |
| MonitorControlTests/XDRBrightnessTests.swift | Updates the testable import to match the app’s corrected LumaControl module name. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A["PRODUCT_NAME = LumaControl"] --> B["PRODUCT_MODULE_NAME = LumaControl"]
B --> C["ibtool embeds LumaControl in storyboard classes"]
B --> D["Swift runtime classes use LumaControl module"]
C --> E["Settings scenes resolve successfully"]
D --> E
Reviews (1): Last reviewed commit: "Fix "Settings could not be opened" after..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What the user saw
Clicking the gear in the menu bar — or reopening the app — put up:
Settings became unreachable in 0.3.0. No pane would open at all.
Root cause
The LumaControl rebrand (
542e00c) changedPRODUCT_NAMEtoLumaControland, in the same commit, pinnedSWIFT_MODULE_NAME = XDRMonitorControlon the app target. Those two settings feed different parts of the build, and they silently disagreed:PRODUCT_MODULE_NAME(followsPRODUCT_NAME)customModuleProvider="target"LumaControlSWIFT_MODULE_NAME-module-name, and therefore the runtime Objective-C class namesXDRMonitorControlSo the compiled storyboard asked for
LumaControl.MainPrefsViewControllerwhile the binary only containedXDRMonitorControl.MainPrefsViewController.NSStoryboard.instantiateController(withIdentifier:)does not raise in that situation. AppKit logsUnknown class … in Interface Builder file, returns a plainNSViewController, and theas?cast inmain.swiftyieldsnil— for all five panes.AppDelegate.settingsPanesthen filters out everything,settingsWindowControlleris built with an empty pane list, and the guard inprefsClickedraises the alert.Evidence from the shipped 0.3.0 (build 39) bundle:
The fix
Remove the
SWIFT_MODULE_NAME = XDRMonitorControlpin from both app-target configurations. The Swift module then followsPRODUCT_NAMEagain, which is exactly what the storyboard resolves against, so the two can no longer drift apart. The only other reference to the old module name was the test target's@testable import.No storyboard change is needed —
customModule="MonitorControl"in the XML source is inert, becausecustomModuleProvider="target"makes ibtool substitute the real module name at compile time.Regression test
MonitorControlTests/SettingsPanesTests.swiftloads the five scenes exactly the waymain.swiftdoes, plus asserts each pane class's runtime module matches the app's own name.I checked that it genuinely catches the bug by putting the
SWIFT_MODULE_NAMEpin back and re-running:Verification
xcodebuild test— 14/14 pass (12 existing + 2 new), no failures._TtC11LumaControl23MainPrefsViewController.Risk
Low. One build setting is deleted and a test file is added; no runtime code, no storyboard, and no bundle identifier change. The bundle ID stays
com.shay2000.XDRMonitorControlon purpose, to keep the Accessibility grant and the helper login item alive across the rename.Rollback is a revert of this commit.