Class: DeployGate::Xcode::Analyze

Inherits:
Object
  • Object
show all
Defined in:
lib/deploygate/xcode/analyze.rb

Defined Under Namespace

Classes: BundleIdentifierDifferentError

Constant Summary collapse

BASE_WORK_DIR_NAME =
'project.xcworkspace'
DEFAULT_BUILD_CONFIGURATION =
'Release'
PROVISIONING_STYLE_AUTOMATIC =
'Automatic'
PROVISIONING_STYLE_MANUAL =
'Manual'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workspaces, build_configuration = nil, target_scheme = nil) ⇒ DeployGate::Xcode::Analyze

Parameters:

  • workspaces (Array)
  • build_configuration (String) (defaults to: nil)
  • target_scheme (String) (defaults to: nil)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/deploygate/xcode/analyze.rb', line 19

def initialize(workspaces, build_configuration = nil, target_scheme = nil)
  @workspaces = workspaces
  @build_configuration = build_configuration || DEFAULT_BUILD_CONFIGURATION
  @scheme_workspace = find_scheme_workspace(workspaces)
  @build_workspace = find_build_workspace(workspaces)
  @xcodeproj = File.dirname(@scheme_workspace)

  config = FastlaneCore::Configuration.create(Gym::Options.available_options, { project: @xcodeproj })
  Gym.config = config
  @project = FastlaneCore::Project.new(config)

  if @project.schemes.length > 1 && target_scheme && @project.schemes.include?(target_scheme)
    @project.options[:scheme] = target_scheme
  else
    @project.select_scheme
  end
  @scheme = @project.options[:scheme]
end

Instance Attribute Details

#build_workspaceObject (readonly)

Returns the value of attribute build_workspace.



4
5
6
# File 'lib/deploygate/xcode/analyze.rb', line 4

def build_workspace
  @build_workspace
end

#schemeObject (readonly)

Returns the value of attribute scheme.



4
5
6
# File 'lib/deploygate/xcode/analyze.rb', line 4

def scheme
  @scheme
end

#scheme_workspaceObject (readonly)

Returns the value of attribute scheme_workspace.



4
5
6
# File 'lib/deploygate/xcode/analyze.rb', line 4

def scheme_workspace
  @scheme_workspace
end

#workspacesObject (readonly)

Returns the value of attribute workspaces.



4
5
6
# File 'lib/deploygate/xcode/analyze.rb', line 4

def workspaces
  @workspaces
end

#xcodeprojObject (readonly)

Returns the value of attribute xcodeproj.



4
5
6
# File 'lib/deploygate/xcode/analyze.rb', line 4

def xcodeproj
  @xcodeproj
end

Instance Method Details

#code_sign_identityObject



47
48
49
50
51
52
53
54
# File 'lib/deploygate/xcode/analyze.rb', line 47

def code_sign_identity
  identity = nil
  resolve_build_configuration do |build_configuration, target|
    identity = build_configuration.resolve_build_setting("CODE_SIGN_IDENTITY", target)
  end

  identity
end

#code_sign_styleObject



38
39
40
41
42
43
44
45
# File 'lib/deploygate/xcode/analyze.rb', line 38

def code_sign_style
  style = nil
  resolve_build_configuration do |build_configuration, target|
    style = build_configuration.resolve_build_setting("CODE_SIGN_STYLE", target)
  end

  style
end

#developer_teamObject



67
68
69
70
71
72
73
74
# File 'lib/deploygate/xcode/analyze.rb', line 67

def developer_team
  team = nil
  resolve_build_configuration do |build_configuration, target|
    team = build_configuration.resolve_build_setting("DEVELOPMENT_TEAM", target)
  end

  team
end

#project_profile_infoObject



76
77
78
79
80
81
82
# File 'lib/deploygate/xcode/analyze.rb', line 76

def project_profile_info
  gym = Gym::CodeSigningMapping.new(project: @project)

  {
      provisioningProfiles: gym.detect_project_profile_mapping
  }
end

#target_bundle_identifierString

TODO: Need to support UDID additions for watchOS and App Extension

Returns:

  • (String)


58
59
60
61
62
63
64
65
# File 'lib/deploygate/xcode/analyze.rb', line 58

def target_bundle_identifier
  bundle_identifier = nil
  resolve_build_configuration do |build_configuration, target|
    bundle_identifier = build_configuration.resolve_build_setting("PRODUCT_BUNDLE_IDENTIFIER", target)
  end

  bundle_identifier
end

#target_provisioning_profileObject



84
85
86
87
88
89
# File 'lib/deploygate/xcode/analyze.rb', line 84

def target_provisioning_profile
  gym = Gym::CodeSigningMapping.new(project: @project)
  bundle_id = target_bundle_identifier

  Xcode::Export.provisioning_profile(bundle_id, nil, developer_team, gym.merge_profile_mapping[bundle_id.to_sym])
end