-
-
Save mbernson/1c5ad83fe404018129ddd1b9f75545e9 to your computer and use it in GitHub Desktop.
X - Opens the Xcode workspace/project or Swift package in your current working directory using Xcode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
XCODE_PATH = File.expand_path(File.join(`xcode-select -p`.chomp, '../..')) | |
def open_cmd(pattern) | |
files = Dir.glob(pattern) | |
`open -a "#{XCODE_PATH}" "#{files.first}"` and exit if files.count == 1 | |
end | |
open_cmd '*.xcworkspace' | |
open_cmd '*.xcodeproj' | |
open_cmd '*.playground' | |
open_cmd 'ios/*.xcworkspace' # React Native folder structure | |
open_cmd '.' if File.exists?('Package.swift') | |
puts 'No Xcode workspaces, projects, playgrounds, or packages found.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment