How to Resume a windowless app (LSUIElement) in OS X Lion - cocoa

In OS X Lion apps automatically resume when the user logs in. My app is set to be a windowless agent without an icon in the Dock (LSUIElement is set to YES in Info.plist) and it doesn't resume when I restart my machine.
According to Apple documentation all applications get the Resume behaviour by default and the developer doesn't need to do anything special to enable it. Are LSUIElement apps a special case? Is there anything that needs to be done to enable them to Resume?

From my own testing, LSUIElement applications are not resumed. So yes, they appear to be a special case – you'd need to ask Apple why this is the case, but setting this value appears to forcibly disable resume.

Related

Can't Debug System Pref Pane under 10.15

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.

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 tell Apple that my Cocoa app is not ready for high resolution?

Apple says that either user or OS X may decide to launch a Cocoa app in magnified mode instead of framework-scaled mode:
All apps that are not Cocoa apps run in magnified mode. However, a Cocoa app can also run in magnified mode if:
The user sets the option to open the app in low resolution (see Figure 1-7).
The app is known to have significant issues when running in framework-scaled mode, so the system makes an exception and instead
runs the app in magnified mode.
(see link)
But how the app developer can launch it magnified? Or, how to force OS X to do it?
You can set the property NSHighResolutionCapable to false in your Info.plist.
In XCode, that property is called High Resolution Capable.

Creating feature in mac app to override the users security setting

I'm a newbie at mac osx development. I would like to know if there's any way to override the mac desktop security settings to allow an application - which is not registered in the Mac App Store, to be installed?
The setting should come from the app that I'm trying to install. That means, whenever I install the app to any mac computer, regardless of its security settings as the following,
Allow applications downloaded from:
Mac App Store
Mac App Store and identified developers
Anywhere
The app should set the settings to Anywhere, allowing it to be installed.
Any help would be very much appreciated.
Launch System Preferences from the Apple menu.
Choose “Security & Privacy” and then click the “General” tab, followed by clicking the lock icon in the corner to unlock the settings.
Look for “Allow applications downloaded from:” and choose “Anywhere”.
Accept the security warning and allow.
Note that you should be careful and aware that now the job of protecting the system from malicious apps belongs to you instead of the OS.
Right click the (app) icon and click 'open' in contextual menu - no need to disable the OS security.
This is not possible. The existence of that setting is intended to protect users from malicious executables. If there were a way for any arbitrary executable to override that setting, what protection would it offer? Malicious executables would simply change the setting to "Anywhere" like you suggest, bypassing the security features of Mac OS X.
You need to sign your application using a Mac Developer certificate, which you can obtain from Apple. That will mark your app as built by an "identified developer" and it will launch just fine without changing any settings.
Control Click the app icon to override this security feature. This is a one off, you don't have to change your settings, you can do it per-app.
There is one other way...
All you have to do to do it manually is to open up Terminal, cd into the .app application, cd into the Contents folder, then cd into the MacOS folder, then type ./YourAppNameHere and execute by typing Enter.

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