Sha256: 24b9c61e74d7bb27bbeef71016a2ebe284d1f699ea4d1f26d8c33acc756ece05

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

# fix-xcode
#   Mark Rickert <mjar81@gmail.com>
 
# Symlinks all your old SDKs to Xcode.app every time it is updated.
# Create a directory called /SDKs and run this script.
#
# Each time you upgrade Xcode, run fix-xcode.

# NOTE FROM JAMON: run `cs symlink_xcode_sdks` instead.
 
module Clearsight
  class Xcode
    def initialize(args)
      @args = args
    end

    def run
      display_banner
      
      require 'FileUtils'
    
      # Find all the SDKs in Xcode.app that aren't symlinks.
      Dir.glob("#{xcode_path}/Platforms/*.platform/Developer/SDKs/*.sdk") do |sdk|
        basename = sdk.split('/').last
        if File.symlink?(sdk)
          puts "#{basename} is already symlinked... skipping.\n"
          next
        end
     
        puts "Processing: #{basename}\n"
     
        # Remove the old version if it exists
        destination = "#{sdk_path}/#{basename}"
        if File.directory?(destination)
          puts " - Removing existing SDK: #{destination}.\n"
          FileUtils.rm_rf destination
        end
     
        puts " - Moving the Xcode version into place in #{sdk_path}.\n"
        FileUtils.mv sdk, sdk_path
      end
     
      Dir.glob("#{sdk_path}/*.sdk") do |sdk|
        sdk_name = sdk.split("/").last
        sdk_platform = sdk_name.match(/[a-zA-Z]{3,}/)[0]
     
        ln_dest = "#{xcode_path}/Platforms/#{sdk_platform}.platform/Developer/SDKs/#{sdk_name}"
        puts " - Symlinking #{sdk_platform}.\n"
     
        FileUtils.ln_sf sdk, ln_dest
      end
     
      puts "\nDone! Your SDKs now live in #{sdk_path} and are symlinked properly into the Xcode.app.\n\n"
    end
     
    def xcode_path
      `xcode-select --print-path`.chomp
    end
     
    def sdk_path
      "/SDKs"
    end
 
    def display_banner
      # Nice little banner
      puts "-" * 29
      puts "Running Fixing Xcode.app SDK Paths."
      puts "-" * 29
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clearsight-1.1.0 lib/clearsight/xcode.rb