Class: Clearsight::Xcode
- Inherits:
-
Object
- Object
- Clearsight::Xcode
- Defined in:
- lib/clearsight/xcode.rb
Instance Method Summary collapse
- #display_banner ⇒ Object
-
#initialize(args) ⇒ Xcode
constructor
A new instance of Xcode.
- #run ⇒ Object
- #run_fix ⇒ Object
- #run_remove_sdk(version) ⇒ Object
- #sdk_path ⇒ Object
- #xcode_path ⇒ Object
Constructor Details
#initialize(args) ⇒ Xcode
Returns a new instance of Xcode.
13 14 15 |
# File 'lib/clearsight/xcode.rb', line 13 def initialize(args) @args = args end |
Instance Method Details
#display_banner ⇒ Object
92 93 94 95 96 |
# File 'lib/clearsight/xcode.rb', line 92 def puts "-" * 29 puts "Running Fixing Xcode.app SDK Paths." puts "-" * 29 end |
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/clearsight/xcode.rb', line 17 def run if @args.count == 2 if @args[0] == "remove" abort "Please pass another parameter specifying what SDK to remove." unless @args[1] run_remove_sdk "#{@args[1]}" end else run_fix end end |
#run_fix ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/clearsight/xcode.rb', line 28 def run_fix 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 |
#run_remove_sdk(version) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/clearsight/xcode.rb', line 75 def run_remove_sdk(version) # Remove the iOS SDK from xcode. version = version.to_s << ".0" if version.to_s.length == 1 puts "-" * 29 puts "Removing the iOS #{version} SDK from the Xcode Bundle." puts "-" * 29 removing = "#{xcode_path}/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS#{version}.sdk" if File.exist? removing FileUtils.rm_rf removing puts "SDK successfully removed. Please restart Xcode." else puts "Couldn't find that SDK at path: #{removing}" end end |
#sdk_path ⇒ Object
71 72 73 |
# File 'lib/clearsight/xcode.rb', line 71 def sdk_path "/SDKs" end |
#xcode_path ⇒ Object
67 68 69 |
# File 'lib/clearsight/xcode.rb', line 67 def xcode_path `xcode-select --print-path`.chomp end |