Post

Replies

Boosts

Views

Activity

Instruments fails to record Points of Interest
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?
1
0
1.2k
Aug ’22
What is default encoding for %s?
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.
2
0
1.1k
Oct ’22
Can a system preference pane register a login item in Ventura?
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?
1
0
838
Oct ’22
Registering login item with new SMAppService API
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?
3
0
2.1k
Nov ’22
CGEventTapPostEvent fails in Save panel
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.
1
0
950
Feb ’23
How to find culprit when stuck in SecureInput mode?
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?
2
0
1.3k
Mar ’23
Sandboxed helper tool crash on launch
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
2
0
1.2k
Mar ’23
Code signing crash when registering login item
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
3
0
1.7k
May ’23
NSURLSession data download never completes
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.
2
0
815
Nov ’23
helper app dyld crash when using Xcode debugger
When I'm running my Mac app in the Xcode debugger, and it launches a helper app, the helper crashes with a dyld error. This does not happen if I am not debugging. Termination Reason: Namespace DYLD, Code 1 Library missing Library not loaded: @rpath/Cal3D.framework/Versions/A/Cal3D Referenced from: <3C1A67BA-5545-31A2-86C5-77104B0194FE> /Volumes/VOLUME/*/SBEngineLib4.framework/Versions/A/SBEngineLib4 The frameworks SBEngineLib4.framework and Cal3D.framework exist in the main app. The helper app does not contain any frameworks, but does contain dylib versions of those frameworks, which I suppose is confusing things somehow.
8
0
1k
Nov ’23