Class: Pod::Xcode::XCFramework

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/xcode/xcframework.rb,
lib/cocoapods/xcode/xcframework/xcframework_slice.rb

Defined Under Namespace

Classes: Slice

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target_name, path) ⇒ XCFramework

Initializes an XCFramework instance with a path on disk

Parameters:

  • target_name (String)

    @see target_name

  • path (Pathname, String)

    @see path


35
36
37
38
39
40
41
42
43
# 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

Instance Attribute Details

#format_versionPod::Version (readonly)

Returns the format version of the .xcframework.

Returns:

  • (Pod::Version)

    the format version of the .xcframework


18
19
20
# File 'lib/cocoapods/xcode/xcframework.rb', line 18

def format_version
  @format_version
end

#pathPathname (readonly)

Returns path the path to the .xcframework on disk.

Returns:

  • (Pathname)

    path the path to the .xcframework on disk


14
15
16
# File 'lib/cocoapods/xcode/xcframework.rb', line 14

def path
  @path
end

#plistHash (readonly)

Returns the contents of the parsed plist.

Returns:

  • (Hash)

    the contents of the parsed plist


26
27
28
# File 'lib/cocoapods/xcode/xcframework.rb', line 26

def plist
  @plist
end

#slicesArray<XCFramework::Slice> (readonly)

Returns the slices contained inside this .xcframework.

Returns:


22
23
24
# File 'lib/cocoapods/xcode/xcframework.rb', line 22

def slices
  @slices
end

#target_nameString (readonly)

Returns target_name the target name this XCFramework belongs to.

Returns:

  • (String)

    target_name the target name this XCFramework belongs to


10
11
12
# File 'lib/cocoapods/xcode/xcframework.rb', line 10

def target_name
  @target_name
end

Instance Method Details

#build_typePod::BuildType

Note:

As CocoaPods does not support mixed packaging nor linkage for xcframework slices, we pick the first slice and assume all are the same

Returns the build type of the contained slices.

Returns:

  • (Pod::BuildType)

    the build type of the contained slices


74
75
76
# File 'lib/cocoapods/xcode/xcframework.rb', line 74

def build_type
  @build_type ||= slices.first.build_type
end

#includes_dynamic_slices?Boolean

Returns true if any slices use dynamic linkage.

Returns:

  • (Boolean)

    true if any slices use dynamic linkage


59
60
61
# File 'lib/cocoapods/xcode/xcframework.rb', line 59

def includes_dynamic_slices?
  build_type.dynamic?
end

#includes_static_slices?Boolean

Returns true if any slices use dynamic linkage.

Returns:

  • (Boolean)

    true if any slices use dynamic linkage


65
66
67
# File 'lib/cocoapods/xcode/xcframework.rb', line 65

def includes_static_slices?
  build_type.static?
end

#nameString

Returns the basename of the framework.

Returns:

  • (String)

    the basename of the framework


53
54
55
# File 'lib/cocoapods/xcode/xcframework.rb', line 53

def name
  File.basename(path, '.xcframework')
end

#parse_plist_contentsObject (private)

Raises:


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# 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
  raise Informative, "XCFramework at #{path} does not contain any frameworks or libraries." if slices.empty?
end

#plist_pathPathname

Returns the path to the Info.plist.

Returns:

  • (Pathname)

    the path to the Info.plist


47
48
49
# File 'lib/cocoapods/xcode/xcframework.rb', line 47

def plist_path
  path + 'Info.plist'
end