Class: RunLoop::Xcode
Overview
All command line tools are run in the context of ‘xcrun`.
A model of the active Xcode version.
Throughout this class’s documentation, there are references to the _active version of Xcode_. The active Xcode version is the one returned by ‘xcrun xcodebuild`. The current Xcode version can be set using `xcode-select` or overridden using the `DEVELOPER_DIR`.
Constant Summary
Constants included from Shell
Instance Method Summary collapse
-
#beta? ⇒ Boolean
Is this a beta version of Xcode?.
-
#developer_dir ⇒ String
Returns the path to the current developer directory.
-
#inspect ⇒ Object
Returns debug String representation.
-
#to_s ⇒ Object
Returns a String representation.
-
#v100 ⇒ RunLoop::Version
Returns a version instance for Xcode 10.0; used to check for the availability of features and paths to various items on the filesystem.
-
#v102 ⇒ RunLoop::Version
Returns a version instance for Xcode 10.2; used to check for the availability of features and paths to various items on the filesystem.
-
#v110 ⇒ RunLoop::Version
Returns a version instance for Xcode 11.0; used to check for the availability of features and paths to various items on the filesystem.
-
#v80 ⇒ RunLoop::Version
Returns a version instance for ‘Xcode 8.0`; used to check for the availability of features and paths to various items on the filesystem.
-
#v81 ⇒ RunLoop::Version
Returns a version instance for ‘Xcode 8.1`; used to check for the availability of features and paths to various items on the filesystem.
-
#v82 ⇒ RunLoop::Version
Returns a version instance for Xcode 8.2; used to check for the availability of features and paths to various items on the filesystem.
-
#v83 ⇒ RunLoop::Version
Returns a version instance for Xcode 8.3; used to check for the availability of features and paths to various items on the filesystem.
-
#v90 ⇒ RunLoop::Version
Returns a version instance for Xcode 9.0; used to check for the availability of features and paths to various items on the filesystem.
-
#v91 ⇒ RunLoop::Version
Returns a version instance for Xcode 9.1; used to check for the availability of features and paths to various items on the filesystem.
-
#v92 ⇒ RunLoop::Version
Returns a version instance for Xcode 9.2; used to check for the availability of features and paths to various items on the filesystem.
-
#v93 ⇒ RunLoop::Version
Returns a version instance for Xcode 9.3; used to check for the availability of features and paths to various items on the filesystem.
-
#v94 ⇒ RunLoop::Version
Returns a version instance for Xcode 9.4; used to check for the availability of features and paths to various items on the filesystem.
-
#version ⇒ RunLoop::Version
Returns the current version of Xcode.
-
#version_gte_100? ⇒ Boolean
Is the active Xcode version 10.0 or above?.
-
#version_gte_102? ⇒ Boolean
Is the active Xcode version 10.2 or above?.
-
#version_gte_110? ⇒ Boolean
Is the active Xcode version 11.0 or above?.
-
#version_gte_81? ⇒ Boolean
Is the active Xcode version 8.1 or above?.
-
#version_gte_82? ⇒ Boolean
Is the active Xcode version 8.2 or above?.
-
#version_gte_83? ⇒ Boolean
Is the active Xcode version 8.3 or above?.
-
#version_gte_8? ⇒ Boolean
Is the active Xcode version 8.0 or above?.
-
#version_gte_90? ⇒ Boolean
Is the active Xcode version 9.0 or above?.
-
#version_gte_91? ⇒ Boolean
Is the active Xcode version 9.1 or above?.
-
#version_gte_92? ⇒ Boolean
Is the active Xcode version 9.2 or above?.
-
#version_gte_93? ⇒ Boolean
Is the active Xcode version 9.3 or above?.
-
#version_gte_94? ⇒ Boolean
Is the active Xcode version 9.4 or above?.
Methods included from Shell
run_shell_command, #run_shell_command
Methods included from Encoding
Instance Method Details
#beta? ⇒ Boolean
Relies on Xcode beta versions having and app bundle named Xcode-Beta.app
Is this a beta version of Xcode?
245 246 247 |
# File 'lib/run_loop/xcode.rb', line 245 def beta? developer_dir[/Xcode-[Bb]eta.app/, 0] end |
#developer_dir ⇒ String
Returns the path to the current developer directory.
From the man pages:
“‘ $ man xcode-select DEVELOPER_DIR Overrides the active developer directory. When DEVELOPER_DIR is set, its value will be used instead of the system-wide active developer directory. “`
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/run_loop/xcode.rb', line 265 def developer_dir @xcode_developer_dir ||= begin if RunLoop::Environment.developer_dir path = RunLoop::Environment.developer_dir else path = xcode_select_path end require 'pathname' path = Pathname.new(path).realpath.to_s if !File.directory?(path) raise RuntimeError, %Q{Cannot determine the active Xcode. Expected an Xcode here: #{path} Check the value of xcode-select: # Does this resolve to a valid Xcode.app/Contents/Developer path? $ xcode-select --print-path Is the DEVELOPER_DIR variable set in your environment? You would only use this if you have multiple Xcode's installed. $ echo $DEVELOPER_DIR See the man pages for xcrun and xcode-select for details. $ man xcrun $ man xcode-select } end path end end |
#inspect ⇒ Object
Returns debug String representation
25 26 27 |
# File 'lib/run_loop/xcode.rb', line 25 def inspect to_s end |
#to_s ⇒ Object
Returns a String representation.
20 21 22 |
# File 'lib/run_loop/xcode.rb', line 20 def to_s "#<Xcode #{version.to_s}>" end |
#v100 ⇒ RunLoop::Version
Returns a version instance for Xcode 10.0; used to check for the availability of features and paths to various items on the filesystem
49 50 51 |
# File 'lib/run_loop/xcode.rb', line 49 def v100 fetch_version(:v100) end |
#v102 ⇒ RunLoop::Version
Returns a version instance for Xcode 10.2; used to check for the availability of features and paths to various items on the filesystem
41 42 43 |
# File 'lib/run_loop/xcode.rb', line 41 def v102 fetch_version(:v102) end |
#v110 ⇒ RunLoop::Version
Returns a version instance for Xcode 11.0; used to check for the availability of features and paths to various items on the filesystem
33 34 35 |
# File 'lib/run_loop/xcode.rb', line 33 def v110 fetch_version(:v110) end |
#v80 ⇒ RunLoop::Version
Returns a version instance for ‘Xcode 8.0`; used to check for the availability of features and paths to various items on the filesystem.
121 122 123 |
# File 'lib/run_loop/xcode.rb', line 121 def v80 fetch_version(:v80) end |
#v81 ⇒ RunLoop::Version
Returns a version instance for ‘Xcode 8.1`; used to check for the availability of features and paths to various items on the filesystem.
113 114 115 |
# File 'lib/run_loop/xcode.rb', line 113 def v81 fetch_version(:v81) end |
#v82 ⇒ RunLoop::Version
Returns a version instance for Xcode 8.2; used to check for the availability of features and paths to various items on the filesystem
105 106 107 |
# File 'lib/run_loop/xcode.rb', line 105 def v82 fetch_version(:v82) end |
#v83 ⇒ RunLoop::Version
Returns a version instance for Xcode 8.3; used to check for the availability of features and paths to various items on the filesystem
97 98 99 |
# File 'lib/run_loop/xcode.rb', line 97 def v83 fetch_version(:v83) end |
#v90 ⇒ RunLoop::Version
Returns a version instance for Xcode 9.0; used to check for the availability of features and paths to various items on the filesystem
89 90 91 |
# File 'lib/run_loop/xcode.rb', line 89 def v90 fetch_version(:v90) end |
#v91 ⇒ RunLoop::Version
Returns a version instance for Xcode 9.1; used to check for the availability of features and paths to various items on the filesystem
81 82 83 |
# File 'lib/run_loop/xcode.rb', line 81 def v91 fetch_version(:v91) end |
#v92 ⇒ RunLoop::Version
Returns a version instance for Xcode 9.2; used to check for the availability of features and paths to various items on the filesystem
73 74 75 |
# File 'lib/run_loop/xcode.rb', line 73 def v92 fetch_version(:v92) end |
#v93 ⇒ RunLoop::Version
Returns a version instance for Xcode 9.3; used to check for the availability of features and paths to various items on the filesystem
65 66 67 |
# File 'lib/run_loop/xcode.rb', line 65 def v93 fetch_version(:v93) end |
#v94 ⇒ RunLoop::Version
Returns a version instance for Xcode 9.4; used to check for the availability of features and paths to various items on the filesystem
57 58 59 |
# File 'lib/run_loop/xcode.rb', line 57 def v94 fetch_version(:v94) end |
#version ⇒ RunLoop::Version
Returns the current version of Xcode.
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/run_loop/xcode.rb', line 213 def version @xcode_version ||= begin if RunLoop::Environment.xtc? RunLoop::Version.new("0.0.0") else version = RunLoop::Version.new("0.0.0") begin args = ["xcrun", "xcodebuild", "-version"] hash = run_shell_command(args) if hash[:exit_status] != 0 RunLoop.log_error("xcrun xcodebuild -version exited non-zero") else out = hash[:out] version_string = out.chomp[VERSION_REGEX, 0] version = RunLoop::Version.new(version_string) end rescue RuntimeError => e RunLoop.log_error(%Q[ Could not find Xcode version: #{e.class}: #{e.} ]) end version end end end |
#version_gte_100? ⇒ Boolean
Is the active Xcode version 10.0 or above?
142 143 144 |
# File 'lib/run_loop/xcode.rb', line 142 def version_gte_100? version >= v100 end |
#version_gte_102? ⇒ Boolean
Is the active Xcode version 10.2 or above?
135 136 137 |
# File 'lib/run_loop/xcode.rb', line 135 def version_gte_102? version >= v102 end |
#version_gte_110? ⇒ Boolean
Is the active Xcode version 11.0 or above?
128 129 130 |
# File 'lib/run_loop/xcode.rb', line 128 def version_gte_110? version >= v110 end |
#version_gte_81? ⇒ Boolean
Is the active Xcode version 8.1 or above?
198 199 200 |
# File 'lib/run_loop/xcode.rb', line 198 def version_gte_81? version >= v81 end |
#version_gte_82? ⇒ Boolean
Is the active Xcode version 8.2 or above?
191 192 193 |
# File 'lib/run_loop/xcode.rb', line 191 def version_gte_82? version >= v82 end |
#version_gte_83? ⇒ Boolean
Is the active Xcode version 8.3 or above?
184 185 186 |
# File 'lib/run_loop/xcode.rb', line 184 def version_gte_83? version >= v83 end |
#version_gte_8? ⇒ Boolean
Is the active Xcode version 8.0 or above?
205 206 207 |
# File 'lib/run_loop/xcode.rb', line 205 def version_gte_8? version >= v80 end |
#version_gte_90? ⇒ Boolean
Is the active Xcode version 9.0 or above?
177 178 179 |
# File 'lib/run_loop/xcode.rb', line 177 def version_gte_90? version >= v90 end |
#version_gte_91? ⇒ Boolean
Is the active Xcode version 9.1 or above?
170 171 172 |
# File 'lib/run_loop/xcode.rb', line 170 def version_gte_91? version >= v91 end |
#version_gte_92? ⇒ Boolean
Is the active Xcode version 9.2 or above?
163 164 165 |
# File 'lib/run_loop/xcode.rb', line 163 def version_gte_92? version >= v92 end |
#version_gte_93? ⇒ Boolean
Is the active Xcode version 9.3 or above?
156 157 158 |
# File 'lib/run_loop/xcode.rb', line 156 def version_gte_93? version >= v93 end |
#version_gte_94? ⇒ Boolean
Is the active Xcode version 9.4 or above?
149 150 151 |
# File 'lib/run_loop/xcode.rb', line 149 def version_gte_94? version >= v94 end |