Class: XCCache::Swift::Sdk

Inherits:
Object
  • Object
show all
Defined in:
lib/xccache/swift/sdk.rb

Constant Summary collapse

NAME_TO_TRIPLE =
{
  :iphonesimulator => "arm64-apple-ios-simulator",
  :iphoneos => "arm64-apple-ios",
  :macosx => "arm64-apple-macosx",
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Sdk

Returns a new instance of Sdk.



14
15
16
# File 'lib/xccache/swift/sdk.rb', line 14

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/xccache/swift/sdk.rb', line 6

def name
  @name
end

Instance Method Details

#sdk_pathObject



28
29
30
31
32
33
# File 'lib/xccache/swift/sdk.rb', line 28

def sdk_path
  # rubocop:disable Layout/LineLength
  # /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
  # rubocop:enable Layout/LineLength
  @sdk_path ||= Pathname(Sh.capture_output("xcrun --sdk #{name} --show-sdk-path")).realpath
end

#sdk_platform_developer_pathObject



35
36
37
# File 'lib/xccache/swift/sdk.rb', line 35

def sdk_platform_developer_path
  @sdk_platform_developer_path ||= sdk_path.parent.parent # iPhoneSimulator.platform/Developer
end

#swiftc_argsObject



39
40
41
42
43
44
45
46
# File 'lib/xccache/swift/sdk.rb', line 39

def swiftc_args
  developer_library_frameworks_path = sdk_platform_developer_path / "Library" / "Frameworks"
  developer_usr_lib_path = sdk_platform_developer_path / "usr" / "lib"
  [
    "-F#{developer_library_frameworks_path}",
    "-I#{developer_usr_lib_path}",
  ]
end

#to_sObject



18
19
20
# File 'lib/xccache/swift/sdk.rb', line 18

def to_s
  name
end

#triple(without_vendor: false) ⇒ Object



22
23
24
25
26
# File 'lib/xccache/swift/sdk.rb', line 22

def triple(without_vendor: false)
  res = NAME_TO_TRIPLE[name.to_sym]
  res = res.sub("-apple", "") if without_vendor
  res
end