Class: Mysigner::Build::ErrorAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/mysigner/build/error_analyzer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(build_errors) ⇒ ErrorAnalyzer

Returns a new instance of ErrorAnalyzer.



8
9
10
11
12
# File 'lib/mysigner/build/error_analyzer.rb', line 8

def initialize(build_errors)
  @build_errors = build_errors || []
  @issues = []
  analyze!
end

Instance Attribute Details

#issuesObject (readonly)

Returns the value of attribute issues.



6
7
8
# File 'lib/mysigner/build/error_analyzer.rb', line 6

def issues
  @issues
end

Instance Method Details

#any_issues?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/mysigner/build/error_analyzer.rb', line 14

def any_issues?
  @issues.any?
end

#format_suggestionsObject

Returns formatted suggestions for CLI output



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/mysigner/build/error_analyzer.rb', line 19

def format_suggestions
  return nil unless any_issues?

  lines = []
  lines << ''
  lines << ('=' * 70)
  lines << '  💡 SUGGESTIONS: How to fix these build errors'
  lines << ('=' * 70)
  lines << ''

  # Group issues by type for cleaner output
  profile_issues = @issues.select { |i| i[:type] == :profile_capability }
  cert_issues = @issues.select { |i| i[:type] == :certificate_mismatch }
  identifier_issues = @issues.select { |i| i[:type] == :missing_identifier }

  # Profile capability issues
  if profile_issues.any?
    lines << '  📋 PROVISIONING PROFILE ISSUES'
    lines << ''

    # Group by profile name
    by_profile = profile_issues.group_by { |i| i[:profile_name] }
    by_profile.each do |profile_name, issues|
      capabilities = issues.map { |i| i[:capability] }.compact.uniq
      lines << "  Profile: \"#{profile_name}\""
      lines << "  Missing capabilities: #{capabilities.join(', ')}"
      lines << ''
    end

    lines << '  How to fix:'
    lines << '    1. Go to Apple Developer Portal → Certificates, Identifiers & Profiles'
    lines << "    2. Select 'Identifiers' and find your Bundle ID"
    lines << '    3. Enable the missing capabilities (App Groups, Apple Pay, etc.)'
    lines << '    4. If adding App Groups or Merchant IDs, make sure to select the specific identifiers'
    lines << "    5. Go to 'Profiles' and regenerate the affected provisioning profiles"
    lines << '    6. Download new profiles: mysigner sync ios && mysigner profile download <ID>'
    lines << '    7. Install profiles to: ~/Library/MobileDevice/Provisioning Profiles/'
    lines << ''
  end

  # Missing specific identifiers (App Group ID, Merchant ID)
  if identifier_issues.any?
    lines << '  🔗 MISSING IDENTIFIERS'
    lines << ''

    identifier_issues.each do |issue|
      lines << "  Profile: \"#{issue[:profile_name]}\""
      lines << "  Missing: #{issue[:identifier_type]} - #{issue[:identifier]}"
      lines << ''
    end

    lines << '  How to fix:'
    lines << '    1. Go to Apple Developer Portal → Identifiers'
    lines << '    2. Find your Bundle ID and edit it'
    lines << '    3. Under the capability, add/select the specific identifier:'
    lines << '       • For App Groups: select your group.* identifier'
    lines << '       • For Apple Pay: select your merchant.* identifier'
    lines << '    4. Regenerate the provisioning profile'
    lines << ''
  end

  # Certificate mismatch
  if cert_issues.any?
    lines << '  🔐 CERTIFICATE MISMATCH'
    lines << ''
    lines << '  Your app and its extensions are signed with different certificates.'
    lines << ''
    lines << '  How to fix:'
    lines << '    1. Open your Xcode project'
    lines << '    2. For EACH target (main app AND extensions):'
    lines << '       • Select the target → Signing & Capabilities'
    lines << '       • Ensure all targets use the same signing identity:'
    lines << "         - For App Store: 'Apple Distribution'"
    lines << "         - For Development: 'Apple Development'"
    lines << '    3. Make sure all targets use matching profile types:'
    lines << '       • App Store profiles for App Store builds'
    lines << '       • Development profiles for development builds'
    lines << ''
    lines << '  Quick fix for App Store builds:'
    lines << '    In project.pbxproj, ensure Release configuration has:'
    lines << '      CODE_SIGN_IDENTITY = "Apple Distribution"'
    lines << '      PROVISIONING_PROFILE_SPECIFIER = "YourApp App Store"'
    lines << ''
  end

  lines << '  📚 More help:'
  lines << "    • Run 'mysigner doctor' to check your setup"
  lines << "    • Run 'mysigner profiles' to list available profiles"
  lines << '    • Check My Signer dashboard for Bundle ID capabilities'
  lines << ''

  lines.join("\n")
end