diff --git a/Package.swift b/Package.swift index 4de4225..498e72b 100644 --- a/Package.swift +++ b/Package.swift @@ -37,6 +37,9 @@ let package = Package( "HLS ObjectiveC", "PlaylistParserError", "mamba.h" + ], + resources: [ + .process("Resources") ] ), .target( diff --git a/mambaSharedFramework/FrameworkInfo.swift b/mambaSharedFramework/FrameworkInfo.swift index 02fe26e..ae9803f 100644 --- a/mambaSharedFramework/FrameworkInfo.swift +++ b/mambaSharedFramework/FrameworkInfo.swift @@ -25,12 +25,22 @@ public enum FrameworkInfo { /// returns the version of the mamba framework public static var version: String { + /// When exporting a framework on SPM, there is no way to access the info dictionary, so the version should be provided differently + #if SWIFT_PACKAGE + guard let versionFilePathUrl = Bundle.module.url(forResource: "version", withExtension: "txt"), + let version = try? String(contentsOf: versionFilePathUrl, encoding: .utf8) + .trimmingCharacters(in: .whitespacesAndNewlines) + else { + assertionFailure("Unable to find version string in framework bundle") + return "Error: Unable to find version string in framework bundle" + } + #else let bundle = Bundle(for: PlaylistParser.self) - guard let version = bundle.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String else { assertionFailure("Unable to find version string in framework bundle") return "Error: Unable to find version string in framework bundle" } + #endif return version } diff --git a/mambaSharedFramework/Resources/version.txt b/mambaSharedFramework/Resources/version.txt new file mode 100644 index 0000000..654c4a4 --- /dev/null +++ b/mambaSharedFramework/Resources/version.txt @@ -0,0 +1 @@ + 2.3.0