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, xcodeproj_path = 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
# File 'lib/deploygate/xcode/analyze.rb', line 19

def initialize(workspaces, build_configuration = nil, target_scheme = nil, xcodeproj_path = nil)
  @workspaces = workspaces
  @build_configuration = build_configuration || DEFAULT_BUILD_CONFIGURATION
  @build_workspace = find_build_workspace(workspaces)
  @xcodeproj = xcodeproj_path.presence || find_xcodeproj(workspaces)

  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

#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



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

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



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

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



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

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



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

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)


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

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



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

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