Class: CocoapodsEntitlementsStatistics::ProjectInfo

Inherits:
Object
  • Object
show all
Includes:
Xcodeproj::Project::Object
Defined in:
lib/cocoapods-entitlements-statistics/project_info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProjectInfo

Returns a new instance of ProjectInfo.



13
14
15
# File 'lib/cocoapods-entitlements-statistics/project_info.rb', line 13

def initialize 
    load_xcodeproj
end

Instance Attribute Details

#load_successObject (readonly)

Returns the value of attribute load_success.



10
11
12
# File 'lib/cocoapods-entitlements-statistics/project_info.rb', line 10

def load_success
  @load_success
end

#projectObject (readonly)

Returns the value of attribute project.



9
10
11
# File 'lib/cocoapods-entitlements-statistics/project_info.rb', line 9

def project
  @project
end

#tagret_nameObject (readonly)

Returns the value of attribute tagret_name.



11
12
13
# File 'lib/cocoapods-entitlements-statistics/project_info.rb', line 11

def tagret_name
  @tagret_name
end

Instance Method Details

#entitlements_plistObject



41
42
43
44
45
# File 'lib/cocoapods-entitlements-statistics/project_info.rb', line 41

def entitlements_plist
    entitlements_files = Pathname.glob("**/#{@tagret_name}.entitlements").reject { |path| !path.to_s.start_with?("#{@tagret_name}/") }
    entitlements_path =  entitlements_files.length > 0 ? entitlements_files.first.realpath : "" 
    entitlements_path
end

#info_plistObject



35
36
37
38
39
# File 'lib/cocoapods-entitlements-statistics/project_info.rb', line 35

def info_plist
    info_plists = Pathname.glob('**/info.plist').reject { |path| !path.to_s.start_with?("#{@tagret_name}/") }
    info_plist_path =  info_plists.length > 0 ? info_plists.first.realpath : "" 
    info_plist_path
end

#load_xcodeprojObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cocoapods-entitlements-statistics/project_info.rb', line 21

def load_xcodeproj
    xcodeprojects = Pathname.glob('**/*.xcodeproj').reject { |path| path.to_s.start_with?('Pods/') }        
    if xcodeprojects.length == 1
        @tagret_name = Pathname(xcodeprojects.first).basename('.xcodeproj')
        @project = Xcodeproj::Project.open(xcodeprojects.first.realpath)
        @load_success = true
    else
        @load_success = false
        error_message = xcodeprojects.length > 1 ? 'found too many' : "couldn't find any"
        projects = xcodeprojects.map(&:basename).join(' ')
        Pod::UI.notice 'CocoaPods-Keys ' + error_message + ' Xcode projects (' + projects + '). Please give a name for this project.'        
    end
end

#load_xcodeproj_success?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/cocoapods-entitlements-statistics/project_info.rb', line 17

def load_xcodeproj_success?
    return @load_success
end

#marketing_versionObject



57
58
59
60
61
# File 'lib/cocoapods-entitlements-statistics/project_info.rb', line 57

def marketing_version
    return nil unless !project_release_config.nil?
    marketing_version = project_release_config.build_settings["MARKETING_VERSION"] 
    marketing_version
end

#product_bundle_identifierObject



63
64
65
66
67
# File 'lib/cocoapods-entitlements-statistics/project_info.rb', line 63

def product_bundle_identifier
    return nil unless !project_release_config.nil?
    product_bundle_identifier = project_release_config.build_settings["PRODUCT_BUNDLE_IDENTIFIER"] 
    product_bundle_identifier
end

#project_release_configObject



47
48
49
50
51
52
53
54
55
# File 'lib/cocoapods-entitlements-statistics/project_info.rb', line 47

def project_release_config
    return @release_configurations unless @release_configurations.nil?
    @project.targets[0].build_configurations.each do |config|
        if config.name == 'Release'
            @release_configurations = config
        end
    end
    @release_configurations
end

#system_capabilitiesObject



69
70
71
72
73
74
75
76
77
78
# File 'lib/cocoapods-entitlements-statistics/project_info.rb', line 69

def system_capabilities
    target_attr_hash = @project.root_object.attributes["TargetAttributes"]
    system_capabilities = Hash.new
    target_attr_hash.each do |_,value|
        if value.class == Hash && value.keys.include?("SystemCapabilities")
            system_capabilities = value["SystemCapabilities"]    
        end
    end
    system_capabilities
end