Make App/Core iOS/Catalyst only

- Drop macOS target from Package.swift

- Drop @available attributes
    - UI idiom
    - Intents API
    - Swipe actions in ProviderLocationView

- Review os(iOS)
    - DebugLog, append idiom to tell Mac from iPad

- Drop redundant canImport
This commit is contained in:
Davide De Rosa 2022-04-19 14:18:26 +02:00
parent a6c7305528
commit f1aa192c9c
18 changed files with 19 additions and 131 deletions

View File

@ -37,7 +37,6 @@ extension Color {
}
extension View {
@available(iOS 14, *)
var themeIdiom: UIUserInterfaceIdiom {
UIDevice.current.userInterfaceIdiom
}

View File

@ -132,7 +132,6 @@ extension IntentDispatcher {
}
private static func handleCellularNetwork(_ trust: Bool, _ vpnManager: VPNManager) {
#if os(iOS)
Task {
do {
try await vpnManager.modifyActiveProfile {
@ -142,7 +141,6 @@ extension IntentDispatcher {
pp_log.error("Unable to modify cellular trust: \(error)")
}
}
#endif
}
private static func handleCurrentNetwork(_ trust: Bool, _ vpnManager: VPNManager) {

View File

@ -25,9 +25,7 @@
import Foundation
import Intents
#if canImport(IntentsUI)
import IntentsUI
#endif
import Combine
@MainActor
@ -65,7 +63,6 @@ class IntentsManager: NSObject, ObservableObject {
}
}
@available(iOS 12, macOS 12, *)
extension IntentsManager: INUIAddVoiceShortcutViewControllerDelegate {
func addVoiceShortcutViewController(_ controller: INUIAddVoiceShortcutViewController, didFinishWith voiceShortcut: INVoiceShortcut?, error: Error?) {
guard let vs = voiceShortcut else {
@ -81,7 +78,6 @@ extension IntentsManager: INUIAddVoiceShortcutViewControllerDelegate {
}
}
@available(iOS 12, macOS 12, *)
extension IntentsManager: INUIEditVoiceShortcutViewControllerDelegate {
func editVoiceShortcutViewController(_ controller: INUIEditVoiceShortcutViewController, didUpdate voiceShortcut: INVoiceShortcut?, error: Error?) {
guard let vs = voiceShortcut else {

View File

@ -23,7 +23,6 @@
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
//
#if canImport(StoreKit)
import Foundation
import StoreKit
@ -222,4 +221,3 @@ extension SKProduct {
return localizedCurrencyFormatter.string(from: price)
}
}
#endif

View File

@ -23,7 +23,6 @@
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
//
#if os(iOS) && canImport(StoreKit)
import UIKit
import StoreKit
@ -93,4 +92,3 @@ public class Reviewer: ObservableObject {
return URL(string: "https://apps.apple.com/app/id\(appId)?action=write-review")!
}
}
#endif

View File

@ -25,11 +25,8 @@
import SwiftUI
import Intents
#if canImport(IntentsUI)
import IntentsUI
#endif
@available(iOS 12, macOS 12, *)
struct IntentAddView: UIViewControllerRepresentable {
let shortcut: INShortcut

View File

@ -25,11 +25,8 @@
import SwiftUI
import Intents
#if canImport(IntentsUI)
import IntentsUI
#endif
@available(iOS 12, macOS 12, *)
struct IntentEditView: UIViewControllerRepresentable {
let shortcut: Shortcut

View File

@ -23,9 +23,7 @@
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
//
#if canImport(MessageUI)
import SwiftUI
import Combine
import MessageUI
struct MailComposerView: UIViewControllerRepresentable {
@ -76,4 +74,3 @@ struct MailComposerView: UIViewControllerRepresentable {
Coordinator(self)
}
}
#endif

View File

@ -32,7 +32,7 @@ struct AboutView: View {
private let readmeURL = Constants.URLs.readme
private let changelogURL = Constants.URLs.iOS.changelog
private let changelogURL = Constants.URLs.changelog
private let homeURL = Constants.URLs.website

View File

@ -122,7 +122,7 @@ struct ProviderLocationView: View, ProviderProfileAvailability {
@ViewBuilder
private func toolbar() -> some View {
if #available(iOS 15, macOS 12, *) {
if #available(iOS 15, *) {
Button {
withAnimation {
isShowingFavorites.toggle()
@ -144,7 +144,7 @@ struct ProviderLocationView: View, ProviderProfileAvailability {
header: !category.name.isEmpty ? Text(category.name) : nil
) {
ForEach(filteredLocations(for: category)) { location in
if isEditable, #available(iOS 15, macOS 12, *) {
if isEditable, #available(iOS 15, *) {
locationRow(location)
.swipeActions(edge: .trailing, allowsFullSwipe: false) {
favoriteActions(location)
@ -197,7 +197,7 @@ struct ProviderLocationView: View, ProviderProfileAvailability {
}
}
@available(iOS 15, macOS 12, *)
@available(iOS 15, *)
private func favoriteActions(_ location: ProviderLocation) -> some View {
Button {
withAnimation {

View File

@ -144,12 +144,10 @@ struct ShortcutsView: View {
}
}
@available(iOS 12, macOS 12, *)
private func presentEditShortcut(_ shortcut: Shortcut) {
modalType = .edit(shortcut: shortcut)
}
@available(iOS 12, macOS 12, *)
private func presentAddShortcut(_ shortcut: INShortcut) {
isNavigationPresented = false
modalType = .add(shortcut: shortcut)

View File

@ -20,34 +20,6 @@
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PassepartoutUtilsTests"
BuildableName = "PassepartoutUtilsTests"
BlueprintName = "PassepartoutUtilsTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PassepartoutServicesTests"
BuildableName = "PassepartoutServicesTests"
BlueprintName = "PassepartoutServicesTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction

View File

@ -1,52 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1330"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PassepartoutProfilesTests"
BuildableName = "PassepartoutProfilesTests"
BlueprintName = "PassepartoutProfilesTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -23,34 +23,22 @@
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
//
import Foundation
#if os(iOS)
import Foundation
import UIKit
#else
import Cocoa
#endif
extension DebugLog {
public func decoratedString(_ appName: String, _ appVersion: String) -> String {
var metadata: [String] = []
let osVersion: String
let deviceType: String?
let device: UIDevice = .current
let osVersion = "\(device.systemName) \(device.systemVersion)"
let deviceModel = device.model
let deviceIdiom = device.userInterfaceIdiom
#if os(iOS)
let device = UIDevice.current
osVersion = "\(device.systemName) \(device.systemVersion)"
deviceType = device.model
#else
let os = ProcessInfo().operatingSystemVersion
osVersion = "macOS \(os.majorVersion).\(os.minorVersion).\(os.patchVersion)"
deviceType = nil
#endif
metadata.append("App: \(appName) \(appVersion)")
metadata.append("OS: \(osVersion)")
if let deviceType = deviceType {
metadata.append("Device: \(deviceType)")
}
let metadata = [
"App: \(appName) \(appVersion)",
"OS: \(osVersion)",
"Device: \(deviceModel) (\(deviceIdiom))"
]
var fullText = metadata.joined(separator: "\n")
fullText += "\n\n"
@ -66,3 +54,4 @@ extension DebugLog {
return data
}
}
#endif

View File

@ -50,11 +50,13 @@ extension Profile.OnDemand {
var rules: [NEOnDemandRule] = []
if withCustomRules {
#if os(iOS)
if withMobileNetwork {
let rule = policyRule
rule.interfaceTypeMatch = .cellular
rules.append(rule)
}
#endif
if withEthernetNetwork {
if let compatibleEthernet = NEOnDemandRuleInterfaceType.compatibleEthernet {
let rule = policyRule

@ -1 +1 @@
Subproject commit ba2b959d493b00359f1f3e2040e35ce6a31e2c74
Subproject commit 9e4db9da5a3216b51624bb1726972e7443cabbe0

View File

@ -25,7 +25,6 @@
import Foundation
import StoreKit
#if os(iOS)
import UIKit
#else

@ -1 +1 @@
Subproject commit 4602f7cb05f5b907ee5e5a9309964cb335db9b59
Subproject commit c8422d9313e8f2dc69b44d19909464e82d7f6b37