Skip to content

Instantly share code, notes, and snippets.

@vyshane
Created November 4, 2019 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vyshane/e144c502e2006761949741b29d9c6fa2 to your computer and use it in GitHub Desktop.
Save vyshane/e144c502e2006761949741b29d9c6fa2 to your computer and use it in GitHub Desktop.
Quickly generate a new Xcode project using Swift Package Manager, and open the project's main.swift in the Xcode editor
#!/bin/sh
#
# Quickly generate a new Xcode project using Swift Package Manager,
# and open the project's main.swift in the Xcode editor.
pwd=$(pwd)
mkdir $1
cd $1
swift package init
rm ./Sources/$1/$1.swift
echo "print(\"Hello world\")" > ./Sources/$1/main.swift
swift package generate-xcodeproj
open -F -a Xcode ./$1.xcodeproj
sleep 1
osascript \
-e 'tell application "Xcode"' \
-e "open POSIX file \"$pwd/$1/Sources/$1/main.swift\"" \
-e 'end tell'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment