Category Archives: macOS

How to use Xcode for C and C++ development

Not only is Xcode an excellent IDE for iOS and macOS apps in both Swift and Objective-C; it does just as fine a job for regular C and C++ code. This includes all the features we know and love, such as code completion, version control, and all the rest of it.

Let’s see how to use Xcode 8.3 for C and C++ development.

Continue reading How to use Xcode for C and C++ development

How to fix “can’t log into YouTube from Safari” on macOS

Something rather strange happened to me today: Safari 10 on macOS Sierra refused to let me login to YouTube. All it did was constantly refresh the page in an endless loop, or just display the front page of YouTube. I cleared the caches, reset the history, but no trick seemed to solve the problem.

When I dug deeper into the Preferences, I found something under Privacy that finally fixed it. Let me share with you what worked on my system.

  • head over to Safari – Preferences
  • select the Privacy tab
  • you’ll see a window like this one:

  • select Manage Website Data
  • after a few moments you’ll see a LONG list of websites that have saved cookies on your machine over time
  • in the top right corner, search for YouTube
  • you’ll see something like this:

  • select the YouTube.com entry and hit Remove, followed by Done
  • now surf back to YouTube and login – this time it’ll work

What we’ve just removed were not just cookies, but also HTML local storage data, as well as cache data specific to the YouTube website. I guess cached stuff can get outdated, or not properly deleted when we close our browser in a hurry.

The principle should work for other websites too, should they give you trouble. If you’re sick and tired of any website saving data to your system, consider switching to the “Always Block” option seen in the first screen shot.

 

How to mount and unmount drives in macOS and OS X from the command line

Unmounting external drives on a Mac is usually done quick and simple by either dragging drive icon to the trash, or by using the eject symbol in a Finder window. Mounting usually happens automatically when a new drive is inserted into a USB port or SD card slot.

However, there is a way to do this via the command line, of which I am a big fan. Fire up a Terminal session and see how to do it.

Listing available drives

To see what’s currently attached to your Mac, let’s use the diskutil command, followed by the word list. You’ll see output like this:

Attached drives are listed with their physical locations on the left (i.e. /dev/disk0, /dev/disk1, etc), as well as with their respective partitions if available on the right (like disk0s1, disk1s2, etc). Make a mental note of the latter: you’ll see that we have a physical disk (like disk0), on which several partitions may have been created. It is those partitions we’ll mount and unmount, NOT the physical drive.

Unmounting an attached hard drive

On my system I have two internal hard disks (disk0 and disk1), and one external USB drive (disk2). Let’s unmount that USB drive now:

Note how we use the unmount command. We need to specify the location of the partition with its full path (i.e. /dev/disk2s1).

Mounting an attached hard drive

To mount the drive again, without having to take it out and plugging it in again, I can issue this command:

What’s the difference between the Logitech M325 and the M325c

The Logitech M325 and M325c are both wireless USB mice. Their design appears to be identical (except for the many different colourful variations of course), and their prices vary from anything between $12 and $60 – depending the layout and seller. Even the packaging is identical.

So what’s the difference between these two models? Is it precision?¬†Is it the build quality? Is it the year of production? Is it something else?

Actually no, the two mice are absolutely identical and both work with Windows, macOS and Linux. The only difference is in the wireless receiver that Logitech give you with each model.

The difference is the wireless receiver

The M325 comes with a Logitech Unifying Receiver. You can tell by the little “sunshine” logo on the side. This type of receiver allows us to use the Logitech Unifying Software to operate several devices over a single receiver (say a mouse and a keyboard). It’s a little clunky to setup more than one device, but it certainly saves valuable USB slots on your machine.

Note that for this to work, all decides must be Logitech unifying devices, and all must display that little sunshine logo.

The M325c on the other hand does NOT come with a unifying receiver, and instead comes with a standard USB receiver. Only this one device will work with said receiver. As you can imagine, the receiver does not bear the unifying logo on the side. Therefore you may find the M325c a little cheaper than the M325.

Note however that the M325c mouse itself IS a unifying device, and it DOES bear the unifying logo on the underside. Hence you can use the M325c mouse with another unifying receiver just fine.

So there you have it – that’s the big secret difference between these two mice. I have both, and I couldn’t tell the difference at first. The mice are identical, just the USB receiver is a little different. Just in case this question was driving you crazy too ūüôā

How to fix problems with Logitech Unifying Receivers

screen-shot-2016-11-04-at-17-12-10I’ve recently bought a new Logitech K360 keyboard for my HP Z600 workstation. I also had a Logitech M325 mouse, both of which came with Unifying USB receivers. I could plug both receivers in, and both devices would work great.

However, I heard good things about these little receivers and wanted to¬†free up a USB port, and thought I’d connect both devices to the same receiver. Apparently you can connect up to 6 devices to one receiver and store any spare ones inside the mouse or keyboard. Being an all-efficient belt-and-braces kinda guy, I tried my luck.

Turns out it was relatively easy to pair both devices to the same receiver, thanks to a small piece of software that can be found here, along with instructions on how to use it:

It all worked fine on my Windows 10 machine, until I wanted to use the mouse (not the keyboard) with my Mac. I know, it’s exotic, and perhaps I should have just bought another mouse. But there’s only so much space on my desk, and I really don’t need more clutter in front of me for just an occasional switch.

I regretted pairing both devices to the same receiver and wished I hadn’t done that, for this very eventuality. So now I had to figure out how to UN-pair both devices again and put them back to how things used to be (before I started messing with them). Continue reading How to fix problems with Logitech Unifying Receivers

How to launch a Mac App with Command Line Parameters from the Dock

In this episode I’ll show you how to launch a Mac App from the Command Line, so that we can pass parameters. I’ll also explain how to wrap up such a command into your own app and add an icon to it, so that you can launch it from the dock with a single click.

This can be useful if you need to convince Google Chrome or any other app to launch with certain parameters and modify its behaviour somehow. In my example I’m using Blender, and I’m using a startup parameter to change its default render engine upon launch. The same principles apply to any app you need to launch with startup parameters.

The process is as follows:

  • find out the full path of the app you want to launch
  • try launching your app from the command line
  • now add parameters to the end of the launch command
  • create an Automator App
  • change its icon from from the generic Otto Icon to your desired app’s icon
  • drag your new launcher app into the dock

I’ll explain all the gory details in this video.

Enjoy!

Catch this episode on my WP Guru Podcast:

How to kill a Mac App via the Command Line

Sometimes it’s’ necessary for us to force-close an app on our Mac if it’s no longer responding to our commands. Usually we’d do that by pressing CMD+OPT+ESCAPE, which brings up a handy window from which we can choose a troublesome app.

Screen Shot 2016-08-23 at 16.10.14

But sometimes, this keyboard combination won’t work – for example, if we’re dealing with a remote Mac to which no physical keyboard is attached. In such cases, we can choose to force-close an app via the command line. Let me show you how to do that.

Connect to your Mac via SSH using a Terminal Session and find out what apps are currently running. We’ll so that with the top command:

Using the -u switch tells top to list the app with the highest CPU usage over time first. The command will display a list of running processes, much like this:

Screen Shot 2016-08-23 at 16.15.04

Take a look at the list and make a note of the troublesome app. In my case it’s Carrara, using 165% of my CPUs resources. By definition impossible, but let’s not worry about that. The important thing is this app’s PID (Process ID). Write it down or take a screenshot, we’ll need it in amount to kill the app (mine is 5964).

Press CTRL+C to stop top and return to the command line. Now issue the following command, replacing 5964 with your own PID:

And that’s it: the troublesome app has been force-closed and should vacate your system sharpishly. For more information on both top and kill, check out their respective man pages on your Mac.

How to make Notes App sync properly on iOS

ios9-notes-app-iconHave you ever wondered why some notes seemingly sync just fine between your iOS devices, but others do not? Wether a note is not fully updated, or you find a duplicate entry in the list, it can be an exercise in frustration.

But fret not, it doesn’t have to be! This is not a bug in the Notes app; it’s the way we’re using it.

Let me show yo what you can do to avoid such problems, and how they can happen in the first place.

Why do we sometimes get random duplicate notes?

This has to do with the way the app stores data in the cloud. Notes saves your content only when you close the note, or when you switch away from it. Your note is not saved while you’re typing it.

Likewise, iOS¬†can only “save over” the current note if you’re not actively editing it. Leaving it open, even if you’re only looking at it, means your note is locked for edits from other devices.

When you make a change on device A, and the same note is opened and edited on device B, then iCloud cannot save your changes to the current note. Hence it creates a duplicate entry. This is a safety mechanism so that your changes are saved rather than lost, and you can decide¬†which copy you’d like to keep when you’re done.

How to avoid sync trouble on iPhone

So on iPhone, the solution is simple: always return to the list view of all your notes. Do not leave a note open. That way, another device can edit its contents without trouble.

How to avoid sync trouble on iPad and Mac?

On the iPad as well as your Mac, things are a little different due to the nature of the Split View Controller. It displays both the list of your notes, as well as a note next to it. Even when you hold your iPad in portrait mode and cannot see the list view, one note is ALWAYS open and displayed, and therefore¬†cannot be edited by another device. That’s usually when and why iOS (or macOS) saves a duplicate.

To avoid this situation, make sure you switch to a note¬†that you’re unlikely to edit from another device.¬†Perhaps create¬†a “dummy note” without content and switch to it when you’re finished with the Notes app.

Remember you can look at a note even if it’s open on another device – it’s just that when editing an open note, trouble keeps in.

Hope this helps ūüôā

How to switch off Developer Beta Downloads on Mac OS X

A while ago I thought it would be fun to run the OS X Developer Betas on my MacBook Pro. That was before El Captain was released. Once the buzz had died down I grew a little tired of the bi-weekly point release downloads that took about an hour to install.

So how can we tell a Developer Beta Mac to become a “normal” non-beta Mac again?

While forum posts suggest that it’s an impossible feat, it’s actually no trouble at all. Simply head over to System Preferences – App Store and find a button that reads “your computer is set to receive pre-release Software Update seeds”.

mac-beta-versions

Click it and an overlay window is shown, allowing you to “not show pre-release updates” anymore. Be warned however that when you do this, the option to bring up this dialogue disappears – so once switched off, there’s no going back easily (unless you install another beta from scratch, like you did when you first obtained yours).

Note that when you switch this feature off, your Mac will remain on the beta you have currently installed, until a new release comes out and replaces it. This option will not remove beta files from your machine, nor will it turn your beta system¬†into a non-beta system instantly: you’ll have to wait for the next release and use the regular update option for that.

You can always check what’s currently installed by heading over to the Apple Icon and select About This Mac.

How to connect your Xbox 360 Controller to Dolphin for Mac

DolphinI’ve been experimenting with the marvellous Dolphin Emulator recently. It’s an open source project that allows us to play Nintendo Gamecube and Wii games on modern hardware. Dolphin is available for Windows, OS X and Linux.

I have a wireless Xbox 360 controller for Windows at my disposal, but the only Windows hardware I have is the first generation Surface Pro. While the controller connects without issues, the Surface¬†sadly just isn’t¬†fast enough to run Dolphin.

My more powerful hardware is Mac based, and Dolphin runs great on my Mac Mini. But I had no idea how to connect my Xbox controller to it.

Turns out it’s actually a breeze to setup: let me show you how it worked for me on OS X El Capitan.

Continue reading How to connect your Xbox 360 Controller to Dolphin for Mac