digimarktech / Xport

A swift script that builds your Swift project on a remote machine.
6 stars 1 forks source link

Xport

Swift 5.1 SPM

A swift script that builds your Swift project on a remote machine.

For example, let's say you want to write some swift code on your raspberry pi, with this script you can write your code in Xcode and use this script to sync your project to your raspberry pi! This project was inspired by the Swish script.

Prerequisites

Setup SSH Authentication

In order for this script to work properly, you need to setup your SSH authentication between your mac and your remote machine. How do you know if this is already setup? Perform the following steps:

  1. Launch your terminal and enter the following ssh <username>@<hostname>.
  2. If you were able to connect without entering a password, you are ready to proceed!
  3. If you were prompted to enter a password, you will need to go through the process of setting up Passwordless SSH Access. We need to do this because when we are executing this script via Xcode, there is no means to respond to a prompt while the script is executing. This article walks through the process of setting up the connection between your mac and remote machine.

Installation with Mint

$ mint install digimarktech/Xport

Configure Xcode

Once you have installed Xport, it can be used to transfer the code you have written in Xcode to your remote machine or Raspberry Pi. Below are the steps necessary to get everything working.

  1. Create External Build System.

Create External Build System

Default External Build Tool Configuration

  1. Add your swift pacakage. This is the code that you have written to execute on the raspberry pi. If you have already created a package locally, you can simply drag it in. Otherwise, you can import it via its hosted github URL or create a new package altogether.

  2. Provide the values for your External Build Tool Configuration. Here are the fields:

    • Build Tool: This is the path where Xport was installed. If you used Mint to install it, you can use the following path /usr/local/bin/xport
    • Arguments: These are the arguments used by the Xport script to execute it. The first argument represents the username used on your Raspberry Pi. The default username is pi. The second argument is the hostname or ip-address used to connect to your pi.
    • Directory: Here is where you specify the path of the swift package that you are copying over.

Custom External Build Tool Configuration

Closeup External Build Tool Configuration

  1. CMD + B to build and execute the script. If you want to see a log of the script use the Report Navigator tab in Xcode.

Author

Marc Aupont, @digimarktech

License

Xport is available under the MIT license. See the LICENSE file for more info.