Tugulab Blog.

How to use Xcode to write Swift code on a remote Linux machine

I have to write a lot of Swift code targeted to Linux only environment. It’s a robotic app, where no monitor is contemplated. I could…
author avatar

clacla

I have to write a lot of Swift code targeted to Linux only environment. It’s a robotic app, where no monitor is contemplated. I could connect remotely to it and code with emacs or vim. But I am so used to Xcode… So I decided to just keep using it, remotely.

The concept is simple. I am going to mount the Linux machine HDD as remote drive (via ssh) on my Mac.

This means being able to to use Xcode on my Mac, with all the nice tools I have there. I will only have to open the terminal on the Linux machine to compile and run.

Step 1: Install SshFS

On your Mac install OSXFuse and SshFS. You can download them both from https://osxfuse.github.io/

Step 2: Create a mount directory

Somewhere on your Mac create a folder which will be where your remote drive will be mounted (where you will find the remote drive’s files).

mkdir ~/Desktop/RemoteDrive

Step 3: Mount the remote drive

You will have to mount the remote drive at every system startup.

sshfs USER@MACHINE-HOSTNAME:/home/USER/ ~/Desktop/RemoteDrive

Step 4: Code

Now you will be able to open the directory from Finder and use it as USB stick. Just open it, create your Xcode project and develop as usual.

Step 5: Unmount the drive

When you’re done, you should unmount the drive securely.

fusermount -u ~/Desktop/RemoteDrive

Simple and convenient. Yay!