Class: Gym::DetectValues
- Inherits:
-
Object
- Object
- Gym::DetectValues
- Defined in:
- lib/gym/detect_values.rb
Overview
This class detects all kinds of default values
Class Method Summary collapse
-
.detect_configuration ⇒ Object
Detects the available configurations (e.g. Debug, Release).
-
.detect_platform ⇒ Object
Is it an iOS device or a Mac?.
-
.detect_provisioning_profile ⇒ Object
Helper Methods.
- .detect_scheme ⇒ Object
-
.detect_toolchain ⇒ Object
The toolchain parameter is used if you don’t use the default toolchain of Xcode (e.g. Swift 2.3 with Xcode 8).
- .min_xcode8? ⇒ Boolean
-
.set_additional_default_values ⇒ Object
This is needed as these are more complex default values Returns the finished config object.
Class Method Details
.detect_configuration ⇒ Object
Detects the available configurations (e.g. Debug, Release)
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/gym/detect_values.rb', line 81 def self.detect_configuration config = Gym.config configurations = Gym.project.configurations return if configurations.count == 0 # this is an optional value anyway if config[:configuration] # Verify the configuration is available unless configurations.include?(config[:configuration]) UI.error "Couldn't find specified configuration '#{config[:configuration]}'." config[:configuration] = nil end end end |
.detect_platform ⇒ Object
Is it an iOS device or a Mac?
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/gym/detect_values.rb', line 67 def self.detect_platform return if Gym.config[:destination] platform = if Gym.project.mac? min_xcode8? ? "macOS" : "OS X" elsif Gym.project.tvos? "tvOS" else "iOS" end Gym.config[:destination] = "generic/platform=#{platform}" end |
.detect_provisioning_profile ⇒ Object
Helper Methods
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/gym/detect_values.rb', line 36 def self.detect_provisioning_profile if Gym.config[:provisioning_profile_path].nil? return unless Gym.config[:use_legacy_build_api] # we only want to auto-detect the profile when using the legacy build API Dir.chdir(File.("..", Gym.project.path)) do profiles = Dir["*.mobileprovision"] if profiles.count == 1 profile = File.(profiles.last) elsif profiles.count > 1 UI. "Found more than one provisioning profile in the project directory:" profile = choose(*profiles) end Gym.config[:provisioning_profile_path] = profile end end if Gym.config[:provisioning_profile_path] FastlaneCore::ProvisioningProfile.install(Gym.config[:provisioning_profile_path]) end end |
.detect_scheme ⇒ Object
58 59 60 |
# File 'lib/gym/detect_values.rb', line 58 def self.detect_scheme Gym.project.select_scheme end |
.detect_toolchain ⇒ Object
The toolchain parameter is used if you don’t use the default toolchain of Xcode (e.g. Swift 2.3 with Xcode 8)
96 97 98 99 100 101 102 103 |
# File 'lib/gym/detect_values.rb', line 96 def self.detect_toolchain return unless Gym.config[:toolchain] # Convert the aliases to the full string to make it easier for the user #justfastlanethings if Gym.config[:toolchain].to_s == "swift_2_3" Gym.config[:toolchain] = "com.apple.dt.toolchain.Swift_2_3" end end |
.min_xcode8? ⇒ Boolean
62 63 64 |
# File 'lib/gym/detect_values.rb', line 62 def self.min_xcode8? Helper.xcode_version.split(".").first.to_i >= 8 end |
.set_additional_default_values ⇒ Object
This is needed as these are more complex default values Returns the finished config object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gym/detect_values.rb', line 6 def self.set_additional_default_values config = Gym.config # First, try loading the Gymfile from the current directory config.load_configuration_file(Gym.gymfile_name) # Detect the project FastlaneCore::Project.detect_projects(config) Gym.project = FastlaneCore::Project.new(config) detect_provisioning_profile # Go into the project's folder, as there might be a Gymfile there Dir.chdir(File.("..", Gym.project.path)) do config.load_configuration_file(Gym.gymfile_name) end config[:use_legacy_build_api] = true if Xcode.pre_7? detect_scheme detect_platform # we can only do that *after* we have the scheme detect_configuration detect_toolchain config[:output_name] ||= Gym.project.app_name return config end |