class RXCode::Workspace
Constants
- WORKSPACE_EXTENSION
WORKSPACE DISCOVERY ========================================================================================¶ ↑
Attributes
Public Class Methods
is_workspace_at_path?(path)
click to toggle source
# File lib/rxcode/workspace.rb, line 17 def self.is_workspace_at_path?(path) File.extname(path) == WORKSPACE_EXTENSION && File.directory?(path) end
new(workspace_path)
click to toggle source
# File lib/rxcode/workspace.rb, line 5 def initialize(workspace_path) unless self.class.is_workspace_at_path?(workspace_path) raise "#{workspace_path.inspect} is not a valid XCode workspace path" end @path = workspace_path end
Public Instance Methods
build_location()
click to toggle source
# File lib/rxcode/workspace.rb, line 108 def build_location Dir[File.join(derived_data_location, '*/info.plist')].each do |info_plist_path| build_location_data = Plist::parse_xml(info_plist_path) workspace_path = build_location_data['WorkspacePath'] if workspace_path == self.path || (project_dependent? && workspace_path == enclosing_product_path) return File.dirname(info_plist_path) end end nil end
built_products_dir()
click to toggle source
# File lib/rxcode/workspace.rb, line 121 def built_products_dir if build_root = build_location File.join(build_root, "Build/Products") end end
contents_path()
click to toggle source
derived_data_location()
click to toggle source
BUILD LOCATION =============================================================================================¶ ↑
# File lib/rxcode/workspace.rb, line 90 def derived_data_location derived_data_style = value_for_setting('IDEWorkspaceUserSettings_DerivedDataLocationStyle') custom_derived_data_location = value_for_setting('IDEWorkspaceUserSettings_DerivedDataCustomLocation') if derived_data_style == 2 # 2 is the code for 'Workspace-relative path' File.expand_path(custom_derived_data_location, self.root) else prefs = RXCode.xcode_preferences if prefs.derived_data_location_is_relative_to_workspace? File.expand_path(prefs.derived_data_location, self.root) else prefs.derived_data_location end end end
enclosing_product_path()
click to toggle source
# File lib/rxcode/workspace.rb, line 51 def enclosing_product_path File.dirname(path) if project_dependent? end
name()
click to toggle source
# File lib/rxcode/workspace.rb, line 41 def name File.basename(path, '.xcworkspace') end
project_dependent?()
click to toggle source
project_independent?()
click to toggle source
# File lib/rxcode/workspace.rb, line 55 def project_independent? !project_dependent? end
project_paths()
click to toggle source
# File lib/rxcode/workspace.rb, line 63 def project_paths require 'nokogiri' if project_dependent? [ File.dirname(path) ] elsif File.exist?(contents_path) document = Nokogiri::XML(File.read(contents_path)) document.xpath('/Workspace/FileRef').collect { |element| resolve_file_reference(element['location']) if element['location'] =~ /\.xcodeproj$/ }.compact else [] end end
projects()
click to toggle source
# File lib/rxcode/workspace.rb, line 59 def projects @projects ||= project_paths.map { |project_path| Project.new(project_path, :workspace => self) } end
resolve_file_reference(location)
click to toggle source
# File lib/rxcode/workspace.rb, line 33 def resolve_file_reference(location) if location =~ /^(?:container|group):(.*)$/ File.expand_path("../#{$1}", path) else location end end
root()
click to toggle source
# File lib/rxcode/workspace.rb, line 25 def root if project_dependent? File.expand_path('../..', path) else File.dirname(path) end end
settings_file_for_user(user_name)
click to toggle source
# File lib/rxcode/workspace.rb, line 150 def settings_file_for_user(user_name) File.join(user_data_directory_for_user(user_name), "WorkspaceSettings.xcsettings") end
settings_for_user(user_name)
click to toggle source
# File lib/rxcode/workspace.rb, line 154 def settings_for_user(user_name) settings_file = settings_file_for_user(user_name) if File.file?(settings_file) Plist::parse_xml(settings_file) else {} end end
user_data_directory_for_user(user_name)
click to toggle source
# File lib/rxcode/workspace.rb, line 146 def user_data_directory_for_user(user_name) File.join(path, "xcuserdata", "#{user_name}.xcuserdatad") end
user_settings()
click to toggle source
# File lib/rxcode/workspace.rb, line 163 def user_settings settings_for_user(ENV['USER']) end
value_for_setting(setting_name)
click to toggle source
# File lib/rxcode/workspace.rb, line 167 def value_for_setting(setting_name) user_settings[setting_name] || shared_settings[setting_name] end