In trying to convert some Objective-C to Swift, I have a subclass of NSWindowController and want to write a convenience initializer. The documentation says
You can also implement an NSWindowController subclass to avoid requiring client code to get the corresponding nib’s filename and pass it to init(windowNibName:) or init(windowNibName:owner:) when instantiating the window controller. The best way to do this is to override windowNibName to return the nib’s filename and instantiate the window controller by passing nil to init(window:).
My attempt to do that looks like this:
class EdgeTab: NSWindowController
{
override var windowNibName: NSNib.Name? { "EdgeTab" }
required init?(coder: NSCoder)
{
super.init(coder: coder)
}
convenience init()
{
self.init( window: nil )
}
}
But I'm getting an error message saying "Incorrect argument label in call (have 'window:', expected 'coder:')". Why the heck is the compiler trying to use init(coder:) instead of init(window:)?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Is there any way I can know that another app has gone full screen? Please note that this is not what NSWindowDidEnterFullScreenNotification does, that only works for my own windows.
As for why I need to know: Say you're playing a YouTube video full screen. The video fills up the main display, and if there's a second display, it goes black. Well, mostly. I have a utility app with small status windows that remain on top. I'd like to be polite and hide them in this scenario.
When I use the Xcode 13 beta to build an app, view-based NSTableViews don't draw anything when the app is run under macOS 10.12 or earlier. I filed a bug (FB9278241), just wondering if anyone has any insight or workaround.
In the General system settings panel in Ventura, under Login Items, there are 2 sections: "Add Login Items", and "Login Items Added by Apps". What is this second category, and where can I find more about how to create such login items?
I'm trying to use signposts to help profile C++ code with Instruments (with Xcode 14 beta 5), and it's not working. A section of code in question, which is definitely getting reached, starts like this
static os_log_t sSignpost_log = nullptr;
if (__builtin_available( macOS 10.14, * ))
{
if (sSignpost_log == nullptr)
{
sSignpost_log = os_log_create( "com.frameforge.gscn", "PointsOfInterest" );
}
os_signpost_interval_begin( sSignpost_log, 99, "com.frameforge.gscn" );
}
and ends like this
if (__builtin_available( macOS 10.14, * ))
{
os_signpost_interval_end( sSignpost_log, 99, "com.frameforge.gscn" );
}
In Instruments, I have a Points of Interest instrument, and in the recording options for that instrument, I added 99 and com.frameforge.gscn as a row under "signpost code names". But after recording a run, the Points of Interest instrument always shows "No Data". I tried adding an os_signpost instrument, and it shows some data, but none of mine. What am I missing?
The docs on -[NSString stringWithFormat:] link to old docs on string format specifiers which say that “the %s specifier causes the characters to be interpreted in the system default encoding”. What the heck is the system default encoding? I tried googling it, and all I found was people saying that while a program may have a default encoding, the Mac OS does not.
I have a system preference pane that contains a background-only app that it wants to set as a login item. I understand that the proper way to set up login items in Ventura is by using the new SMAppService framework. In order to do so, I need an instance of SMAppService. I can't create it using +[SMAppService loginItemServiceWithIdentifier:], because that assumes that the login item is embedded in the calling app, and in this case the calling app is System Preferences. That leaves having the app itself get the mainAppService class property. But when I do that, and then ask the service for its status, the result is SMAppServiceStatusNotFound. That's documented as:
An error occurred and the framework couldn’t find this service.
What kind of error??? When I try this, I see some messages in Console from the tccd process that look like they might be related, but they don't clarify what's wrong.
Must I just give up on using a system preference pane, and make my utility a plain old app containing a helper app?
I'm trying to use -[SMAppService loginItemServiceWithIdentifier:] API, and after creating the SMAppServiceInstance, its status is SMAppServiceStatusNotFound. That means it didn't find the helper app?
The documentation is a little mixed up. It says that the parameter is "The bundle identifier of the helper application", but also says "The property list name must correspond to a property list in the calling app’s Contents/Library/LoginItems directory". So which is it, a property list name or a bundle identifier? And it the thing in the LoginItems directory a helper application or a property list?
What I have is an app bundle inside the Contents/Library/LoginItems of the app that's calling the SMAppService API. Or in other words, the given bundle identifier parameter is the CFBundleIdentifier value in Caller.app/Contents/Library/LoginItems/Helper.app/Contents/Info.plist. Is that not the right way to do it?
I have a keyboard macro utility that uses a global event tap, and requires accessibility permission. It works except when typing in the edit field of a standard Save panel. Then it just beeps when I call CGEventTapPostEvent. I'm guessing that has something to do with standard open/save panels running in some special security box ( I forget the term). If I could just turn off my utility in Save panels, that would be good enough, but I can't figure out how to detect that situation. If I look at the result of CGWindowListCopyWindowInfo, I can see the Save window, but I don't see anything special about it. Nor can I think of any way of detecting that the keyboard event I posted has been rejected.
Sometimes, a Mac gets stuck in secure keyboard input mode, which prevents event taps from working. Googling indicates that this is a perennial intermittent problem. I've seen the suggestion to find the responsible process by using the command line
ioreg -l -w 0 | grep SecureInput
and looking for a PID in the output. When this happened to me today, the PID was that of the loginwindow process. That seems to be a bogus "I don't really know" result. In my case, quitting Safari cleared the problem. But is there any better way to find out the real source of the problem than quitting apps one by one?
When I try to turn on sandboxing on a helper tool, it crashes on launch. I thought my problem was solved when I found the post Sandboxed Helper Tool Crashing in libsystem_secinit, but no. I set CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO in the target that builds the tool, and verified that the only entitlement in the built tool is that com.apple.security.app-sandbox is true, but it still crashes.
Backtrace:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_secinit.dylib 0x7ff81af68400 _libsecinit_appsandbox.cold.7 + 49
1 libsystem_secinit.dylib 0x7ff81af6793c _libsecinit_appsandbox + 1831
2 libsystem_trace.dylib 0x7ff80f06649c _os_activity_initiate_impl + 51
3 libsystem_secinit.dylib 0x7ff81af671d4 _libsecinit_initializer + 67
4 libSystem.B.dylib 0x7ff81af7b8b9 libSystem_initializer + 286
5 dyld 0x7ff80efa1618 invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 172
6 dyld 0x7ff80efe0de9 invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 242
7 dyld 0x7ff80efd4ef7 invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 557
8 dyld 0x7ff80ef870b7 dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 245
9 dyld 0x7ff80efd40a7 dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 175
10 dyld 0x7ff80efe08d2 dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 470
11 dyld 0x7ff80efa14f6 dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 150
12 dyld 0x7ff80efa9fd4 dyld4::PrebuiltLoader::runInitializers(dyld4::RuntimeState&) const + 30
13 dyld 0x7ff80efc100d dyld4::APIs::runAllInitializersForMain() + 71
14 dyld 0x7ff80ef8c369 dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 3743
15 dyld 0x7ff80ef8b281 start + 2289
I'm getting a code signing crash when I try to register a helper app as a login item, and I think this is new with macOS 13.4. That is, the crash log contains this:
Exception Type: EXC_CRASH (SIGKILL (Code Signature Invalid))
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: CODESIGNING 4 Launch Constraint Violation
I'm seeing one suspicious message in the system log:
tccd Prompting policy for hardened runtime; service: kTCCServiceAppleEvents requires entitlement com.apple.security.automation.apple-events but it is missing for accessing={TCCDProcess: identifier=com.jwwalker.AutoPairs.uiapp,
pid=91471, auid=501, euid=501, binary_path=/Applications/AutoPairs 4.0.1a1/AutoPairs4.0.1a1.app/Contents/MacOS/AutoPairs}, requesting={TCCDProcess: identifier=com.apple.appleeventsd, pid=531, auid=55, euid=55, binary_path=/System/Library/CoreServices/appleeventsd},
I can't figure out why the OS would think that I need an Apple Events entitlement.
I've looked a the thread Resolving Code Signing Crashes on
Launch, but it hasn't enlightened me. One problem I ran into is at the step
certtool d "authorised0.cer"
I get the output
CSSM_CL_CertGetAllFields: CSSMERR_CL_UNKNOWN_FORMAT
When I go to https://www.frameforge.com in Safari, the address bar doesn't contain the little padlock icon indicating proper SSL. But if I go to the same URL in FireFox, Chrome, or Edge, they do have a lock indicating that all is well. How can I figure out why Safari is not happy with this site's certificates or whatever?
Yesterday and today, when I try to notarize a Mac app, it fails in the upload stage. And yet Apple's system status page shows a green dot next to Developer ID Notary Service.
I've tried relaunching Xcode and even rebooting the Mac.
Xcode 14.3, macOS 13.4.1
Feedback filed, FB12570950
I'm trying to download a small data file using NSURLSession, but the completion handler is never called (where "never" means I waited long after the specified timeout).
NSURLSessionConfiguration* config =
NSURLSessionConfiguration.ephemeralSessionConfiguration;
config.timeoutIntervalForResource = 120.0;
config.timeoutIntervalForRequest = 120.0;
NSURLSession* session = [NSURLSession sessionWithConfiguration: config];
[session dataTaskWithURL: inURL
completionHandler:
^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error)
{
...
}];
I'm trying to update some old code that used the deprecated NSURLConnection class, and am using the same URL, so I know that the URL is good.