import Foundation /// Open-source license / attribution text bundled with PunktfunkKit (see `Resources/`). /// /// Exposed from the kit so the app shell can show an Acknowledgements screen. The text files are /// bundled as SwiftPM resources and read via `Bundle.module`, which works both for `swift build` /// and for the Xcode app (it links the PunktfunkKit product, so the resource bundle rides along). public enum Licenses { private static func resource(_ name: String) -> String { guard let url = Bundle.module.url(forResource: name, withExtension: "txt"), let text = try? String(contentsOf: url, encoding: .utf8) else { return "" } return text } /// punktfunk's own license — MIT OR Apache-2.0, at your option. public static var appLicense: String { let mit = resource("LICENSE-MIT") let apache = resource("LICENSE-APACHE") if mit.isEmpty && apache.isEmpty { return "punktfunk is licensed under MIT OR Apache-2.0, at your option." } return "punktfunk is licensed under MIT OR Apache-2.0, at your option.\n\n" + "================================ MIT ================================\n\n" + mit + "\n\n============================== Apache-2.0 ==============================\n\n" + apache } /// Third-party software notices for the linked Rust crates (generated by /// `scripts/gen-third-party-notices.sh`). public static var thirdPartyNotices: String { let text = resource("THIRD-PARTY-NOTICES") return text.isEmpty ? "Third-party notices unavailable." : text } }