macOS app on Catalina through Xcode receives "TCC deny IOHIDDeviceOpen" - xcode

With Catalina out, I have took time to update and tried to run my app but I am facing a weird issue.
My app is monitoring key events therefore needing the new authorization to monitor inputs.
If I run through the signed bundle, I do get the warning telling me to turn it on in the system preferences which I do. It then works fine.
If I do the same running through Xcode or through Iterm2, I always have the "TCC deny IOHIDDeviceOpen". I have tried to authorize products of the build but it does not change anything.
Anyone with an idea ?

If that doesn't work, make sure your terminal program (e.g. iTerm.app) is also checked in the "Input Monitoring" permissions.

I had a similar problem. I found that removing all entries for my app from System Preferences->Security & Privacy->Input Monitoring and then re-running under Xcode worked. It is almost like Catalina recognises the app as one in the store and doesn't ask about turning support on but then sees it as a different app when it actually comes to opening devices

Related

Mac App crashed queue: com.apple.CoreLocation.0x7fc93e530920

So I am trying to make my app work on iOS and MacOS. Which to say it does run on both. However when I submitted it to Apple, they seemed to of made it crash. Due to the following
Crashed Thread: 3 Dispatch queue: com.apple.CoreLocation.0x7fc93e530920
Now I can tell it is due to CoreLocation, But I am wondering why did it not crash on my mac when I tested it (same version) 13.15.6.
Next is how do I fix this, if I can't get the error to happen again?
Encountered this too. In my case on macOS 10.15 all ran fine, but got a crash report when the application was submitted for review, where it crashed on Big Sur (macOS 11.3) with this error.
The solution (for me) is to add the key NSLocationUsageDescription to the plist in the Mac version.
See https://developer.apple.com/forums/thread/652193 and Apple doc
I could only intermittently reproduce this error, and when it happened it happened the moment I enabled Location Services in System Preferences. I guess that is the moment that CoreLocation inspects the plist, and sometimes crashes, i.e. not always.
Addition:
For macOS 11 (Big Sur) the authorisation of access to location has changed more than described above. Depending on your needs you need to ask for access to location, as described in https://developer.apple.com/documentation/corelocation/requesting_authorization_for_location_services?language=objc.
So, this is 4 possible keys and "purpose strings" for the plist, that steer the authorisation via system alerts, with the user's choice handed to you via the delegate locationManagerDidChangeAuthorization:.
Also see https://developer.apple.com/documentation/corelocation/choosing_the_location_services_authorization_to_request?language=objc
Note that location will work fine without these strings, but you will run into a rejection with the AppStore when you submit your application for review.
Also note that if your Mac has location services NOT enabled at all in
System Preferences -> Security&Privacy -> Privacy -> Location services
no system alerts will show up at all. It is assumed that if not enabled the user does not want to be bothered.

iOS9 Share Extension can not debug on Xcode

When I build share extension from Xcode for the real device, Xcode arbitrarily stop debug. But when I launch for simulator, the problem does not occur.
Environment
Xcode 7.1.1
iOS 9.1
Details
When I build share extension, Xcode shows "Finished running MobileSafari.app on iPhone", but Safari does not run. And, The square stop button is arbitrarily gray. So, I launch Safari by myself and choose my extension and post. The debug section does not show anything. Also, URL request is not sent Rails server.
This is the picture when I build the share extension for the real device.
I do not know why the real device can not launch share extension at Xcode.
If anyone know the answer about this problem, please tell me.
Typically you can debug a share extension by going to Debug -> Attach to process or PID and entering the name of your share extension. From there you can open the share extension on your device or simulator and Xcode's debugger should attach and hit breakpoints correctly. However, I've noticed that log messages do not show up when doing this, nor do values populate for variables in the debugger view.
Here's how I got the debugging to work correctly. Run the share extension scheme. When it asks you what app to run, chose 'Photos' (because that's the app your extension will operate in). The Photos app will then launch on your device and you may proceed to use your extension. The debugger in Xcode should then work as expected.
I encountered this issue as well, though unfortunately I don't know the exact solution, maybe I can offer some information that might be helpful.
I (like you, judging by your screenshot) was using Cocoapods, and Cocoapods was copying resources from the pods into the bundle of the app extension after it was code signed. If memory serves, this was interfering with the code signing in some way, and therefore preventing the app from running under the debugger.
I believe that one of the symptoms of this was that logs appeared in the mac's console (or the device's console, can't remember which) saying something about "blasting onto the device using the old skool[sic] method."
You could confirm that this is the case by removing Cocoapods from your project, or any pods that require resources to be copied after compilation. I believe that the solution was to add some kind of special build phase to the extension project to copy the bundle resources, and disabling whatever Cocoapods uses by default.
As a temporary solution, I believe that deleting your app from the device should allow you to attach the debugger once, on the run where the app is installed for the first time. You might also try deleting derived data for your project.

Permission Denied when running Mac app after upgrading to XCode 4.4

I had a working Mac application until I updated to XCode 4.4 and Mountain Lion. Now the application still compiles, but when I try to run it I get an error message.
error: failed to launch '/Users/username/James/mac/Browser/trunk/Browser/DerivedData/Browser/Build/Products/Debug/Browser.app/Contents/MacOS/Browser' -- Permission denied*
Can anybody explain why I might be getting this?
I found this on an iPhone 5 (iOS 6.0) newly set up for development. I had to manually launch the app on the phone, and it said "Are you sure you want to launch this app signed by this devloper?" Once I approved that, the "permission denied" went away and it now launches from Xcode.
Unlock the Device
Try simply unlocking your device before running on it. I was stumped by this very same issue. Upon building and running with no changes to OS, environment, code, etc., I was receiving the error.
Similar questions have been asked here and here, but were not helpful in this situation.
This is caused by an entitlement (and, presumably, having the wrong kind of certificate for it).
If you have the sandbox enabled, and try to sign with a Developer ID certificate, your application will crash on launch (as of Lion—I haven't tried this on Mountain Lion).
If you have iCloud enabled, and try to sign with a Developer ID certificate, your application will not launch at all—in Xcode, you'll get the error message in the question, and in Finder, the application will launch ever so briefly and then get SIGKILLed.
Presumably, there is a right kind of certificate with which one can sign an app in order to be able to test with a sandbox and maybe even iCloud that you can obtain if you have a Mac Developer Program membership. A Developer ID certificate is not that kind of cert.
(That solves my problem, anyway. Dennis, what kind of cert were you trying to sign with?)
Open the organizer and make sure you're mac is in developer mode.
Also check your gatekeeper settings.
The device is seeing the app as an "unauthorized app downloaded from the web" for lack of a better description. Go into Settings > Security & Privacy, and at the bottom, allow applications downloaded from Anywhere.
Throwing a few thoughts on the wall:
Are you perhaps building on an external disk? Some drives get special permissions (like the "ignore permissions" checkbox), or maybe have ACLs set in a weird way. Tried building on internal startup disk?
Are you code signing? Have you tried just turning that off, to see if there's a bug in code signing or entitlements? Not the first time a new codesign tool has a bug.
Have you tried using xcode-select and updating any command line tools that are installed to make sure they all match the version of Xcode used?
Do you have any shell script build phases or the likes that might be editing the application after it's been signed, thus breaking the signature?
Have you checked if your hard disk is full or there's a (broken?) symlink somewhere in a path, or a volume name that has been unmounted?
i am sure this is long been figured out, but I have been getting the Permission denied and it turned out I had to add my laptop to the provisioning profile. I had recently reimaged my machine and in doing so the provisioning profile was no longer valid for that machine. It worked fine until i enabled iCloud. That's when the permission denied started.
Check the organizer in XCODE, click on the devices tab and click on your machine on the left. Check to see that the UDID it shows is listed in the devices section in your mac developer portal.
The short answer is when you get this error message, there is no valid development provisioning profile in the built application.
That alone won't solve your problem! There are a number of common causes of this:
You've moved to a new machine and haven't installed the provisioning profile in Xcode. Also see below
You've moved to a new machine and it's not in developer mode OR not added to the provisioning profile
For both of these, let Xcode regenerate it, or do it yourself in the Member centre... You can validate the causes is something to do with your provisioning profile by running Console and filtering on taskgated where you can see which provisioning profile it is trying to use (it will pull the one embedded in the application first, then try to pull from any installed on the Mac).
Make sure you check in your build settings that the right one is being used for Debug builds. Simple steps that normally resolve (XCode 5)
Go to member centre and create a new development profile
Select the app and certificate
Validate that the machine you are using is in the list of machines to be included in the profile, tick the box
Generate the certificate
Download it, and drag it over the Xcode icon in the doc
Go to the Build Settings tab in your target and set the provisioning profile to the one you've just downloaded
You haven't configured your iCloud/APN/GameCenter entitlements correctly.

Cannot enable Mac OSX Lion Location Services with Safari

I just hit a frustrating problem while debugging that I am hoping that someone else has encountered...and solved. I am troubleshooting an app that uses the javascript Geolocation app on OS X Lion. I have been using Safari and everything was working fine.
After a reboot, Safari reported that access to Geolocation services was denied. In the Safari preferences, under privacy, the option to "Limit Website Access to Location Services" the setting is indeed set to "Deny without prompting".
The problem is that I cannot seem to enable this setting. According the Apple doc, you need to first enable location services for the application in the System Settings. This is under Security and Privacy -> Privacy. I have seen cases where this is empty and Safari simply doesn't show up. Finally, after another reboot, Safari.app actually showed up here. Unfortunately, after enabling Safari here, I still could not enable location services in the Safari settings. It is almost like the settings are out of sync with each other.
Any thoughts would be greatly appreciated!
I just ran into the same issue but found a solution on a support forum.
Solution 1:
Cycling "Set timezone automatically using current location" in the Date & Time > Time Zone preference pane fixed my issue. It's possible that a legacy preference left over from my Snow Leopard install was causing a problem there.
Solution 2:
For me, I had to quit the iPhone simulator to toggle the option on.
The second solution did the trick, but maybe only because I tried the first one, uh, first.

Xcode 4 Error: Error Starting Executable

I ran into problem with testing my app on iOS and Xcode when I am uploading it to my actual devices (iphone and iPad), and I'm wondering if someone knows the issue and can help me out:
Normally when I build my app on my devices, the app is installed and launched on my devices. But as I am preparing for submitting my first app I was testing around and changing the Bundle Identifier, App ID, and Development Provisions (so the issue may have something to do with it), and now, when I try to build my app on my devices, although it's installed on my devices fine, Xcode will not launch the app anymore. Instead, I got this error message:
Error Starting Executable.
Error launching remote program: No such file
or directory.
Does anyone know what the issue is? And What is this derived data folder about?
Much thanks!
I have also faced that problem. I have closed, restarted Xcode; deleted the application from device and reinstalled it again, then the problem has gone.
Running App from a Clean Slate
For me the problem did not resolve until I did the following in this order:
Delete the app from the device (Do this before trying to debug again)
Quit XCode (Don't just close the project)
Delete the app build folder (example path: /Users/myusername/Library/Developer/Xcode/DerivedData/MyProject-fhkaamuyvqhubaezinqbmxbnaufd/)
Restart XCode
Finally -- Try debugging again on the iOS device
The app build folder of step 3 refers to your app's build folder that is a child of "DerivedData". To find this you can reveal your app in finder, then backtrack until you get to "DerivedData" folder and delete the folder above that like "MyApp-crazylongweirdletters". Without this step (3), I could not debug, so this is a critical step and you must quit XCode before you do this step.
For some it appears simply restarting XCode does the trick, but not for me.
I only post this answer because the earlier answers did NOT work for me. Hopefully others banging their heads will find this and get a sigh of relief. :)
Notes:
The issue started happening for me when I modified the bundle id of the app.
My code signing is and was correct. My provisioning profile was the "Team Provisioning Profile" which should work for any app id (default for "iPhone Developer" automatic profile selector).
I was doing a DEBUG build (not release / distribution).
You cant debug (start from Xcode) an application signed with a distribution profile if I remember well... And then you get such messages, gdb failling to attach to process.
I finally found my error!
I was playing around with my info.plist file, and I changed the Executable Name and Bundle and Bundle Display name! As soon as I changed those back to the Defaults (EXECUTABLE_NAME, PRODUCT_NAME, PRODUCT_NAME respectively) it worked perfectly.
Delete the app from the device (tap-and-hold then delete) and try again.
For me, none of those worked. Same error, but different solution.
My problem was cause by me accidently changing the "Deployment Target" (ios version) to a version higher than what was on the phone I tried to run the code on.
The fix was simple - drop the deployment target to below or equal to the ios software version on my phone :)
I got the same error by not having my code signing correct.
Go to your project > Targets > Build Settings > Check code signing for debug state.
I stumbled upon this as a solution to another issue whch was a warning when trying to build an app on a new 4.3.5 device.
If i set the profile to distribution I do not get a warning message when building the app, but the debugger will attach to the device.
If i set the code signing to the distribution profile, i get no warnings in the build process, but the debugger will not attach. So the answer above about being signing based seems to be correct. This might also only be an issue on newer 4.3.5 devices with xcode
Product -> Clean in the menubar
This error some times happen due to incomplete "Restore" or "Sync" process of your device which keeps the .app files locked up.
What I did I had to jailbreak my device to go find the app under /User/Applications/XXXXX-XXXX-XXX/ and phisically delete the .app
For one of the apps it worked and for other one I realized it just does not run GDB automatically so the error message is totally misleading, so I set the GDB to manual and it worked and did not give me that error, but of course I have to run the app manually for the debug session to start.
It also may have required some other stuff that I did before like checking the provision profile, but this was the last step that made it work.
Before this I tried all the solutions did not work for me, and obviously simply deleting the app by holding down your finger on the screen did not work, as it removed the icon but all the files were still there. ( Since it was a development app not a downloaded App Store app )
had same problem,
quit the XCode...delete app from device...run the program again..
i solved that way..one of my friends had to restart the device.
I have the same problem. I solved it by changing the project's directory name and then launching the app again.
I had this problem on a recently restored device where my in-development apps had not been reinstalled—they were showing up on Springboard as "Waiting" to be downloaded from the App Store. Deleting the app from Springboard fixed the problem.
I've faced this issue since yesterday on two different devices, both iOS 4.x. Deleting the DerivedData folder, deleting the app, restarting the Xcode, and cleaning the code did NOT work. Repeating all the steps, in addition to rebooting the device fixed it for me.
Here I am posting an update to the issue. Might be helpful for someone with the same problem. I have Xcode 4.4 and launched it on a device with iOS 5.0 . If Xcode doesnt have the 5.0 simulators

Resources