Can't Debug System Pref Pane under 10.15 - xcode

In Xcode 11.1, I have disabled SIP and set System Preferences as the debug executable. When I run my build, System Preferences loads, but when I open my prefPane, no breakpoints are ever hit.
This worked fine in 10.11 to 10.14.
With SIP enabled, I get a "can't attach to System Preferences" error as expected. But I am at a loss as to why the break points are never hit as they have been with earlier macOS versions.
I have a background process that is used by the prefPane and I am able to debug that just fine, but trying to debug the prefPane while it is running in System Preferences doesn't work anymore.
Has anyone got a solution?
Could this be because the prefPane is actually run in "legacyLoader" which is sub-launched by System Preferences?

I needed to specify "legacyLoader" as the executable and not launch it automatically, but instead wait for it to be launched.
I still don't know how to do this without disabling SIP since there is no way to tell System Preferences to open an alternate (self-signed) copy of legacyLoader instead of the default system one.

Related

Xcode 7.3 wont attach to simulator to debug

So I upgraded to Xcode 7.3.1 and now my Xcode will build, and deploy my apps (yes every app, even a brand new blank one) to the simulator but the app never launches on the simulator and the debugger never attaches, Xcode just hangs and has to be force quit. I've completely wiped out Xcode and all simulators and re-installed to no avail. I've scoured Stack Overflow and Google trying every piece of advice and still no luck. Anyone anywhere have any idea how to solve this issue? If I downgrade to 7.2.1 I'm able to debug in the simulator just fine.
Let me know if you need more information.
My Apps run just fine on the simulator, and if I try to attach the debugger to a running app it wont and Xcode hangs in the attempt, when attempting to attach this way at least Xcode doesn't have to be force quit.
FYI, I can debug on a device this is only a simulator issue.
I had this same issue, and tried fixing my projects and reinstalled Xcode twice before I was able to get Simulator to crash and give me an error report that called out Cylance. Luckily I have access to administer our Cylance portal, so I was able to work through the issue to narrow down the problem.
Symptoms:
When running an app from Xcode, the Simulator launches but the application does not launch within the Simulator
Trying to stop the application from within Xcode does not work, and generates no messages
Trying to re-run the application from within Xcode generates the following message: ‘An instance of “APPLICATION NAME” is already running. Choose “Stop” to terminate and launch a new instance.’ But pressing Stop does nothing.
Xcode will not quit, and eventually the user must Force Quit to exit Xcode
Within the OS X console, the following messages are displayed:
6/3/16 7:35:38.000 PM kernel[0]: AMFI: com.apple.dt.ins(pid 2239) - [deny-mmap] main process is a platform binary, but mapped executable file is not: /Library/Application Support/Cylance/Desktop/CyMemDef.dylib
6/3/16 7:35:38.000 PM kernel[0]: AMFI: com.apple.dt.ins(pid 2239) - [deny-mmap] mapped file has team identifier XXXX: /Library/Application Support/Cylance/Desktop/CyMemDef.dylib
Resolution:
The problem is caused by Memory Protection being turned on within the policy assigned to the Mac within the Cylance portal.
To resolve the issue, place the Mac into a zone/policy that does not have Memory Protection turned on. Auto Quarantine and Protection Settings can be left on.
During my testing, I was not able to come up with a list of exclusions that allowed me to leave Memory Protection on, so I ended up disabling it completely.

Network Link Conditioner Freezes and Wont Start

I have downloaded Hardware IO Tools for Xcode 7.1 from the Apple Developer site and installed it by opening the DMG and then double clicking Network Link Conditioner.prefPane.
I then go to my System Preferences and can see the Network Link Conditioner is there. I can go into it but as soon as I click the switch to turn it on the whole System Preferences freezes up. Also, I noticed that my keyboard seems to stop working...somewhat. I can still do cmd + spacebar and then type in there to search my system but I can't type into the URL field on safari for example.
My Mac: OS X Yosemite v10.10.5
My Xcode: v7.2.1 (7C1002)
By the way, I downloaded the 7.1 version of the Hardware IO Tools as they only have a 7.1 or 7.3 version, there doesn't seem to be a version for 7.2. Maybe that is the issue? I can't currently upgrade to 7.3 as that requires me to upgrade OS X to 10.11 but our company policy does not currently allow for that.
Anybody know how I could fix this?
Could this be caused by the fact that I am not an admin on my machine?
My suspicion was correct, it wouldn't start as it needs to be run as an admin.
If you're not an admin, you need to run a command such as
sudo /Applications/System\ Preferences.app/Contents/MacOS/System\ Preferences
or in my case I had to get an admin in the office to do:
su - <admin_username> /Applications/System\ Preferences.app/Contents/MacOS/System\ Preferences
These commands will open the System Preferences as an admin user.
I have noticed that when he Network Link Condition is open in the System Preferences, my keyboard stops working in certain areas still. For example, I couldn't type in here whilst the panel was open (even with it turned off) but as soon as I closed the panel I could type again. I will possibly open another question at a later dare about this though.

Accessibility disabled for app in Mac OS X 10.9

After upgrading to Mac OS X 10.9 and running my app (which executes various AppleScripts as part of its execution) I get a dialog that the app has to be specifically enabled via the System Preferences Security/Privacy screen. So I do this and the app then functions properly.
However, when I recompile and build the app, it will no longer execute the AppleScripts and does not show the dialog. When I look in the System Preferences Security/Privacy I see that my app is still listed there but has been disabled (i.e. checkbox reset).
BY trial and error, I have found the following:
If you change the Bundle Version string in the apps info.plist and rebuild the app even without making any other changes such as code, etc this will happen; it will be disabled from accessibility.
If you make all kinds of changes to the app (code, resources, etc) but do not change the Bundle Version string in info.plist, it will still be allowed to have accessibility access.
My question is: is there a way to circumvent disabling after rebuilding?

How to get UIAutomation, Simulator, and Xcode Debugger Running at the same time?

Can anyone point me to the documentation on how to make Instruments run UIAutomation scripts and start the iPhone application with the debugger running in the Simulator?
Constraints:
I only have iPhone 3g hardware to test with and debugging against the device with UIAutomation just does not reliably work.
Normally the test scripts are just ran to make sure everything passes, but now a weird bug exists that only gets triggered when the UIAutomation script runs (which is a good thing). The bug cannot be duplicated in manual operation.
There does not seem to be anyway to attach Instruments UIAutomation to a process already running in the simulator. There is no selection.
Starting Instruments UIAutomation directly does not cause it to start with the debugger.
I would assume that there is some command line magic that can be configured in Instruments edit active target (environment variable, arguments, working directory) to make this happen, but I've not found the magic paragraph.
Thanks,
Neil
This stumped me for a while, too -- especially since when the Automation Instrument is selected, the Instruments application explicitly says Current instrumentation disallows attach. The key is to realize that an app running in the simulator is visible in your host system as its own process, so attaching directly from GDB works well. These instructions are for XCode 4.2 (4C199) on Snow Leopard 10.6.8:
Start your test in Instruments however you normally do (either directly from Instruments, or from Xcode 4's Product -> Profile. Pick whatever templates and scripts to get your automated test underway.
Back in Xcode, under the menu Product -> Attach to Process, you should see your iOS app, listed by name, alongside all the other applications on your host computer. In fact, it very likely will be listed first, under the section header Likely Targets.
If it's not visible, choose View -> Debug Area -> Show Debug Area so you can see the gdb console.
Hit the pause button (Product -> Debug -> Pause) to interrupt your program. Set breakpoints, inspect, as usual.
Then next question is: why can't I see my normal NSLog() output in the debugger console?
Your app already bound itself to the console output streams, so the simplest place to look for its output is in OS X Console app (/Applications/Utilities/Console.app) and look under DATABASE SEARCHES -> All Messages.

Mac OS X Services: enable without user interaction?

I wrote a simple Mac 'Service' for Finder, that executes a command.
Basically: this adds a ContextMenu in Finder.
If I right-click a file in Finder, a menu item pops up. If the user clicks it, it executes my script. (kind of like 'Send to Bluetooth device, ...')
In OS X Leopard (10.5) and earlier, all services are enabled.
In 10.6 (Snow Leopard), Apple changed the behavior, services now have preferences, and can be enabled or disabled by the user. (which is a good thing)
However, I wrote the service, but there seems to be no way to enable it automatically (in our installer).
I tried doing it with Applescript, going to the System Preferences and ticking the checkbox that way, but it requires some accessibility features to be turned on. (off by default).
Is it possible? If so, how?
Or do I need something else to provide Context Menus in Finder.
I tracked File changes on my filesystem while changing the preferences and discovered there was a plist file:
~/Library/Prefrences/pbs.plist
which contains what I need.
If I edit that manually, it seems to work. So, problem solved :)

Resources