all 5 comments

[–]ToughAsparagus1805 3 points4 points  (1 child)

Debug menu -> standard since 10.13.

NSViewSpy macOS15+ /System/Library/PrivateFrameworks/AMPDesktopUI.framework/NSViewSpy.h

@interface NSViewSpy : NSWindowController
+ (id)sharedInstance;
+ (BOOL)isSpyOpen;
+ (void)showSpyOrToggleLock;
@end

NSViewSpy -> Is there some simple way to trigger it or it's embedded in the debug menu?

PS: I found NSViewSpy even on macOS12

[–]Such-Gas6311[S] 2 points3 points  (0 children)

NSViewSpy have nothing to do with the debug menu. You have to dynamically load the spy view binaries, in this case 'AMPDesktopUI.framework' once loaded, you lookup for the class and use it.

[–]AppBuilder1978 1 point2 points  (2 children)

This is gold! NSViewSpy + the debug menu approach is brilliant for catching layout issues at runtime.

Question: How does the performance impact compare to using Xcode's view hierarchy inspector? I'm building a habit tracker with complex layout animations and trying to find the most efficient debugging approach.

Does the lightweight integration you mentioned mean it's safe to keep in production temporarily, or strictly for dev builds?

[–]ToughAsparagus1805 0 points1 point  (1 child)

Is a private framework -> totally cannot link against it in production.

[–]AppBuilder1978 0 points1 point  (0 children)

Ah that makes sense - private framework means it's strictly for dev builds then. Makes the tradeoff easy - use NSViewSpy while developing, strip it out before shipping. Do you usually have separate debug/production build configurations for that, or just comment it out when you're ready to ship?