From 2342553c02aa7d0c500e0567e3e241554aa2bff6 Mon Sep 17 00:00:00 2001 From: Florian Friedrich Date: Thu, 28 Sep 2023 12:35:01 +0200 Subject: [PATCH] Add Swift 5.9 support --- CODEOWNERS => .github/CODEOWNERS | 0 .github/dependabot.yml | 21 +- .github/workflows/docs.yml | 238 ++---------------- .github/workflows/enable-auto-merge.yml | 4 +- .github/workflows/swift-test.yml | 164 +++--------- .gitignore | 18 +- .../xcschemes/app-information.xcscheme | 92 +++++++ Package.resolved | 23 ++ Package.swift | 25 +- Package@swift-5.6.swift | 27 -- Package@swift-5.7.swift | 27 -- README.md | 2 +- .../Model/AppInfo+AppleID.swift | 6 +- Sources/AppInformation/Model/AppInfo.swift | 10 +- Tests/AppInformationTests/AppInfoTests.swift | 15 +- 15 files changed, 235 insertions(+), 437 deletions(-) rename CODEOWNERS => .github/CODEOWNERS (100%) create mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/app-information.xcscheme create mode 100644 Package.resolved delete mode 100644 Package@swift-5.6.swift delete mode 100644 Package@swift-5.7.swift diff --git a/CODEOWNERS b/.github/CODEOWNERS similarity index 100% rename from CODEOWNERS rename to .github/CODEOWNERS diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0b244e4..1cdf9b2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,13 +1,24 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: github-actions + directory: / open-pull-requests-limit: 10 schedule: - interval: "daily" - time: "07:00" - timezone: "Europe/Berlin" + interval: daily + time: 07:00 + timezone: Europe/Berlin + assignees: + - ffried + reviewers: + - ffried + - package-ecosystem: swift + directory: / + open-pull-requests-limit: 10 + schedule: + interval: daily + time: 07:00 + timezone: Europe/Berlin assignees: - ffried reviewers: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 494b350..485cc10 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -8,229 +8,19 @@ on: push: branches: [ main ] -jobs: - release-context: - runs-on: ubuntu-latest - outputs: - version-name: ${{ github.ref_name }} - is-latest: ${{ steps.compare-tags.outputs.is-latest }} - steps: - - uses: joutvhu/get-release@v1 - id: latest-release - with: - latest: true - throwing: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Compare tags - id: compare-tags - env: - REF_TYPE: ${{ github.ref_type }} - REF_NAME: ${{ github.ref_name }} - LATEST_TAG: ${{ steps.latest-release.outputs.tag_name }} - run: | - if [ "${REF_TYPE}" == 'tag' ] && [ "${REF_NAME}" == "${LATEST_TAG}" ]; then - echo 'is-latest=true' >> "${GITHUB_OUTPUT}" - else - echo 'is-latest=false' >> "${GITHUB_OUTPUT}" - fi - - spm-context: - runs-on: ubuntu-latest - outputs: - package-dump: ${{ steps.dump-package.outputs.package-dump }} - steps: - - uses: swift-actions/setup-swift@v1.24.0 - with: - swift-version: '5.7' - - uses: actions/checkout@v4 - # We don't use a cache here, because SPM doesn't resolve dependencies when dumping packages. - - name: Dump package - id: dump-package - run: | - delimiter="$(openssl rand -hex 8)" - echo "package-dump<<${delimiter}" >> "${GITHUB_OUTPUT}" - swift package dump-package >> "${GITHUB_OUTPUT}" - echo "${delimiter}" >> "${GITHUB_OUTPUT}" +permissions: + contents: write - generate-docs: - needs: - - release-context - - spm-context - runs-on: macos-12 - strategy: - matrix: - target: ${{ fromJson(needs.spm-context.outputs.package-dump).products.*.targets.* }} - steps: - - uses: swift-actions/setup-swift@v1.24.0 - id: swift-setup - with: - swift-version: '5.7' - - name: Read OS Version - uses: sersoft-gmbh/os-version-action@v3 - id: os-version - - uses: actions/checkout@v4 - - uses: actions/cache@v3 - with: - path: .build - key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-setup.outputs.version }}-${{ hashFiles('**/Package.resolved') }} - restore-keys: | - ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-setup.outputs.version }}- - - uses: sersoft-gmbh/swifty-docs-action@v3 - env: - ENABLE_DOCC_SUPPORT: '1' - DOCC_JSON_PRETTYPRINT: 'YES' - with: - package-version: ${{ needs.release-context.outputs.version-name }} - targets: ${{ matrix.target }} - enable-inherited-docs: true - enable-index-building: false - transform-for-static-hosting: true - hosting-base-path: ${{ github.event.repository.name }}/${{ needs.release-context.outputs.version-name }} - output: ${{ matrix.target }}-docs - - name: Package docs - env: - TARGET: ${{ matrix.target }} - run: tar -cvf "${TARGET}-docs.tar" "${TARGET}-docs" - - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.target }}-docs - path: ${{ matrix.target }}-docs.tar +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true - publish-docs: - needs: - - release-context - - spm-context - - generate-docs - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: gh-pages - path: repository - - uses: actions/download-artifact@v3 - with: - path: artifacts - - name: Extract tars - run: find artifacts -name '*.tar' -execdir tar -xvf '{}' --strip-components 1 \; -delete - - name: Merge documentations - env: - TARGETS: ${{ join(fromJson(needs.spm-context.outputs.package-dump).products.*.targets.*, ' ') }} - DOCS_BASE_DIR: repository/${{ needs.release-context.outputs.version-name }} - run: | - rm -rf "${DOCS_BASE_DIR}" - is_first=1 - for target in $TARGETS; do - if [ $is_first -eq 1 ]; then - echo "Copying initial documentation for ${target}" - cp -R "artifacts/${target}-docs" "${DOCS_BASE_DIR}" - is_first=0 - else - echo "Merging documentation for ${target}" - cp -R "artifacts/${target}-docs/data/documentation/"* "${DOCS_BASE_DIR}/data/documentation/" - cp -R "artifacts/${target}-docs/documentation/"* "${DOCS_BASE_DIR}/documentation/" - fi - done - echo "Deleting non-mergable metadata.json" - rm -f "${DOCS_BASE_DIR}/metadata.json" - - name: Create version index - working-directory: repository - env: - TARGET_DOCS_DIR: ${{ needs.release-context.outputs.version-name }}/documentation - INDEX_FILE: ${{ needs.release-context.outputs.version-name }}/index.html - BASE_URL: 'https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ needs.release-context.outputs.version-name }}/documentation' - REPO_NAME: ${{ github.event.repository.name }} - run: | - target_count=0 - target_list="" - single_target_name="" - for target in $(ls "${TARGET_DOCS_DIR}"); do - if [ -d "${TARGET_DOCS_DIR}/${target}" ]; then - single_target_name="${target}" - target_count=$((target_count+1)) - target_list="${target_list}
  • ${target} Documentation
  • " - fi - done - if [ ${target_count} -gt 1 ]; then - echo "Found ${target_count} targets. Generating list..." - cat > "${INDEX_FILE}" < - - - ${REPO_NAME} Documentation - - - - - - EOF - else - echo "Found one target. Generating redirect file to target ${single_target_name}" - cat > "${INDEX_FILE}" < - - - ${REPO_NAME} Documentation - - - -

    Redirecting...

    - - - EOF - fi - - name: Create root index - working-directory: repository - env: - REDIRECT_URL: 'https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/latest' - REPO_NAME: ${{ github.event.repository.name }} - run: | - cat > 'index.html' < - - - ${REPO_NAME} Documentation - - - -

    Redirecting...

    - - - EOF - - name: Create latest symlink - if: ${{ needs.release-context.outputs.is-latest }} - working-directory: repository - env: - VERSION_NAME: ${{ needs.release-context.outputs.version-name }} - run: | - rm -f 'latest' - ln -s "${VERSION_NAME}" 'latest' - - name: Determine changes - id: check-changes - working-directory: repository - run: | - if [ -n "$(git status --porcelain)" ]; then - echo 'has-changes=true' >> "${GITHUB_OUTPUT}" - else - echo 'has-changes=false' >> "${GITHUB_OUTPUT}" - fi - - uses: crazy-max/ghaction-github-pages@v4 - if: ${{ steps.check-changes.outputs.has-changes }} - with: - keep_history: true - build_dir: repository - commit_message: Deploy documentation for '${{ needs.release-context.outputs.version-name }}' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - cleanup: - needs: - - generate-docs - - publish-docs - if: ${{ always() }} - runs-on: ubuntu-latest - steps: - - name: Cleanup Artifacts - uses: joutvhu/delete-artifact@v1 +jobs: + generate-and-publish-docs: + uses: sersoft-gmbh/oss-common-actions/.github/workflows/swift-generate-and-publish-docs.yml@main + with: + os: macOS + swift-version: '5.9' + organisation: ${{ github.repository_owner }} + repository: ${{ github.event.repository.name }} + pages-branch: gh-pages diff --git a/.github/workflows/enable-auto-merge.yml b/.github/workflows/enable-auto-merge.yml index 6b3a13a..74fbf98 100644 --- a/.github/workflows/enable-auto-merge.yml +++ b/.github/workflows/enable-auto-merge.yml @@ -1,6 +1,8 @@ name: Auto-merge for Dependabot PRs -on: pull_request +on: + pull_request: + branches: [ main ] permissions: contents: write diff --git a/.github/workflows/swift-test.yml b/.github/workflows/swift-test.yml index fa4e42a..b642300 100644 --- a/.github/workflows/swift-test.yml +++ b/.github/workflows/swift-test.yml @@ -6,67 +6,37 @@ on: pull_request: branches: [ main ] +permissions: + contents: read + jobs: + variables: + outputs: + max-supported-swift-version: '5.9' + xcode-scheme: app-information + xcode-platform-version: latest + fail-if-codecov-fails: true + runs-on: ubuntu-latest + steps: + - run: exit 0 + test-spm: + needs: variables strategy: matrix: - os: [ macos-12 ] - swift-version: [ '' ] - xcode-version: [ '^13.4' ] - include: - - os: macos-12 - swift-version: '' - xcode-version: '^14.1' - - os: ubuntu-20.04 - swift-version: 5.6 - xcode-version: '' - - os: ubuntu-20.04 - swift-version: 5.7 - xcode-version: '' - - os: ubuntu-22.04 - swift-version: 5.7 - xcode-version: '' - - runs-on: ${{ matrix.os }} - - steps: - - if: ${{ runner.os == 'macOS' }} - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: ${{ matrix.xcode-version }} - - name: Install Swift - if: ${{ runner.os == 'Linux' }} - uses: sersoft-gmbh/swifty-linux-action@v3 - with: - release-version: ${{ matrix.swift-version }} - platform: ${{ matrix.os }} - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Read OS Version - uses: sersoft-gmbh/os-version-action@v3 - id: os-version - - name: Read Swift Version - uses: sersoft-gmbh/swift-version-action@v3 - id: swift-version - - uses: actions/checkout@v4 - - uses: actions/cache@v3 - with: - path: .build - key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-version.outputs.version }}-${{ hashFiles('**/Package.resolved') }} - restore-keys: | - ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-version.outputs.version }}- - - name: Build & Test - run: swift test -v --parallel --enable-code-coverage - - name: Generate Coverage Files - uses: sersoft-gmbh/swift-coverage-action@v4 - id: coverage-files - - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ${{ join(fromJSON(steps.coverage-files.outputs.files), ',') }} - fail_ci_if_error: true + os: [ macOS, ubuntu ] + swift-version-offset: [ 0 ] + uses: sersoft-gmbh/oss-common-actions/.github/workflows/swift-test-spm.yml@main + with: + os: ${{ matrix.os }} + max-swift-version: ${{ needs.variables.outputs.max-supported-swift-version }} + swift-version-offset: ${{ matrix.swift-version-offset }} + fail-if-codecov-fails: ${{ fromJson(needs.variables.outputs.fail-if-codecov-fails) }} + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} test-xcode: - runs-on: macos-12 + needs: variables strategy: matrix: platform: @@ -75,76 +45,14 @@ jobs: - iPadOS - tvOS - watchOS - env: - XCODE_SCHEME: app-information - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: ^14.1 - - name: Read OS Version - uses: sersoft-gmbh/os-version-action@v3 - id: os-version - - name: Read Swift Version - uses: sersoft-gmbh/swift-version-action@v3 - id: swift-version - - name: Select destination - id: destination - env: - PLATFORM: ${{ matrix.platform }} - run: | - DESTINATION='' - case "${PLATFORM}" in - 'macOS') DESTINATION='platform=macOS';; - 'iOS') DESTINATION='platform=iOS Simulator,OS=latest,name=iPhone 13 Pro';; - 'iPadOS') DESTINATION='platform=iOS Simulator,OS=latest,name=iPad Pro (11-inch) (3rd generation)';; - 'tvOS') DESTINATION='platform=tvOS Simulator,OS=latest,name=Apple TV 4K (2nd generation)';; - 'watchOS') DESTINATION='platform=watchOS Simulator,OS=latest,name=Apple Watch Series 7 (45mm)';; - *) echo "::error title=Unknown platform!::Unknown platform: ${PLATFORM}" && exit 1;; - esac - echo "xcode=${DESTINATION}" >> "${GITHUB_OUTPUT}" - - uses: actions/checkout@v4 - # PIF ISSUES: https://github.com/apple/swift-package-manager/issues/5767 - - uses: actions/cache@v3 - with: - path: .build - key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-version.outputs.version }}-${{ hashFiles('**/Package.resolved') }} - restore-keys: | - ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-version.outputs.version }}- - - name: Work around PIF issues - env: - DESTINATION: ${{ steps.destination.outputs.xcode }} - run: | - swift package dump-pif > /dev/null - ATTEMPT=0 - while [ -z "${SUCCESS}" ] && [ "${ATTEMPT}" -le 5 ]; do - xcodebuild clean -scheme "${XCODE_SCHEME}" -destination "${DESTINATION}" | grep -q "CLEAN SUCCEEDED" && SUCCESS=true - ATTEMPT=$((ATTEMPT + 1)) - done - # END PIF ISSUES - - uses: actions/cache@v3 - with: - path: .derived-data - key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-xcode-${{ steps.swift-version.outputs.version }}-${{ matrix.platform }}-${{ hashFiles('**/Package.resolved') }} - restore-keys: | - ${{ runner.os }}-${{ steps.os-version.outputs.version }}-xcode-${{ steps.swift-version.outputs.version }}-${{ matrix.platform }}- - - uses: sersoft-gmbh/xcodebuild-action@v3 - with: - spm-package: './' - scheme: ${{ env.XCODE_SCHEME }} - destination: ${{ steps.destination.outputs.xcode }} - action: test - parallel-testing-enabled: ${{ matrix.platform != 'watchOS' }} - enable-code-coverage: true - derived-data-path: .derived-data - - uses: sersoft-gmbh/swift-coverage-action@v4 - id: coverage-files - with: - search-paths: | - ./.build - ./.derived-data - $HOME/Library/Developer/Xcode/DerivedData - - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ${{ join(fromJSON(steps.coverage-files.outputs.files), ',') }} - fail_ci_if_error: true + swift-version-offset: [ 0 ] + uses: sersoft-gmbh/oss-common-actions/.github/workflows/swift-test-xcode.yml@main + with: + xcode-scheme: ${{ needs.variables.outputs.xcode-scheme }} + max-swift-version: ${{ needs.variables.outputs.max-supported-swift-version }} + swift-version-offset: ${{ matrix.swift-version-offset }} + platform: ${{ matrix.platform }} + platform-version: ${{ needs.variables.outputs.xcode-platform-version }} + fail-if-codecov-fails: ${{ fromJson(needs.variables.outputs.fail-if-codecov-fails) }} + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore index 6cb6e6f..5bd10af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,22 @@ .DS_Store + /.build -/.swiftpm /Packages /*.xcodeproj xcuserdata/ +DerivedData/ +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata + +# VS Code +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/app-information.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/app-information.xcscheme new file mode 100644 index 0000000..40ed866 --- /dev/null +++ b/.swiftpm/xcode/xcshareddata/xcschemes/app-information.xcscheme @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..e65252d --- /dev/null +++ b/Package.resolved @@ -0,0 +1,23 @@ +{ + "pins" : [ + { + "identity" : "swift-docc-plugin", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-docc-plugin", + "state" : { + "revision" : "26ac5758409154cc448d7ab82389c520fa8a8247", + "version" : "1.3.0" + } + }, + { + "identity" : "swift-docc-symbolkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-docc-symbolkit", + "state" : { + "revision" : "b45d1f2ed151d057b54504d653e0da5552844e34", + "version" : "1.0.0" + } + } + ], + "version" : 2 +} diff --git a/Package.swift b/Package.swift index e679a1a..f407c36 100644 --- a/Package.swift +++ b/Package.swift @@ -2,7 +2,16 @@ // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription -import Foundation + +let swiftSettings: Array = [ + .enableUpcomingFeature("ConciseMagicFile"), + .enableUpcomingFeature("ExistentialAny"), + .enableUpcomingFeature("BareSlashRegexLiterals"), + .enableUpcomingFeature("DisableOutwardActorInference"), +// .enableExperimentalFeature("AccessLevelOnImport"), +// .enableExperimentalFeature("VariadicGenerics"), +// .unsafeFlags(["-warn-concurrency"], .when(configuration: .debug)), +] let package = Package( name: "app-information", @@ -12,16 +21,18 @@ let package = Package( name: "AppInformation", targets: ["AppInformation"]), ], + dependencies: [ + .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), + ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target(name: "AppInformation"), + .target( + name: "AppInformation", + swiftSettings: swiftSettings), .testTarget( name: "AppInformationTests", - dependencies: ["AppInformation"]), + dependencies: ["AppInformation"], + swiftSettings: swiftSettings), ] ) - -if ProcessInfo.processInfo.environment["ENABLE_DOCC_SUPPORT"] == "1" { - package.dependencies.append(.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")) -} diff --git a/Package@swift-5.6.swift b/Package@swift-5.6.swift deleted file mode 100644 index 1a04eea..0000000 --- a/Package@swift-5.6.swift +++ /dev/null @@ -1,27 +0,0 @@ -// swift-tools-version:5.6 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription -import Foundation - -let package = Package( - name: "app-information", - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "AppInformation", - targets: ["AppInformation"]), - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target(name: "AppInformation"), - .testTarget( - name: "AppInformationTests", - dependencies: ["AppInformation"]), - ] -) - -if ProcessInfo.processInfo.environment["ENABLE_DOCC_SUPPORT"] == "1" { - package.dependencies.append(.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")) -} diff --git a/Package@swift-5.7.swift b/Package@swift-5.7.swift deleted file mode 100644 index 2b45849..0000000 --- a/Package@swift-5.7.swift +++ /dev/null @@ -1,27 +0,0 @@ -// swift-tools-version:5.7 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription -import Foundation - -let package = Package( - name: "app-information", - products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. - .library( - name: "AppInformation", - targets: ["AppInformation"]), - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages this package depends on. - .target(name: "AppInformation"), - .testTarget( - name: "AppInformationTests", - dependencies: ["AppInformation"]), - ] -) - -if ProcessInfo.processInfo.environment["ENABLE_DOCC_SUPPORT"] == "1" { - package.dependencies.append(.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")) -} diff --git a/README.md b/README.md index b59ca29..ba3cae8 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ A simple package for storing as well as showing app infos. Add the following dependency to your `Package.swift`: ```swift -.package(url: "https://github.com/sersoft-gmbh/app-information.git", from: "1.0.0"), +.package(url: "https://github.com/sersoft-gmbh/app-information", from: "1.0.0"), ``` Or add it via Xcode (as of Xcode 11). diff --git a/Sources/AppInformation/Model/AppInfo+AppleID.swift b/Sources/AppInformation/Model/AppInfo+AppleID.swift index 4780b42..78ac8ef 100644 --- a/Sources/AppInformation/Model/AppInfo+AppleID.swift +++ b/Sources/AppInformation/Model/AppInfo+AppleID.swift @@ -5,7 +5,7 @@ import struct Foundation.URLComponents extension AppInfo { /// Represents an AppleID of an application (usually a numerical value). @frozen - public struct AppleID: RawRepresentable, ExpressibleByStringLiteral, Hashable, Codable, Sendable { + public struct AppleID: RawRepresentable, Sendable, ExpressibleByStringLiteral, Hashable, Codable { public typealias RawValue = String public typealias StringLiteralType = RawValue.StringLiteralType @@ -16,7 +16,7 @@ extension AppInfo { /// The app store url for this AppleID. public var appStoreURL: URL { let component = "id\(rawValue)" -#if canImport(Darwin) && compiler(>=5.7.1) +#if canImport(Darwin) if #available(macOS 13, iOS 16, tvOS 16, watchOS 9, *) { return Self.appStoreBaseURL.appending(component: component) } else { @@ -35,7 +35,7 @@ extension AppInfo { comps.queryItems = (comps.queryItems ?? []) + CollectionOfOne(queryItem) return comps.url! } -#if canImport(Darwin) && compiler(>=5.7.1) +#if canImport(Darwin) if #available(macOS 13, iOS 16, tvOS 16, watchOS 9, *) { return appStoreURL.appending(queryItems: [queryItem]) } else { diff --git a/Sources/AppInformation/Model/AppInfo.swift b/Sources/AppInformation/Model/AppInfo.swift index e0a160c..65116f9 100644 --- a/Sources/AppInformation/Model/AppInfo.swift +++ b/Sources/AppInformation/Model/AppInfo.swift @@ -2,9 +2,9 @@ import class Foundation.Bundle import class Foundation.ProcessInfo /// Contains the information for an application (e.g. naming and versioning). -public struct AppInfo: Equatable, Identifiable, Sendable { +public struct AppInfo: Sendable, Equatable, Identifiable { /// The naming information. - public struct Naming: Equatable, Sendable { + public struct Naming: Sendable, Equatable { /// The unlocalized set of names. public let unlocalized: (base: String, display: String?) /// The localized set of names. @@ -32,13 +32,13 @@ public struct AppInfo: Equatable, Identifiable, Sendable { } /// The versioning information. - public struct Versioning: Equatable, Sendable { + public struct Versioning: Sendable, Equatable { /// The version, e.g. 1.0.0. public let version: String /// The build, e.g. 42. public let build: String - /// The combined version information, formatted as " ()" + /// The combined version information, formatted as `" ()"` public var combined: String { "\(version) (\(build))" } } @@ -65,7 +65,7 @@ extension AppInfo { /// - Parameter appleID: The appleID to use. Defaults to `nil`, in which case it is attempted to read it /// from the `AppInformationAppleID` key in the bundle's info dictionary. public init(bundle: Bundle, appleID: AppleID? = nil) { - let infoDict = bundle.infoDictionary ?? [:] + let infoDict = bundle.infoDictionary ?? .init() identifier = bundle.bundleIdentifier ?? String(ProcessInfo.processInfo.processIdentifier) names = Naming(infoDict: infoDict, localizedInfoDict: bundle.localizedInfoDictionary) versioning = Versioning(infoDict: infoDict) diff --git a/Tests/AppInformationTests/AppInfoTests.swift b/Tests/AppInformationTests/AppInfoTests.swift index 6b210c6..1d7acdd 100644 --- a/Tests/AppInformationTests/AppInfoTests.swift +++ b/Tests/AppInformationTests/AppInfoTests.swift @@ -12,11 +12,11 @@ final class AppInfoTests: XCTestCase { override var bundleIdentifier: String? { _identifier } var _infoDict: Dictionary? - override var infoDictionary: [String : Any]? { _infoDict } - + override var infoDictionary: Dictionary? { _infoDict } + var _localizedInfoDict: Dictionary? - override var localizedInfoDictionary: [String : Any]? { _localizedInfoDict } - + override var localizedInfoDictionary: Dictionary? { _localizedInfoDict } + init(path: String, identifier: String? = nil, infoDict: Dictionary? = nil, @@ -189,9 +189,8 @@ final class AppInfoTests: XCTestCase { func testSwiftUIEnvironment() throws { #if arch(arm64) || arch(x86_64) #if canImport(SwiftUI) && canImport(Combine) - guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) else { - throw XCTSkip() - } + guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) + else { throw XCTSkip() } let info = AppInfo(bundle: FakeBundle(path: bundlePath)) var env = EnvironmentValues() XCTAssertEqual(env.appInfo, .current) @@ -209,7 +208,7 @@ final class AppInfoTests: XCTestCase { fileprivate func XCTAssertEqual(_ lhs: @autoclosure () throws -> (T1, T2), _ rhs: @autoclosure () throws -> (T1, T2), _ message: @autoclosure () -> String = "", - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line) { XCTAssert(try lhs() == rhs(), message(), file: file, line: line) }