### Initialize AcknowListViewController (UIKit) Source: https://context7.com/vtourraine/acknowlist/llms.txt Provides examples of initializing `AcknowListViewController` in various ways: default initialization, from a specific plist file name, from a plist file URL with custom table style, and with a custom acknowledgements array. It also shows how to present the view controller modally. ```swift import UIKit import AcknowList class SettingsViewController: UIViewController { // Default initialization - auto-loads from CocoaPods plist and Package.resolved func showDefaultAcknowledgements() { let viewController = AcknowListViewController() navigationController?.pushViewController(viewController, animated: true) } // Initialize with a specific CocoaPods plist file name func showAcknowledgementsFromPlist() { let viewController = AcknowListViewController(fileNamed: "Pods-MyApp-acknowledgements") navigationController?.pushViewController(viewController, animated: true) } // Initialize with a plist file URL and custom table style func showAcknowledgementsFromURL() { guard let url = Bundle.main.url( forResource: "Pods-MyApp-acknowledgements", withExtension: "plist" ) else { return } let viewController = AcknowListViewController(plistFileURL: url, style: .plain) navigationController?.pushViewController(viewController, animated: true) } // Initialize with custom acknowledgements array func showCustomAcknowledgements() { let acknowledgements = [ Acknow(title: "Custom Library", text: "Custom license text..."), Acknow(title: "Another Library", text: "Another license...", repository: URL(string: "https://github.com/example/repo")) ] let viewController = AcknowListViewController(acknowledgements: acknowledgements) viewController.headerText = "Open Source Libraries" viewController.footerText = "We love open source!" // Present modally with navigation controller let navController = UINavigationController(rootViewController: viewController) present(navController, animated: true) } // Disable GitHub API license fetching func showAcknowledgementsWithoutGitHub() { let viewController = AcknowListViewController() viewController.canFetchLicenseFromGitHub = false navigationController?.pushViewController(viewController, animated: true) } } ``` -------------------------------- ### Localize Acknowledgements UI Strings Source: https://context7.com/vtourraine/acknowlist/llms.txt Provides localized strings for the acknowledgements UI, supporting 13 languages. Includes functions to get the localized title and to sort acknowledgements alphabetically using locale-aware comparison. ```swift import AcknowList // Get localized "Acknowledgements" title for buttons/labels let title = AcknowLocalization.localizedTitle() print(title) // "Acknowledgements" (or localized equivalent) // Sort acknowledgements alphabetically using locale-aware comparison let unsortedAcknowledgements = [ Acknow(title: "Zebra", text: "..."), Acknow(title: "Alpha", text: "..."), Acknow(title: "Beta", text: "..." ] let sorted = AcknowLocalization.sorted(unsortedAcknowledgements) // Result: Alpha, Beta, Zebra (locale-aware sorting) // Use localized title for a button let button = UIButton(type: .system) button.setTitle(AcknowLocalization.localizedTitle(), for: .normal) ``` -------------------------------- ### Initialize with Custom File or URL Source: https://github.com/vtourraine/acknowlist/blob/main/README.md Initialize the controller using a specific plist file name or a direct URL to a plist file. ```swift let viewController = AcknowListViewController(fileNamed: "Pods-AcknowExample-acknowledgements") ``` ```swift let url = Bundle.main.url(forResource: "Pods-AcknowExample-acknowledgements", withExtension: "plist") let viewController = AcknowListViewController(plistFileURL: url) ``` -------------------------------- ### Initialize with Manual Acknow Instances Source: https://github.com/vtourraine/acknowlist/blob/main/README.md Create custom Acknow instances to include licenses not found in standard configuration files. ```swift let acknow = Acknow(title: "...", text: "...") let viewController = AcknowListViewController(acknowledgements: [acknow]) ``` -------------------------------- ### Create Acknow Model Instances Source: https://context7.com/vtourraine/acknowlist/llms.txt Demonstrates creating `Acknow` instances with varying levels of detail, including title, text, license type, and repository URL. Accessing properties is also shown. ```swift import AcknowList // Create a simple acknowledgement with title and text let simpleAcknow = Acknow(title: "Alamofire", text: "MIT License text here...") // Create an acknowledgement with all properties let fullAcknow = Acknow( title: "SwiftyJSON", text: "Copyright (c) 2014 - 2023 Ruoyu Fu...", license: "MIT", repository: URL(string: "https://github.com/SwiftyJSON/SwiftyJSON") ) // Access properties print(fullAcknow.title) // "SwiftyJSON" print(fullAcknow.license) // Optional("MIT") print(fullAcknow.repository) // Optional(https://github.com/SwiftyJSON/SwiftyJSON) ``` -------------------------------- ### Create AcknowList Model Instance Source: https://context7.com/vtourraine/acknowlist/llms.txt Shows how to create an `AcknowList` instance, which holds a collection of `Acknow` objects along with optional header and footer text. Accessing list properties is also demonstrated. ```swift import AcknowList // Create acknowledgements array let acknowledgements = [ Acknow(title: "Alamofire", text: "MIT License..."), Acknow(title: "Kingfisher", text: "MIT License..."), Acknow(title: "SnapKit", text: "MIT License...") ] // Create an AcknowList with header and footer let acknowList = AcknowList( headerText: "This app uses the following open source libraries:", acknowledgements: acknowledgements, footerText: "Thank you to all the open source contributors!" ) // Access the list properties print(acknowList.headerText) // Optional header print(acknowList.acknowledgements.count) // 3 print(acknowList.footerText) // Optional footer ``` -------------------------------- ### Initialize AcknowListViewController Source: https://github.com/vtourraine/acknowlist/blob/main/README.md Standard initialization for pushing the acknowledgements controller onto a navigation stack. ```swift let viewController = AcknowListViewController() navigationController.pushViewController(viewController, animated: true) ``` -------------------------------- ### AcknowSwiftUIView (SwiftUI) Source: https://context7.com/vtourraine/acknowlist/llms.txt A SwiftUI view for displaying a single acknowledgement's license text, with automatic fetching of licenses from GitHub. ```APIDOC ## AcknowSwiftUIView (SwiftUI) ### Description A SwiftUI view that displays a single acknowledgement's license text. Automatically fetches missing licenses from GitHub if available. ### Usage ```swift import SwiftUI import AcknowList struct LicenseDetailView: View { let acknowledgement = Acknow( title: "Alamofire", text: "MIT License full text...", license: "MIT", repository: URL(string: "https://github.com/Alamofire/Alamofire") ) var body: some View { NavigationView { AcknowSwiftUIView(acknowledgement: acknowledgement) } } } // The view will automatically fetch license from GitHub API // if text is nil and repository is a valid GitHub URL struct AutoFetchLicenseView: View { let acknowledgement = Acknow( title: "SnapKit", text: nil, // Will be fetched from GitHub repository: URL(string: "https://github.com/SnapKit/SnapKit") ) var body: some View { NavigationView { AcknowSwiftUIView(acknowledgement: acknowledgement) } } } ``` ``` -------------------------------- ### Initialize AcknowListSwiftUIView in SwiftUI Source: https://context7.com/vtourraine/acknowlist/llms.txt Displays a list of acknowledgements with various initialization methods including default loading, custom arrays, model-based, and plist-based sources. ```swift import SwiftUI import AcknowList // Default initialization - auto-loads from CocoaPods and SPM struct SettingsView: View { var body: some View { NavigationView { AcknowListSwiftUIView() } } } // Initialize with custom acknowledgements struct CustomAcknowledgementsView: View { let acknowledgements = [ Acknow(title: "SwiftUI Library", text: "MIT License..."), Acknow(title: "Networking Framework", text: "Apache 2.0 License...") ] var body: some View { NavigationView { AcknowListSwiftUIView( acknowledgements: acknowledgements, headerText: "Third-Party Libraries", footerText: "Thank you open source community!" ) } } } // Initialize with AcknowList model struct ModelBasedView: View { var body: some View { NavigationView { if let acknowList = AcknowParser.defaultAcknowList() { AcknowListSwiftUIView(acknowList: acknowList) } } } } // Initialize from plist URL struct PlistBasedView: View { var body: some View { NavigationView { if let url = Bundle.main.url(forResource: "Pods-MyApp-acknowledgements", withExtension: "plist") { AcknowListSwiftUIView(plistFileURL: url) } } } } ``` -------------------------------- ### Customize Header and Footer Source: https://github.com/vtourraine/acknowlist/blob/main/README.md Manually set the header and footer text for the acknowledgements view. ```swift viewController.headerText = "We love open source software." viewController.footerText = "Powered by CocoaPods and SPM" ``` -------------------------------- ### Fetch GitHub Repository License Source: https://context7.com/vtourraine/acknowlist/llms.txt Fetches license information from GitHub's API for a given repository URL. Includes a helper to check if a URL is a GitHub repository and provides a cancellable task for fetching the license. ```swift import AcknowList // Check if URL is a GitHub repository let url = URL(string: "https://github.com/Alamofire/Alamofire")! if GitHubAPI.isGitHubRepository(url) { print("Valid GitHub repository") } // Fetch license from GitHub API GitHubAPI.getLicense(for: url) { result in switch result { case .success(let licenseText): print("License fetched successfully:") print(licenseText) case .failure(let error): print("Failed to fetch license: \(error)") } } // The task can be cancelled if needed let task = GitHubAPI.getLicense(for: url) { result in // Handle result } // task.cancel() // Cancel if needed ``` -------------------------------- ### Display Single Acknowledgement with AcknowSwiftUIView Source: https://context7.com/vtourraine/acknowlist/llms.txt Displays a single license text, with optional automatic GitHub license fetching when the text is nil and a repository URL is provided. ```swift import SwiftUI import AcknowList struct LicenseDetailView: View { let acknowledgement = Acknow( title: "Alamofire", text: "MIT License full text...", license: "MIT", repository: URL(string: "https://github.com/Alamofire/Alamofire") ) var body: some View { NavigationView { AcknowSwiftUIView(acknowledgement: acknowledgement) } } } // The view will automatically fetch license from GitHub API // if text is nil and repository is a valid GitHub URL struct AutoFetchLicenseView: View { let acknowledgement = Acknow( title: "SnapKit", text: nil, // Will be fetched from GitHub repository: URL(string: "https://github.com/SnapKit/SnapKit") ) var body: some View { NavigationView { AcknowSwiftUIView(acknowledgement: acknowledgement) } } } ``` -------------------------------- ### AcknowViewController (UIKit) Source: https://context7.com/vtourraine/acknowlist/llms.txt A UIKit view controller for displaying a single acknowledgement's full license text in a scrollable format. ```APIDOC ## AcknowViewController (UIKit) ### Description A UIKit view controller that displays a single acknowledgement's full license text with scrollable content. ### Usage ```swift import UIKit import AcknowList // Create and present a single acknowledgement view let acknowledgement = Acknow( title: "Alamofire", text: """ Copyright (c) 2014-2024 Alamofire Software Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction... """ ) let viewController = AcknowViewController(acknowledgement: acknowledgement) navigationController?.pushViewController(viewController, animated: true) // Access the text view for customization after viewDidLoad // viewController.textView?.font = .systemFont(ofSize: 14) ``` ``` -------------------------------- ### Present AcknowViewController in UIKit Source: https://context7.com/vtourraine/acknowlist/llms.txt Displays a single acknowledgement's full license text within a scrollable view controller. ```swift import UIKit import AcknowList // Create and present a single acknowledgement view let acknowledgement = Acknow( title: "Alamofire", text: """ Copyright (c) 2014-2024 Alamofire Software Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction... """ ) let viewController = AcknowViewController(acknowledgement: acknowledgement) navigationController?.pushViewController(viewController, animated: true) // Access the text view for customization after viewDidLoad // viewController.textView?.font = .systemFont(ofSize: 14) ``` -------------------------------- ### Use Localized Title Source: https://github.com/vtourraine/acknowlist/blob/main/README.md Retrieve the localized string for the acknowledgements title. ```swift button.setTitle(AcknowLocalization.localizedTitle(), for: .normal) ``` -------------------------------- ### Integrate AcknowList in UIKit and SwiftUI Source: https://context7.com/vtourraine/acknowlist/llms.txt Demonstrates how to trigger the AcknowList view controller from a UIKit table view and a SwiftUI sheet, alongside a method for merging custom acknowledgements with dependency manager data. ```swift import UIKit import SwiftUI import AcknowList // MARK: - UIKit Integration class SettingsTableViewController: UITableViewController { override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if indexPath.row == acknowledgementsRow { let viewController = AcknowListViewController() viewController.headerText = "This app is built with help from:" viewController.footerText = "Thank you to all contributors!" navigationController?.pushViewController(viewController, animated: true) } } private var acknowledgementsRow: Int { 0 } } // MARK: - SwiftUI Integration struct SettingsSwiftUIView: View { @State private var showingAcknowledgements = false var body: some View { List { Button("Acknowledgements") { showingAcknowledgements = true } } .sheet(isPresented: $showingAcknowledgements) { NavigationView { AcknowListSwiftUIView() .toolbar { ToolbarItem(placement: .cancellationAction) { Button("Done") { showingAcknowledgements = false } } } } } } } // MARK: - Combining CocoaPods and SPM with Custom Entries func createCombinedAcknowledgements() -> [Acknow] { var acknowledgements: [Acknow] = [] // Add from CocoaPods if let podsList = AcknowParser.defaultPods() { acknowledgements.append(contentsOf: podsList.acknowledgements) } // Add from Swift Package Manager if let packagesList = AcknowParser.defaultPackages() { acknowledgements.append(contentsOf: packagesList.acknowledgements) } // Add custom acknowledgements acknowledgements.append(Acknow( title: "Custom Icons", text: "Icons provided by IconArtist under Creative Commons license." )) // Sort alphabetically return AcknowLocalization.sorted(acknowledgements) } ``` -------------------------------- ### Set Table View Style Source: https://github.com/vtourraine/acknowlist/blob/main/README.md Specify the table view style during initialization. ```swift let viewController = AcknowListViewController(plistFileURL: url, style: .plain) ``` -------------------------------- ### AcknowParser Utility Source: https://context7.com/vtourraine/acknowlist/llms.txt Utility class for parsing acknowledgements from CocoaPods plist files and Swift Package Manager resolved files. ```APIDOC ## AcknowParser ### Description A utility class for parsing acknowledgements from CocoaPods plist files and Swift Package Manager resolved files. ### Parsing Methods 1. **Default Acknowledgements**: Auto-detects and parses both CocoaPods and SPM files. ```swift import AcknowList if let defaultList = AcknowParser.defaultAcknowList() { print("Found \(defaultList.acknowledgements.count) acknowledgements") print("Header: \(defaultList.headerText ?? "none")") print("Footer: \(defaultList.footerText ?? "none")") } ``` 2. **CocoaPods Acknowledgements**: Parses only CocoaPods acknowledgements. ```swift if let podsList = AcknowParser.defaultPods() { for acknow in podsList.acknowledgements { print("Pod: \(acknow.title)") } } ``` 3. **Swift Package Manager Dependencies**: Parses only Swift Package Manager dependencies. ```swift if let packagesList = AcknowParser.defaultPackages() { for acknow in packagesList.acknowledgements { print("Package: \(acknow.title) - \(acknow.repository?.absoluteString ?? "no URL")") } } ``` 4. **Find First Link**: Extracts the first URL found within a given text string. ```swift let licenseText = "Licensed under MIT. See https://opensource.org/licenses/MIT" if let url = AcknowParser.firstLink(in: licenseText) { print("Found link: \(url)") // https://opensource.org/licenses/MIT } ``` ``` -------------------------------- ### AcknowListSwiftUIView (SwiftUI) Source: https://context7.com/vtourraine/acknowlist/llms.txt A SwiftUI view that displays a list of acknowledgements, supporting navigation to detail views and various initialization methods. ```APIDOC ## AcknowListSwiftUIView (SwiftUI) ### Description A SwiftUI view that displays a list of acknowledgements with navigation to detail views. Supports iOS, macOS, tvOS, watchOS, and visionOS. ### Initialization Options 1. **Default Initialization**: Auto-loads acknowledgements from CocoaPods and SPM. ```swift struct SettingsView: View { var body: some View { NavigationView { AcknowListSwiftUIView() } } } ``` 2. **Custom Acknowledgements**: Initialize with a custom array of `Acknow` objects. ```swift struct CustomAcknowledgementsView: View { let acknowledgements = [ Acknow(title: "SwiftUI Library", text: "MIT License..."), Acknow(title: "Networking Framework", text: "Apache 2.0 License...") ] var body: some View { NavigationView { AcknowListSwiftUIView( acknowledgements: acknowledgements, headerText: "Third-Party Libraries", footerText: "Thank you open source community!" ) } } } ``` 3. **AcknowList Model**: Initialize with an `AcknowList` model. ```swift struct ModelBasedView: View { var body: some View { NavigationView { if let acknowList = AcknowParser.defaultAcknowList() { AcknowListSwiftUIView(acknowList: acknowList) } } } } ``` 4. **Plist File URL**: Initialize from a plist file URL. ```swift struct PlistBasedView: View { var body: some View { NavigationView { if let url = Bundle.main.url(forResource: "Pods-MyApp-acknowledgements", withExtension: "plist") { AcknowListSwiftUIView(plistFileURL: url) } } } } ``` ``` -------------------------------- ### Parse Acknowledgements with AcknowParser Source: https://context7.com/vtourraine/acknowlist/llms.txt Utility methods for extracting acknowledgement data from CocoaPods, SPM, or parsing links from license text. ```swift import AcknowList // Parse default acknowledgements (auto-detects CocoaPods and SPM files) if let defaultList = AcknowParser.defaultAcknowList() { print("Found \(defaultList.acknowledgements.count) acknowledgements") print("Header: \(defaultList.headerText ?? "none")") print("Footer: \(defaultList.footerText ?? "none")") } // Parse only CocoaPods acknowledgements if let podsList = AcknowParser.defaultPods() { for acknow in podsList.acknowledgements { print("Pod: \(acknow.title)") } } // Parse only Swift Package Manager dependencies if let packagesList = AcknowParser.defaultPackages() { for acknow in packagesList.acknowledgements { print("Package: \(acknow.title) - \(acknow.repository?.absoluteString ?? "no URL")") } } // Find first URL link in license text let licenseText = "Licensed under MIT. See https://opensource.org/licenses/MIT" if let url = AcknowParser.firstLink(in: licenseText) { print("Found link: \(url)") // https://opensource.org/licenses/MIT } ``` -------------------------------- ### Decode Swift Package Manager Resolved File Source: https://context7.com/vtourraine/acknowlist/llms.txt Decodes acknowledgements from a Swift Package Manager's `Package.resolved` file. Supports both v1 and v2 formats. Ensure the `Package.resolved` file is in the main bundle. ```swift import AcknowList // Decode from Package.resolved file guard let url = Bundle.main.url(forResource: "Package", withExtension: "resolved"), let data = try? Data(contentsOf: url) else { return } do { let decoder = AcknowPackageDecoder() let acknowList = try decoder.decode(from: data) for acknowledgement in acknowList.acknowledgements { print("Package: \(acknowledgement.title)") if let repository = acknowledgement.repository { print(" Repository: \(repository)") } } } catch { print("Failed to decode Package.resolved: \(error)") } ``` -------------------------------- ### Decode CocoaPods Acknowledgements Plist Source: https://context7.com/vtourraine/acknowlist/llms.txt Decodes acknowledgements from a CocoaPods-generated plist file. Ensure the plist file is correctly named and located in the main bundle. ```swift import AcknowList // Decode from a CocoaPods acknowledgements plist file guard let url = Bundle.main.url( forResource: "Pods-MyApp-acknowledgements", withExtension: "plist" ), let data = try? Data(contentsOf: url) else { return } do { let decoder = AcknowPodDecoder() let acknowList = try decoder.decode(from: data) print("Header: \(acknowList.headerText ?? \"none\")") print("Footer: \(acknowList.footerText ?? \"none\")") for acknowledgement in acknowList.acknowledgements { print("- \(acknowledgement.title)") print(" License type: \(acknowledgement.license ?? \"unknown\")") } } catch { print("Failed to decode: \(error)") } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.