Class: XCInvoke::Xcode
- Inherits:
-
Object
- Object
- XCInvoke::Xcode
- Extended by:
- Enumerable
- Defined in:
- lib/xcinvoke/xcode.rb
Instance Attribute Summary collapse
-
#developer_dir ⇒ Object
readonly
Returns the value of attribute developer_dir.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #as_env ⇒ Object
- #build_number ⇒ Object
- #dyld_framework_path ⇒ Object
- #dyld_library_path ⇒ Object
-
#initialize(path) ⇒ Xcode
constructor
A new instance of Xcode.
- #swift_version ⇒ Object
- #version ⇒ Object
- #xcrun(cmd, env: {}) ⇒ Object
Constructor Details
#initialize(path) ⇒ Xcode
Returns a new instance of Xcode.
26 27 28 |
# File 'lib/xcinvoke/xcode.rb', line 26 def initialize(path) @developer_dir = Pathname(path) end |
Instance Attribute Details
#developer_dir ⇒ Object (readonly)
Returns the value of attribute developer_dir.
24 25 26 |
# File 'lib/xcinvoke/xcode.rb', line 24 def developer_dir @developer_dir end |
Class Method Details
.all ⇒ Object
47 48 49 |
# File 'lib/xcinvoke/xcode.rb', line 47 def self.all to_a end |
.each(&blk) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/xcinvoke/xcode.rb', line 35 def self.each(&blk) xcodes, = Open3.capture2('mdfind', "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'", err: '/dev/null') xcodes = xcodes.split("\n").map(&:strip) xcodes = xcodes.map do |xc| xc = Pathname(xc) + 'Contents/Developer' new(xc) end xcodes.each(&blk) end |
.find_swift_version(swift_version) ⇒ Object
51 52 53 |
# File 'lib/xcinvoke/xcode.rb', line 51 def self.find_swift_version(swift_version) select { |xc| xc.swift_version == swift_version }.sort.last end |
.selected ⇒ Object
30 31 32 33 |
# File 'lib/xcinvoke/xcode.rb', line 30 def self.selected dir, = Open3.capture2('xcode-select', '-p', err: '/dev/null') new(dir.strip) end |
Instance Method Details
#<=>(other) ⇒ Object
69 70 71 |
# File 'lib/xcinvoke/xcode.rb', line 69 def <=>(other) version <=> other.version end |
#as_env ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/xcinvoke/xcode.rb', line 80 def as_env { 'DEVELOPER_DIR' => developer_dir.to_path, 'DYLD_FRAMEWORK_PATH' => dyld_framework_path.to_path, 'DYLD_LIBRARY_PATH' => dyld_library_path.to_path, } end |
#build_number ⇒ Object
60 61 62 63 |
# File 'lib/xcinvoke/xcode.rb', line 60 def build_number info = xcodebuild_info info[1] if info end |
#dyld_framework_path ⇒ Object
88 89 90 |
# File 'lib/xcinvoke/xcode.rb', line 88 def dyld_framework_path developer_dir + 'Toolchains/XcodeDefault.xctoolchain/usr/lib' end |
#dyld_library_path ⇒ Object
92 93 94 |
# File 'lib/xcinvoke/xcode.rb', line 92 def dyld_library_path developer_dir + 'Toolchains/XcodeDefault.xctoolchain/usr/lib' end |
#swift_version ⇒ Object
55 56 57 58 |
# File 'lib/xcinvoke/xcode.rb', line 55 def swift_version info = swift_info info.first if info end |
#version ⇒ Object
65 66 67 |
# File 'lib/xcinvoke/xcode.rb', line 65 def version Liferaft::Version.new(build_number) end |
#xcrun(cmd, env: {}) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/xcinvoke/xcode.rb', line 73 def xcrun(cmd, env: {}) env = env.merge(as_env) cmd = %w(xcrun) + cmd output, = Open3.capture2(env, *cmd, err: '/dev/null') output end |