AcknowList

repository·main·Indexed 21 days ago

https://github.com/vtourraine/acknowlist

A library for displaying an acknowledgements screen containing a list of licenses from CocoaPods and Swift Package Manager dependencies. It provides dual interfaces for UIKit (AcknowListViewController) and SwiftUI (AcknowListSwiftUIView), featuring automatic loading from .plist and Package.resolved files, customizable headers and footers, and support for iOS, tvOS, visionOS, watchOS, and macOS.

Tokens
1.7K
Snippets
5
Records
8
Agent score
25%

What's inside AcknowList

  1. Overview of AcknowList

    main

    AcknowList is a library for displaying an acknowledgements screen containing a list of licenses (e.g., from CocoaPods dependencies).

    Key features include:

    • Customizable header and footer.
    • Tappable links within license text.
    • Localized default titles and footers.
    • Automatic loading and formatting of acknowledgments from CocoaPods and Swift Package Manager files.
    • Support for Storyboard configuration, Dark Mode, Dynamic Type, and accessibility features.
    • Dual interfaces for both UIKit and SwiftUI.
  2. AcknowList Core Components

    main

    The library is organized into several functional areas:

    Model

    Defines the data structures for acknowledgments:

    • Acknow: Represents an individual acknowledgment entry.
    • AcknowList: The primary model representing the collection of acknowledgments.

    Parser

    Handles the extraction of license data from dependency files:

    • AcknowParser: The main parsing interface.
    • AcknowPackageDecoder: Decodes Swift Package Manager files.
    • AcknowPodDecoder: Decodes CocoaPods files.

    Localization

    • AcknowLocalization: Manages localized strings for titles and footers.

    UI Interfaces

    • UIKit: Use AcknowListViewController or AcknowViewController for standard view controller integration.
    • SwiftUI: Use AcknowListSwiftUIView or AcknowSwiftUIView for SwiftUI-based applications.
  3. Install AcknowList via CocoaPods

    main

    To install AcknowList using CocoaPods, follow these steps:

    1. Add pod 'AcknowList' to your Podfile.
    2. Run pod install.
    3. Add the generated CocoaPods acknowledgements file to your main target. Locate the file Pods-#target#-acknowledgements.plist in the Pods/Target Support Files/Pods-#target#/ folder. Drag and drop it into your Xcode project. Important: Do not check Copy items if needed during the drag-and-drop process; you want to reference the file, not copy it.
    # Podfile
    pod 'AcknowList'
  4. Install AcknowList via Swift Package Manager

    main

    To install AcknowList using Swift Package Manager (requires Xcode 12+):

    1. In Xcode, go to FileAdd Packages….
    2. Enter the repository URL: https://github.com/vtourraine/AcknowList.
    3. Select your desired version.
    4. Add the generated Package.resolved file to your main target. Locate the file and drag/drop it into your Xcode project. Important: Do not check Copy items if needed.

    File Locations for Package.resolved:

    • Single Xcode projects: [appName].xcodeproj/project.xcworkspace/xcshareddata/swiftpm/
    • Xcode workspaces (e.g., with CocoaPods): [appName].xcworkspace/xcshareddata/swiftpm/
    https://github.com/vtourraine/AcknowList
  5. Use AcknowList in SwiftUI

    main

    AcknowList provides a AcknowListSwiftUIView for SwiftUI projects. You can instantiate it using either a path to a .plist file or an array of Acknow instances. It is intended to be presented within a NavigationView.

    // Example usage in SwiftUI
    struct AcknowledgementsView: View {
        var body: some View {
            NavigationView {
                AcknowListSwiftUIView(acknowledgements: [
                    Acknow(title: "Example", text: "License text...")
                ])
            }
        }
    }
  6. Customize AcknowListViewController appearance

    main

    You can customize the header text, footer text, and the table view style of the AcknowListViewController.

    // Customize header and footer
    viewController.headerText = "We love open source software."
    viewController.footerText = "Powered by CocoaPods and SPM"
    
    // Change table view style (e.g., to .plain)
    let viewController = AcknowListViewController(plistFileURL: url, style: .plain)
    
    // Use the localized title for your presenting button
    button.setTitle(AcknowLocalization.localizedTitle(), for: .normal)
  7. Initialize AcknowListViewController (UIKit)

    main

    The AcknowListViewController is typically pushed onto a UINavigationController. By default, it attempts to automatically load acknowledgements from CocoaPods (.plist) or Swift Package Manager (Package.resolved) files.

    You can also initialize it with a specific file name, a file URL, or a custom array of Acknow objects.

    // Default initialization (auto-detects CocoaPods/SPM files)
    let viewController = AcknowListViewController()
    navigationController.pushViewController(viewController, animated: true)
    
    // Initialize with a specific plist file name
    let viewController = AcknowListViewController(fileNamed: "Pods-AcknowExample-acknowledgements")
    
    // Initialize with a specific file URL
    let url = Bundle.main.url(forResource: "Pods-AcknowExample-acknowledgements", withExtension: "plist")
    let viewController = AcknowListViewController(plistFileURL: url)
    
    // Initialize with custom Acknow instances
    let acknow = Acknow(title: "Custom Title", text: "Custom License Text")
    let viewController = AcknowListViewController(acknowledgements: [acknow])
  8. AcknowList Platform Support and Compatibility

    main

    AcknowList supports multiple platforms, but note the differences between UIKit and SwiftUI availability.

    PlatformUIKitSwiftUI
    📱 iOS9.0+13.0+
    📺 tvOS9.0+13.0+
    🥽 visionOS1.0+1.0+
    ⌚️ watchOSnot supported7.0+
    💻 macOSnot supported10.15+

    ⚠️ Important Compatibility Note: If you install AcknowList via CocoaPods or Swift Package Manager, it will require iOS 13 and tvOS 13 due to dependency requirements.

    To support earlier versions (iOS 9+):

    1. Import the library manually.
    2. Ignore the SwiftUI classes.
    3. Alternatively, use VTAcknowledgementsViewController instead.