user1898712
user1898712

Reputation: 368

Is there a way to share Xcode templates across a team?

At work, we've been moving towards a VIPER based architecture, so I have written an Xcode template for creating and instantiating all the required files which works perfectly for what we need.

I have pasted it ~/Library/Developer/Xcode/Templates, and it works and shows up fine, however I've been asked to look into if it was possible to have it synced across the team instead of having to email it to everyone whenever there is a change, or reuploading to Confluence and having everyone redownload and reinstall it. Now, I've looked online, but I am unable to see anything of much help about syncing them across team members, so I just thought I'd ask if you guys know of a way?

Thanks a million guys

Upvotes: 2

Views: 559

Answers (1)

Rafael Machado
Rafael Machado

Reputation: 655

I have the same thing on my project and all I did was to add the template files on the source control (into a separated folder) and write a shell script to install/uninstall the templates:

Note that it uses symlink so any updates will propagate.

#!/usr/bin/env bash
set -eo pipefail

# Default the folder name to "Project Name".
folderName="Project name that will show under Xcode Menu"
scriptPath="$( cd "$(dirname "$0")" ; pwd -P )"
xcodeTemplateDirectory=~/Library/Developer/Xcode/Templates/File\ Templates/
linkName="$xcodeTemplateDirectory"/"$folderName"

if [ $1 == "install" ]; then
    # Create the install directory if it does not exist.
    if [ ! -d "$xcodeTemplateDirectory" ]; then
        mkdir -p "$xcodeTemplateDirectory"
    fi

    rm -rf "$linkName"
    ln -s "$scriptPath"/"$folderName" "$xcodeTemplateDirectory"
fi

if [ $1 == "uninstall" ]; then
    rm -rf "$linkName"
fi

Upvotes: 5

Related Questions