DomainDig/AppLinks.swift

2ad5d8160338d289a65d6a4d1c214a02bf916f1f
domain-dig/DomainDig/AppLinks.swift history · blame · raw

34 lines · 1529 bytes

2 symbols in this file
 1import Foundation
 2
 3/// Centralized external destinations, kept in one place so URLs and the App Store
 4/// identifier can be swapped without touching any view.
 5///
 6/// `documentation` points at the repository README for now; swap in a dedicated
 7/// docs site if one lands.
 8enum AppLinks {
 9    /// App Store numeric identifier; the listing/review/share URLs derive from it.
10    static let appStoreID = "6760368004"
11
12    static let sourceCode = url("https://github.com/krz-labs/domain-dig")
13    static let documentation = url("https://github.com/krz-labs/domain-dig#readme")
14    static let privacyPolicy = url("https://krz.sh/privacy/domain-dig/")
15    static let termsOfUse = url("https://www.apple.com/legal/internet-services/itunes/dev/stdeula/")
16    static let supportEmail = "root@krz.sh"
17
18    static var appStoreListing: URL { url("https://apps.apple.com/app/id\(appStoreID)") }
19    static var writeReview: URL { url("https://apps.apple.com/app/id\(appStoreID)?action=write-review") }
20
21    static var copyright: String {
22        let year = Calendar.current.component(.year, from: Date())
23        return "© \(year) Christian Cleberg"
24    }
25
26    /// Builds URLs from developer-controlled literals; a malformed literal is a
27    /// programming error, surfaced loudly in development rather than force-unwrapped.
28    private static func url(_ string: String) -> URL {
29        guard let url = URL(string: string) else {
30            preconditionFailure("Invalid AppLinks URL literal: \(string)")
31        }
32        return url
33    }
34}