Module: HMap::PBXHelper
- Defined in:
- lib/hmap/xc/pbx_helper.rb
Class Method Summary collapse
- .build_as_framework?(target) ⇒ Boolean
- .defines_module?(target) ⇒ Boolean
- .get_groups(xct) ⇒ Object
- .group_paths(xct) ⇒ Object
- .project_references(project) ⇒ Object
- .projects(*p_paths) ⇒ Object
- .uses_swift?(target) ⇒ Boolean
Class Method Details
.build_as_framework?(target) ⇒ Boolean
27 28 29 |
# File 'lib/hmap/xc/pbx_helper.rb', line 27 def self.build_as_framework?(target) target.symbol_type == :framework if target.respond_to?(:symbol_type) end |
.defines_module?(target) ⇒ Boolean
31 32 33 34 35 36 37 38 39 |
# File 'lib/hmap/xc/pbx_helper.rb', line 31 def self.defines_module?(target) return true if build_as_framework?(target) bus = target.build_configuration_list.build_configurations.map do |bu| bu.instance_variable_get('@simple_attributes_hash')['buildSettings'] || {} end bus.any? { |s| s['DEFINES_MODULE'] == 'YES' } end |
.get_groups(xct) ⇒ Object
3 4 5 6 7 |
# File 'lib/hmap/xc/pbx_helper.rb', line 3 def self.get_groups(xct) groups = xct.referrers.select { |e| e.is_a?(Constants::PBXGroup) } || [] groups += groups.flat_map { |g| get_groups(g) } groups.compact.reverse end |
.group_paths(xct) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/hmap/xc/pbx_helper.rb', line 9 def self.group_paths(xct) ps = get_groups(xct).map do |g| s_hash = g.instance_variable_get('@simple_attributes_hash') s_hash['path'] unless s_hash.nil? end.compact File.join(*ps) end |
.project_references(project) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/hmap/xc/pbx_helper.rb', line 56 def self.project_references(project) return if project.nil? p_path = File.dirname(project.path) project.root_object.project_references.map do |sp| ff = sp[:project_ref] path = ff.instance_variable_get('@simple_attributes_hash')['path'] || '' full_path = File.join(p_path, path) Xcodeproj::Project.open(full_path) end end |
.projects(*p_paths) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/hmap/xc/pbx_helper.rb', line 41 def self.projects(*p_paths) return if p_paths.empty? p_paths.flat_map do |pj| project = Xcodeproj::Project.open(pj) p_path = File.dirname(project.path) project.root_object.project_references.map do |sp| ff = sp[:project_ref] path = ff.instance_variable_get('@simple_attributes_hash')['path'] || '' full_path = File.join(p_path, path) Xcodeproj::Project.open(full_path) end << project end end |
.uses_swift?(target) ⇒ Boolean
17 18 19 20 21 22 23 24 25 |
# File 'lib/hmap/xc/pbx_helper.rb', line 17 def self.uses_swift?(target) source_files = target.build_phases.flat_map do |phase| phase.files if phase.is_a?(Constants::PBXSourcesBuildPhase) end.compact source_files.any? do |file| path = file.file_ref.instance_variable_get('@simple_attributes_hash')['path'] || '' File.extname(path) == '.swift' end end |