Class: Pod::Xcode::XCFramework::Slice
- Inherits:
-
Object
- Object
- Pod::Xcode::XCFramework::Slice
- Defined in:
- lib/cocoapods/xcode/xcframework/xcframework_slice.rb
Instance Attribute Summary collapse
-
#headers ⇒ Pathname
readonly
The path to the headers.
-
#identifier ⇒ String
readonly
The framework identifier.
-
#path ⇒ Pathname
readonly
The path to the .framework, .a or .dylib of this slice.
-
#platform ⇒ Platform
readonly
The supported platform.
-
#platform_variant ⇒ Symbol
readonly
The platform variant.
-
#supported_archs ⇒ Array<String>
readonly
List of supported architectures.
Instance Method Summary collapse
-
#binary_path ⇒ Pathname
The path to the bundled binary.
-
#build_type ⇒ BuildType
The build type of the binary.
-
#dynamic? ⇒ Boolean
True if this slice contains a dynamically-linked binary.
-
#framework? ⇒ Boolean
True if this slice is a framework, not a library.
-
#initialize(path, identifier, archs, platform, platform_variant: nil, headers: path.join('Headers')) ⇒ Slice
constructor
A new instance of Slice.
-
#library? ⇒ Boolean
True if this slice is a library, not a framework.
-
#name ⇒ String
The name of the framework.
-
#package_type ⇒ Symbol
The package type of the slice - either :framework or :library.
-
#simulator_variant? ⇒ Boolean
True if this is a slice built for simulator.
-
#static? ⇒ Boolean
True if this slice contains a statically-linked binary.
Constructor Details
#initialize(path, identifier, archs, platform, platform_variant: nil, headers: path.join('Headers')) ⇒ Slice
Returns a new instance of Slice.
31 32 33 34 35 36 37 38 |
# 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 |
Instance Attribute Details
#headers ⇒ Pathname (readonly)
Returns the path to the headers.
29 30 31 |
# File 'lib/cocoapods/xcode/xcframework/xcframework_slice.rb', line 29 def headers @headers end |
#identifier ⇒ String (readonly)
Returns the framework identifier.
17 18 19 |
# File 'lib/cocoapods/xcode/xcframework/xcframework_slice.rb', line 17 def identifier @identifier end |
#path ⇒ Pathname (readonly)
Returns the path to the .framework, .a or .dylib of this slice.
9 10 11 |
# File 'lib/cocoapods/xcode/xcframework/xcframework_slice.rb', line 9 def path @path end |
#platform ⇒ Platform (readonly)
Returns the supported platform.
21 22 23 |
# File 'lib/cocoapods/xcode/xcframework/xcframework_slice.rb', line 21 def platform @platform end |
#platform_variant ⇒ Symbol (readonly)
Returns the platform variant. Either :simulator or nil.
25 26 27 |
# File 'lib/cocoapods/xcode/xcframework/xcframework_slice.rb', line 25 def platform_variant @platform_variant end |
#supported_archs ⇒ Array<String> (readonly)
Returns list of supported architectures.
13 14 15 |
# File 'lib/cocoapods/xcode/xcframework/xcframework_slice.rb', line 13 def supported_archs @supported_archs end |
Instance Method Details
#binary_path ⇒ Pathname
Returns the path to the bundled binary.
129 130 131 132 133 134 135 136 137 138 139 140 |
# 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 ⇒ BuildType
Returns the build type of the binary.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# 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? ⇒ Boolean
Returns true if this slice contains a dynamically-linked binary.
105 106 107 |
# File 'lib/cocoapods/xcode/xcframework/xcframework_slice.rb', line 105 def dynamic? build_type.dynamic? end |
#framework? ⇒ Boolean
Returns true if this slice is a framework, not a library.
87 88 89 |
# File 'lib/cocoapods/xcode/xcframework/xcframework_slice.rb', line 87 def framework? build_type.framework? end |
#library? ⇒ Boolean
Returns true if this slice is a library, not a framework.
93 94 95 |
# File 'lib/cocoapods/xcode/xcframework/xcframework_slice.rb', line 93 def library? build_type.library? end |
#name ⇒ String
Returns the name of the framework.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# 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 ⇒ Symbol
Returns the package type of the slice - either :framework or :library.
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# 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? ⇒ Boolean
Returns true if this is a slice built for simulator.
65 66 67 |
# File 'lib/cocoapods/xcode/xcframework/xcframework_slice.rb', line 65 def simulator_variant? @platform_variant == :simulator end |
#static? ⇒ Boolean
Returns true if this slice contains a statically-linked binary.
99 100 101 |
# File 'lib/cocoapods/xcode/xcframework/xcframework_slice.rb', line 99 def static? build_type.static? end |