class Pod::Xcode::XCFramework

Attributes

format_version[R]

@return [Pod::Version] the format version of the .xcframework

path[R]

@return [Pathname] path the path to the .xcframework on disk

plist[R]

@return [Hash] the contents of the parsed plist

slices[R]

@return [Array<XCFramework::Slice>] the slices contained inside this .xcframework

target_name[R]

@return [String] target_name the target name this XCFramework belongs to

Public Class Methods

new(target_name, path) click to toggle source

Initializes an XCFramework instance with a path on disk

@param [String] target_name @see target_name @param [Pathname, String] path @see path

@return [XCFramework] the xcframework at the given path

# File lib/cocoapods/xcode/xcframework.rb, line 35
def initialize(target_name, path)
  @target_name = target_name
  @path = Pathname.new(path).tap do |p|
    raise 'Absolute path is required' unless p.absolute?
  end

  @plist = Xcodeproj::Plist.read_from_path(plist_path)
  parse_plist_contents
end

Public Instance Methods

build_type() click to toggle source

@return [Pod::BuildType] the build type of the contained slices

@note As CocoaPods does not support mixed packaging nor linkage for xcframework slices,

we pick the first slice and assume all are the same
# File lib/cocoapods/xcode/xcframework.rb, line 74
def build_type
  @build_type ||= slices.first.build_type
end
includes_dynamic_slices?() click to toggle source

@return [Boolean] true if any slices use dynamic linkage

# File lib/cocoapods/xcode/xcframework.rb, line 59
def includes_dynamic_slices?
  build_type.dynamic?
end
includes_static_slices?() click to toggle source

@return [Boolean] true if any slices use dynamic linkage

# File lib/cocoapods/xcode/xcframework.rb, line 65
def includes_static_slices?
  build_type.static?
end
name() click to toggle source

@return [String] the basename of the framework

# File lib/cocoapods/xcode/xcframework.rb, line 53
def name
  File.basename(path, '.xcframework')
end
plist_path() click to toggle source

@return [Pathname] the path to the Info.plist

# File lib/cocoapods/xcode/xcframework.rb, line 47
def plist_path
  path + 'Info.plist'
end

Private Instance Methods

parse_plist_contents() click to toggle source
# File lib/cocoapods/xcode/xcframework.rb, line 80
def parse_plist_contents
  @format_version = Pod::Version.new(plist['XCFrameworkFormatVersion'])
  @slices = plist['AvailableLibraries'].map do |library|
    identifier = library['LibraryIdentifier']
    relative_path = library['LibraryPath']
    archs = library['SupportedArchitectures']
    platform_name = library['SupportedPlatform']
    platform_variant = library['SupportedPlatformVariant']
    headers = library['HeadersPath']

    slice_root = path.join(identifier)
    slice_path = slice_root.join(relative_path)
    headers = slice_root.join(headers) unless headers.nil?
    XCFramework::Slice.new(slice_path, identifier, archs, platform_name, :platform_variant => platform_variant, :headers => headers)
  end.sort_by(&:identifier)
  raise Informative, "XCFramework at #{path} does not contain any frameworks or libraries." if slices.empty?
end