Any way for a sandboxed OS X app to intercept keystrokes? - xcode

So I've used Dave Delong's brilliant code here to intercept keystrokes in OS X without my app needing to be in focus, unfortunately my app crashes when I try to sandbox it with the message 'deny hid-control' in the console.
A little bit of digging turns up that as of a year ago this wasn't possible, but has anything changed since then? Or does this mean that my app can't go in the Mac App Store since it's dependent on being able to intercept keystrokes? Is there an entitlement that I'm just missing out on here?

Related

What is calling requestWhenInUseAuthorization?

I am working on a react-native app. I send it to Testflight. Apple says it's missing NSLocationAlwaysUsageDescription. However, I don't see where is my app asking for location data? The app doesn't show a prompt for it. I looked at the code, and nowhere is it actually calling requestAlwaysAuthorization nor requestWhenInUseAuthorization.
How can I find out what is calling requestAlwaysAuthorization or requestWhenInUseAuthorization? Does XCode allow to have some breakpoint for those functions?
Thank you,
Slackware

Find out which app launched my cocoa app

I have been searching all around for a way to check which app did launch my cocoa app.
It seems I cannot use NSWorkspaceDidDectivateApplicationNotification because it starts tracking after the app was launched. Do someone know how to do this? The app in question is a status bar app, not sure if that makes any difference.

Obtaining OS X app store receipts on test builds

Been trying tonight to obtain a receipt for my app. However, I've been unsuccessful. Here's the steps I've done:
Code signed with developer cert
Made sure minimum version in the info.plist is 10.7
Checked for the presence of the receipt file and called exit(173) if not found
Built from XCode 4.2
Added a new version of the app and some in-app metadata in itunesconnect. The app status is now waiting for a new binary.
I've then done clean, build, right clicked on the app in XCode's project view and opened it in finder to launch it, hopefully failing validation and pulling a receipt back from the store.
However, this never seems to happen (don't get asked for any itunes login etc) and the app terminates immediately.
I've also gone through an entire build/archive/create installer type process as well but that didn't pop up the login either.
Am I missing something obvious?
Thanks!
I've finally got it working. In case anyone else has a similar problem, the real help for me was finding out about console.app. In running this I could see my app didn't appear to be signed.
I deleted all the certificates etc and re-installed new ones. Seems it HAS to be the Mac 3rd party developer. Nothing else seemed to work.

Can Apps Made in Applescript Editor Be Submitted to the Mac App Store?

Can you submit apps made in AppleScript editor to the Mac App Store?
Well, if they're made with AppleScript Studio (-> with Xcode), there is no reason to get rejected, I'd think...
Take a look at this. It doesn't look like they're disallowing apps like that...

NSWindow not Activating

I create a window in a helper tool that runs in the background (it's not an app bundle with a .nib and Info.plist, but a plain executable). When -makeKeyAndOrderFront: is called, the window is displayed but it does not "pop" out like an active window.
Can this be fixed?
Regards,
Erik
You should wrap the helper tool as a regular .app bundle with at least Info.plist. Then the problem goes away. A GUI app in OS X needs to have an Info.plist to receive events correctly.
The way a GUI app misbehaved if not in an app bundle has never been clear to me. If I remember correctly, it changed over time, depending on OS X's versions. I think it behaved worse in previous versions of OS X. For example, the window is shown but I couldn't click any UI inside it.
Many people who compiled a program in a cross-platform toolkit faced this problem, see e.g. this discussion here in the WxWidgets wiki. Apparently, OS X doesn't mark a program not within an .app bundle as a foreground-able app, which causes your problem. You can use TransformProcessType from your binary not inside an .app bundle to make a foreground-able app to solve your problem, but that's not a documented/intended usage of this function.
So, just wrap it in an .app bundle.
Update:
This "foreground-able-ness" is controlled by the activationPolicy of an app, see this doc on NSApplication. Found the info on this post on Cocoa with love.

Resources