Users are in for a bad experience with the Mojave app restrictions

With the Mojave update to macOS, Apple has introduced a couple of restrictions on what your apps are allowed to do. If you are the developer of apps that are downloadable outside of the Apple App Store you need to be wary of these restrictions.

The two new restrictions I will be talking about in this article is the Automation and Full Disk Access restrictions. The new restrictions on Automation will prevent apps from scripting other apps through AppleScript and the Full Disk Access will prevent apps from manipulating files owned by other apps.

In these scary times of the World Wide Web it is probably a very good idea for Apple to add these restrictions to the OS. But I do think that Apple has done it in a not very user friendly way, especially when it comes to Full Disk Access.

Full Disk Access

Unless the user has specifically given Full Disk Access to your app, it is not allowed to change files not owned by itself. If you try you will get an error telling you that it is not allowed.

Screenshot 2018-10-18 at 22.16.56

That is a good thing! You should not be allowed to mess up things for everybody else.

The problem is that Apple has not given us an API to prompt the user to give access. There is not even an API for checking if we have access to a file.

The user is in for a bad experience because they have to manually give Full Disk Access to our app in the Security & Privacy panel.

Screenshot 2018-10-18 at 22.24.09

That is absolutely terrible! Most users I have met have no clue on how and where to find the .app file or the security center. You have to write a thorough user guide to help the users and who reads user guides these days?

Fortunately, Apple has done a better job when it comes to Automation.

Automation

Mojave will stop you if your app tries to access another app through AppleScript. This too is a good thing. Imagine the mess a malicious app could do!

Fortunately, Apple has done better when it comes to usability than they did with Full Disk Access. All you as a developer need to do is add the key NSAppleEventsUsageDescription to your app’s plist.info file with a description.

Screenshot 2018-11-09 at 19.11.23

The first time the app tries to script another application, the runtime will automatically prompt the user for permissions.

Screenshot 2018-11-09 at 19.14.52

Of course, you have to make sure that your app gracefully fails if the user denies permissions.

If the user grants the permission your app is added to the Automation tab under Privacy & Security settings.

Screenshot 2018-11-09 at 19.17.56

Note how there is no way to add an app manually to the Automation tab. Shame on you, Apple!

You can clear the entire list from the Terminal:

tccutil reset AppleEvents

Hardened build

Beware that if you need a hardened build for notarisation, the good people of Apple have in all their glory decided to completely ignore the NSAppleEventsUsageDescription property unless you also specifically enable Apple Events in the Capabilities tab in Xcode.

Screenshot 2018-11-09 at 19.26.35

Conclusion

While I think it is a good idea to restrict permissions for macOS apps installed outside of the App Store, I do believe that the user experience is terrible. How many users know the consequences of granting permissions to full disk access or to Apple Events? Nobody knows what those terms mean. Apple is also making it very hard for developers to properly instruct the app users.

Working Effectively with Windows as a (non-)Developer

There are lots of great articles on how to know your tools to be a better programmer. I thought I’d chip in give and give 10 tricks on how to be a good Windows user and hence also a better developer. These tricks are very simple and have been part of Windows for a while (some even before Windows 10) and yet they are unknown to many Windows users.

There has always been an ongoing war on whether macOS or Windows is the better. I am a user of both and I love and hate both of them (although I am more effective on Windows). I hope the following tricks can be of help to Mac users who sometimes need to use Windows, and also of help to existing Windows users who perhaps can learn a new trick or two.

I would be happy to hear about what tricks you use to make life easier so please join in on the comments.

These tricks all apply to Windows 10.

1. Show file extensions in Explorer

For some reason the default setting in Windows is to hide all known file extensions.

There should be a law against that.

So, the first and most important trick is to get Windows to show all known file extensions in Windows File Explorer.

For example, I had a client that stubbornly claimed that double-clicking the MyApp.exe file would only show some gibberish in Notepad. After a while it occurred to me that the standard .NET configuration file MyApp.exe.config file showed as MyApp.exe on the client’s machine because the file extension .exe was hidden.

So, the first thing you do on a new Windows box is to open Explorer, click Options -> Change folder and search options. Go to the View tab and clear the check box for “Hide extensions for known folder options”.

2. Use the Run command

The second most important trick is the “Run” command in Windows. Mac has its very useful Spotlight Search, and Windows has its equally useful Search feature in the Start menu, but I find the Run command much more useful.

The Run command allows you to run one-line command line instructions. You get to the Run command by typing Windows+R on the keyboard. That will open up a small dialog to the lower left where you can type any command.

The Run command gives you a very fast way to start apps or open web pages. The following are a few common examples:

  • calc (starts Calculator)
  • notepad (starts Notepad)
  • excel (starts Excel)
  • winword (starts Word)
  • mstsc (starts remote desktop terminal)
  • inetmgr (starts the IIS Manager)
  • cmd /f:on (starts a command prompt with tab completion)
  • www.dev.to (opens the default browser and goes to dev.to)
  • http://dev.to (same as above)
  • %programfiles% (opens Explorer and goes to the program files folder, usually C:\Program Files)
  • control panel (opens the Control Panel)
  • services.msc (opens the services panel)

3. Use Windows Search

I already mentioned it above, and I will mention it again. Few people realize that Windows has built-in search similar to Mac’s Spotlight search.

Just press the Windows button on the keyboard to open the start menu and start typing immediately. This will search for apps and files and the search results show immediately on the start menu. It evens searches tags in images and content in pdf files.

I actually never understood the hatred for Windows 8 and 8.1 and the large start menu. To me it was just a big friendly searchable start screen. But I guess I was the only person in the world that liked it.

Unfortunately, Windows Search does not search the internet.

4. Use the Power menu

The power menu is shown when you press Windows+X on the keyboard. The power menu gives you immediate access to the most important stuff such as settings, event viewer, network connections, and the command prompt.

Speaking of the command prompt, if you prefer to use PowerShell, you can replace the command prompt with PowerShell on the power menu. Right-click your taskbar and choose taskbar settings. Then turn on the setting “Replace Command Prompt with Windows PowerShell in the menu when I right-click the start button or press Windows-key+X” (now that’s a long sentence).

5. Easily start new instances of an app

As you know you can start an app by clicking its icon on the taskbar.

Now, if you want to start more instances of the same app, you hold left-Shift and click the icon.

And if you want to start an app as administrator, you hold left-Ctrl and left-Shift and click the icon.

You should pin command prompt and PowerShell to the taskbar so that you can start and administrator prompt just by left-ctrl + left-shift + clicking it.

You can also start an app that has been pinned to the taskbar simply by holding the Windows key and pressing the number for the app. So, for example, Edge is the third app om my taskbar, so I can start it simply by pressing Windows+3 on my keyboard.


(I apologize for my hopeless, childish handwriting)

6. Use the Snipping Tool

This tool is very helpful for capturing screen shots and I use it all the time, for example for writing blogs. Just search for “Snipping” in your start menu to use it.

You may find difficulties in snipping a screen shot of menus and such but of course I have a trick for that:

  1. Start the Snipping Tool and click New.
  2. Press the Esc button on your keyboard.
  3. Open whatever menu you wish to capture.
  4. Press Ctrl+Print Screen on your keyboard.
  5. Now you can draw a rectangle of with the Snipping Tool to capture the menu.

7. Copy the path of a file

Left-shift and right-click a file to reveal a number of extra items on the context menu. One of them is “Copy as path” which will copy the file’s full path to your clipboard. Neat.

8. Use shortcuts

Some common shortcuts:

  • Windows+E: Start File Explorer
  • Windows+D: Show the desktop
  • Windows+I: Open settings
  • Windows+Ctrl+D: Create new virtual desktop
  • Windows+Ctrl+right arrow: Go to next virtual desktop
  • Windows+Ctrl+left arrow: Go to previous virtual desktop
  • Windows+Ctrl+F4: Close current virtual desktop
  • Windows+arrow up: Maximize window
  • Windows+arrow down: Minimize window
  • Windows+arrow left or arrow right: Snap window to the left or right border

By the way, if you grab a window by the title bar and shake it with the mouse, all other windows on the desktop will be minimized.

9. Keep your Windows desktop clean

With Windows search and the run command, who needs icons on the desktop?

Add shortcuts to the taskbar for the apps that you use the most for easy access and leave the desktop clean and uncluttered.

10. Easily create connection strings

The last trick for now is for developers. I find it incredibly useful and I have not met a single person who knows about it since I learned it many years ago. So I decided to include it here as a small bonus for those who made it this far.

I can never remember the syntax or the property names for connection strings when connecting to a database from code on Windows which is why this trick has helped me for years. A long time ago at a conference (in Boston I believe) I saw the presenter creating a file on his desktop with the extension .udl. Then he double-clicked the file which opened a small dialog where he entered SQL Server instance name and selected authentication and database name.

After dismissing the dialog he opened Notepad (by pressing Windows+R and entering “notepad”) and he then dragged the .udl file to Notepad, revealing a beautiful connection string. How about that!

By the way, the .udl trick won’t work unless you have followed the very first trick on this list: “Show file extensions in Explorer”.

I hope you find above useful 😀