Class: Pod::Xcode::XCFramework
- Inherits:
-
Object
- Object
- Pod::Xcode::XCFramework
- Defined in:
- lib/cocoapods/xcode/xcframework.rb,
lib/cocoapods/xcode/xcframework/xcframework_slice.rb
Defined Under Namespace
Classes: Slice
Instance Attribute Summary collapse
-
#format_version ⇒ Pod::Version
readonly
The format version of the .xcframework.
-
#path ⇒ Pathname
readonly
Path the path to the .xcframework on disk.
-
#plist ⇒ Hash
readonly
The contents of the parsed plist.
-
#slices ⇒ Array<XCFramework::Slice>
readonly
The slices contained inside this .xcframework.
Instance Method Summary collapse
-
#build_type ⇒ Pod::BuildType
The build type of the contained slices.
-
#includes_dynamic_slices? ⇒ Boolean
True if any slices use dynamic linkage.
-
#includes_static_slices? ⇒ Boolean
True if any slices use dynamic linkage.
-
#initialize(path) ⇒ XCFramework
constructor
Initializes an XCFramework instance with a path on disk.
-
#name ⇒ String
The basename of the framework.
- #parse_plist_contents ⇒ Object private
-
#plist_path ⇒ Pathname
The path to the Info.plist.
Constructor Details
#initialize(path) ⇒ XCFramework
Initializes an XCFramework instance with a path on disk
31 32 33 34 35 36 37 38 |
# File 'lib/cocoapods/xcode/xcframework.rb', line 31 def initialize(path) @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_version ⇒ Pod::Version (readonly)
Returns the format version of the .xcframework.
14 15 16 |
# File 'lib/cocoapods/xcode/xcframework.rb', line 14 def format_version @format_version end |
#path ⇒ Pathname (readonly)
Returns path the path to the .xcframework on disk.
10 11 12 |
# File 'lib/cocoapods/xcode/xcframework.rb', line 10 def path @path end |
#plist ⇒ Hash (readonly)
Returns the contents of the parsed plist.
22 23 24 |
# File 'lib/cocoapods/xcode/xcframework.rb', line 22 def plist @plist end |
#slices ⇒ Array<XCFramework::Slice> (readonly)
Returns the slices contained inside this .xcframework.
18 19 20 |
# File 'lib/cocoapods/xcode/xcframework.rb', line 18 def slices @slices end |
Instance Method Details
#build_type ⇒ Pod::BuildType
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.
69 70 71 |
# File 'lib/cocoapods/xcode/xcframework.rb', line 69 def build_type @build_type ||= slices.first.build_type end |
#includes_dynamic_slices? ⇒ Boolean
Returns true if any slices use dynamic linkage.
54 55 56 |
# File 'lib/cocoapods/xcode/xcframework.rb', line 54 def includes_dynamic_slices? build_type.dynamic? end |
#includes_static_slices? ⇒ Boolean
Returns true if any slices use dynamic linkage.
60 61 62 |
# File 'lib/cocoapods/xcode/xcframework.rb', line 60 def includes_static_slices? build_type.static? end |
#name ⇒ String
Returns the basename of the framework.
48 49 50 |
# File 'lib/cocoapods/xcode/xcframework.rb', line 48 def name File.basename(path, '.xcframework') end |
#parse_plist_contents ⇒ Object (private)
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/cocoapods/xcode/xcframework.rb', line 75 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_path ⇒ Pathname
Returns the path to the Info.plist.
42 43 44 |
# File 'lib/cocoapods/xcode/xcframework.rb', line 42 def plist_path path + 'Info.plist' end |