class Xcodeproj::Project
Public Class Methods
schemes(project_path)
click to toggle source
Local override to allow for user schemes.
Get list of shared and user schemes in project
@param [String] path
project path
@return [Array]
# File lib/branch_io_cli/core_ext/xcodeproj.rb, line 14 def self.schemes(project_path) base_dirs = [File.join(project_path, 'xcshareddata', 'xcschemes'), File.join(project_path, 'xcuserdata', "#{ENV['USER']}.xcuserdatad", 'xcschemes')] # Take any .xcscheme file from base_dirs schemes = base_dirs.inject([]) { |memo, dir| memo + Dir[File.join dir, '*.xcscheme'] } .map { |f| File.basename(f, '.xcscheme') } # Include any scheme defined in the xcschememanagement.plist, if it exists. base_dirs.map { |d| File.join d, 'xcschememanagement.plist' } .select { |f| File.exist? f }.each do |plist_path| plist = File.open(plist_path) { |f| ::Plist.parse_xml f } scheme_user_state = plist["SchemeUserState"] schemes += scheme_user_state.keys.map { |k| File.basename k, '.xcscheme' } end schemes.uniq! if schemes.empty? && File.exist?(project_path) # Open the project, get all targets. Add one scheme per target. project = self.open project_path schemes += project.targets.reject(&:test_target_type?).map(&:name) elsif schemes.empty? schemes << File.basename(project_path, '.xcodeproj') end schemes end