Class: Gym::ErrorHandler

Inherits:
Object
  • Object
show all
Defined in:
gym/lib/gym/error_handler.rb

Overview

This classes methods are called when something goes wrong in the building process

Class Method Summary collapse

Class Method Details

.handle_build_error(output) ⇒ Object

This method should raise an exception in any case, as the return code indicated a failed build

Parameters:

  • The (String)

    output of the errored build



12
13
14
15
16
17
18
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
# File 'gym/lib/gym/error_handler.rb', line 12

def handle_build_error(output)
  # The order of the handling below is important
  case output
  when /Your build settings specify a provisioning profile with the UUID/
    print("Invalid code signing settings")
    print("Your project defines a provisioning profile which doesn't exist on your local machine")
    print("You can use sigh (https://docs.fastlane.tools/actions/sigh/) to download and install the provisioning profile")
    print("Follow this guide: https://docs.fastlane.tools/codesigning/GettingStarted/")
  when /Provisioning profile does not match bundle identifier/
    print("Invalid code signing settings")
    print("Your project defines a provisioning profile that doesn't match the bundle identifier of your app")
    print("Make sure you use the correct provisioning profile for this app")
    print("Take a look at the output above for more information")
    print("You can follow this guide: https://docs.fastlane.tools/codesigning/GettingStarted/")
  when /provisioning profiles matching the bundle identifier .(.*)./ # the . around the (.*) are for the strange "
    print("You don't have the provisioning profile for '#{$1}' installed on the local machine")
    print("Make sure you have the profile on this computer and it's properly installed")
    print("You can use sigh (https://docs.fastlane.tools/actions/sigh/) to download and install the provisioning profile")
    print("Follow this guide: https://docs.fastlane.tools/codesigning/GettingStarted/")
  when /matching the bundle identifier .(.*). were found/ # the . around the (.*) are for the strange "
    print("You don't have a provisioning profile for the bundle identifier '#{$1}' installed on the local machine")
    print("Make sure you have the profile on this computer and it's properly installed")
    print("You can use sigh (https://docs.fastlane.tools/actions/sigh/) to download and install the provisioning profile")
    print("Follow this guide: https://docs.fastlane.tools/codesigning/GettingStarted/")

  # Insert more code signing specific errors here
  when /code signing is required/
    print("Your project settings define invalid code signing settings")
    print("To generate an ipa file you need to enable code signing for your project")
    print("Additionally make sure you have a code signing identity set")
    print("Follow this guide: https://docs.fastlane.tools/codesigning/GettingStarted/")
  when /US\-ASCII/
    print("Your shell environment is not correctly configured")
    print("Instead of UTF-8 your shell uses US-ASCII")
    print("Please add the following to your '~/.bashrc':")
    print("")
    print("       export LANG=en_US.UTF-8")
    print("       export LANGUAGE=en_US.UTF-8")
    print("       export LC_ALL=en_US.UTF-8")
    print("")
    print("You'll have to restart your shell session after updating the file.")
    print("If you are using zshell or another shell, make sure to edit the correct bash file.")
    print("For more information visit this stackoverflow answer:")
    print("https://stackoverflow.com/a/17031697/445598")
  end
  print_xcode_path_instructions
  print_xcode_version
  print_full_log_path
  print_environment_information
  print_build_error_instructions

  # This error is rather common and should be below the other (a little noisy) output
  case output
  when /Code signing is required for product/
    print("Seems like Xcode is not happy with the code signing setup")
    print("Please make sure to check out the raw `xcodebuild` output")
    UI.important(Gym::BuildCommandGenerator.xcodebuild_log_path)
    print("The very bottom of the file will tell you the raw Xcode error message")
    print("indicating on why the code signing step failed")
  end

  UI.build_failure!("Error building the application - see the log above", error_info: output)
end

.handle_empty_archiveObject



115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'gym/lib/gym/error_handler.rb', line 115

def handle_empty_archive
  print("The generated archive is invalid, this can have various reasons:")
  print("Usually it's caused by the `Skip Install` option in Xcode, set it to `NO`")
  print("For more information visit https://developer.apple.com/library/ios/technotes/tn2215/_index.html")
  print("Also, make sure to have a valid code signing identity and provisioning profile installed")
  print("Follow this guide to setup code signing https://docs.fastlane.tools/codesigning/GettingStarted/")
  print("If your intention was only to export an ipa be sure to provide a valid archive at the archive path.")
  print("This error might also happen if your workspace/project file is not in the root directory of your project.")
  print("To workaround that issue, you can wrap your calls to gym with")
  print("`Dir.chdir('../path/to/dir/containing/proj') do`")
  print("For an example you can check out")
  print("https://github.com/artsy/emission-nebula/commit/44fe51a7fea8f7d52f0f77d6c3084827fe5dd59e")
  UI.build_failure!("Archive invalid")
end

.handle_empty_ipaObject



130
131
132
# File 'gym/lib/gym/error_handler.rb', line 130

def handle_empty_ipa
  UI.build_failure!("IPA invalid")
end

.handle_empty_pkgObject



134
135
136
# File 'gym/lib/gym/error_handler.rb', line 134

def handle_empty_pkg
  UI.build_failure!("PKG invalid")
end

.handle_package_error(output) ⇒ Object

This method should raise an exception in any case, as the return code indicated a failed build

Parameters:

  • The (Array)

    output of the errored build (line by line)



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
112
113
# File 'gym/lib/gym/error_handler.rb', line 78

def handle_package_error(output)
  case output
  when /single\-bundle/
    print("Your project does not contain a single–bundle application or contains multiple products")
    print("Please read the documentation provided by Apple: https://developer.apple.com/library/ios/technotes/tn2215/_index.html")
  when /no signing identity matches '(.*)'/
    print("Could not find code signing identity '#{$1}'")
    print("Make sure the name of the code signing identity is correct")
    print("and it matches a locally installed code signing identity")
    print("You can pass the name of the code signing identity using the")
    print("`codesigning_identity` option")
  when /no provisioning profile matches '(.*)'/
    print("Could not find provisioning profile with the name '#{$1}'")
    print("Make sure the name of the provisioning profile is correct")
    print("and it matches a locally installed profile")
  when /mismatch between specified provisioning profile and signing identity/
    print("Mismatch between provisioning profile and code signing identity")
    print("This means, the specified provisioning profile was not created using")
    print("the specified certificate.")
    print("Run cert and sigh before gym to make sure to have all signing resources ready")
  when /requires a provisioning profile/
    print("No provisioning profile provided")
    print("Make sure to pass a valid provisioning for each required target")
    print("Check out the docs on how to fix this: https://docs.fastlane.tools/actions/gym/#export-options")
  # insert more specific code signing errors here
  when /Codesign check fails/
    print("A general code signing error occurred. Make sure you passed a valid")
    print("provisioning profile and code signing identity.")
  end
  print_xcode_version
  print_full_log_path
  print_environment_information
  print_build_error_instructions
  print_xcode9_plist_warning
  UI.build_failure!("Error packaging up the application", error_info: output)
end