class Pod::Xcode::XCFramework::Slice

Attributes

headers[R]

@return [Pathname] the path to the headers

identifier[R]

@return [String] the framework identifier

path[R]

@return [Pathname] the path to the .framework, .a or .dylib of this slice

platform[R]

@return [Platform] the supported platform

platform_variant[R]

@return [Symbol] the platform variant. Either :simulator or nil

supported_archs[R]

@return [Array<String>] list of supported architectures

Public Class Methods

new(path, identifier, archs, platform, platform_variant: nil, headers: path.join('Headers')) click to toggle source
# File lib/cocoapods/xcode/xcframework/xcframework_slice.rb, line 31
def initialize(path, identifier, archs, platform, platform_variant: nil, headers: path.join('Headers'))
  @path = path
  @identifier = identifier
  @supported_archs = archs
  @platform = Pod::Platform.new(platform)
  @platform_variant = platform_variant.to_sym unless platform_variant.nil?
  @headers = headers
end

Public Instance Methods

binary_path() click to toggle source

@return [Pathname] the path to the bundled binary

# File lib/cocoapods/xcode/xcframework/xcframework_slice.rb, line 129
def binary_path
  @binary_path ||= begin
    case package_type
    when :framework
      path + name
    when :library
      path
    else
      raise Informative, "Invalid package type `#{package_type}`"
    end
  end
end
build_type() click to toggle source

@return [BuildType] the build type of the binary

# File lib/cocoapods/xcode/xcframework/xcframework_slice.rb, line 111
def build_type
  @build_type ||= begin
    linkage = Xcode::LinkageAnalyzer.dynamic_binary?(binary_path) ? :dynamic : :static
    ext = File.extname(path)
    packaging = case ext
                when '.framework'
                  :framework
                when '.a', '.dylib'
                  :library
                else
                  raise Informative, "Invalid XCFramework slice type `#{ext}`"
                end
    BuildType.new(:linkage => linkage, :packaging => packaging)
  end
end
dynamic?() click to toggle source

@return [Boolean] true if this slice contains a dynamically-linked binary

# File lib/cocoapods/xcode/xcframework/xcframework_slice.rb, line 105
def dynamic?
  build_type.dynamic?
end
framework?() click to toggle source

@return [Boolean] true if this slice is a framework, not a library

# File lib/cocoapods/xcode/xcframework/xcframework_slice.rb, line 87
def framework?
  build_type.framework?
end
library?() click to toggle source

@return [Boolean] true if this slice is a library, not a framework

# File lib/cocoapods/xcode/xcframework/xcframework_slice.rb, line 93
def library?
  build_type.library?
end
name() click to toggle source

@return [String] the name of the framework

# File lib/cocoapods/xcode/xcframework/xcframework_slice.rb, line 42
def name
  @name ||= begin
    case package_type
    when :framework
      File.basename(path, '.framework')
    when :library
      ext = File.extname(path)
      case ext
      when '.a', '.dylib'
        result = File.basename(path).gsub(/^lib/, '')
        result[0] = result.downcase[0]
        result
      else
        raise Informative, "Invalid package type `#{package_type}`"
      end
    else
      raise Informative, "Invalid package type `#{package_type}`"
    end
  end
end
package_type() click to toggle source

@return [Symbol] the package type of the slice - either :framework or :library

# File lib/cocoapods/xcode/xcframework/xcframework_slice.rb, line 71
def package_type
  @package_type ||= begin
    ext = File.extname(path)
    case ext
    when '.framework'
      :framework
    when '.a', '.dylib'
      :library
    else
      raise Informative, "Invalid XCFramework slice type `#{ext}`"
    end
  end
end
simulator_variant?() click to toggle source

@return [Boolean] true if this is a slice built for simulator

# File lib/cocoapods/xcode/xcframework/xcframework_slice.rb, line 65
def simulator_variant?
  @platform_variant == :simulator
end
static?() click to toggle source

@return [Boolean] true if this slice contains a statically-linked binary

# File lib/cocoapods/xcode/xcframework/xcframework_slice.rb, line 99
def static?
  build_type.static?
end