Class: Xcodeproj::Project
- Inherits:
-
Object
- Object
- Xcodeproj::Project
- Defined in:
- lib/branch_io_cli/core_ext/xcodeproj.rb
Defined Under Namespace
Modules: Object
Class Method Summary collapse
-
.schemes(project_path) ⇒ Array
Local override to allow for user schemes.
Class Method Details
.schemes(project_path) ⇒ Array
Local override to allow for user schemes.
Get list of shared and user schemes in project
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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 |