Enable SwiftLint inside of Xcode
This commit also fixes all linter warnings and errors.
This commit is contained in:
parent
941d465570
commit
3c30a4b336
7 changed files with 130 additions and 21 deletions
|
|
@ -4,7 +4,6 @@ import SwiftUI
|
||||||
@main
|
@main
|
||||||
@MainActor
|
@MainActor
|
||||||
struct BurrowApp: App {
|
struct BurrowApp: App {
|
||||||
|
|
||||||
static let tunnel = Tunnel { manager, proto in
|
static let tunnel = Tunnel { manager, proto in
|
||||||
proto.serverAddress = "hackclub.com"
|
proto.serverAddress = "hackclub.com"
|
||||||
manager.localizedDescription = "Burrow"
|
manager.localizedDescription = "Burrow"
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ extension Tunnel {
|
||||||
return "Disabled"
|
return "Disabled"
|
||||||
case .connecting:
|
case .connecting:
|
||||||
return "Connecting"
|
return "Connecting"
|
||||||
case .connected(_):
|
case .connected:
|
||||||
return "Connected"
|
return "Connected"
|
||||||
case .disconnecting:
|
case .disconnecting:
|
||||||
return "Disconnecting"
|
return "Disconnecting"
|
||||||
|
|
@ -40,4 +40,3 @@ extension Tunnel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
import Combine
|
||||||
import NetworkExtension
|
import NetworkExtension
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Combine
|
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
class Tunnel: ObservableObject {
|
class Tunnel: ObservableObject {
|
||||||
|
|
@ -61,10 +61,6 @@ class Tunnel: ObservableObject {
|
||||||
tasks = [statusTask, configurationTask]
|
tasks = [statusTask, configurationTask]
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
|
||||||
tasks.forEach { $0.cancel() }
|
|
||||||
}
|
|
||||||
|
|
||||||
func update() async {
|
func update() async {
|
||||||
do {
|
do {
|
||||||
managers = try await NETunnelProviderManager.managers
|
managers = try await NETunnelProviderManager.managers
|
||||||
|
|
@ -111,9 +107,13 @@ class Tunnel: ObservableObject {
|
||||||
guard let manager = managers?.first else { return }
|
guard let manager = managers?.first else { return }
|
||||||
manager.connection.stopVPNTunnel()
|
manager.connection.stopVPNTunnel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
tasks.forEach { $0.cancel() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension NEVPNConnection {
|
extension NEVPNConnection {
|
||||||
var tunnelStatus: Tunnel.Status {
|
var tunnelStatus: Tunnel.Status {
|
||||||
switch status {
|
switch status {
|
||||||
case .connected:
|
case .connected:
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,13 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct TunnelView: View {
|
struct TunnelView: View {
|
||||||
|
@ObservedObject var tunnel: Tunnel
|
||||||
@ObservedObject
|
|
||||||
var tunnel: Tunnel
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
Text(verbatim: tunnel.status.description)
|
Text(verbatim: tunnel.status.description)
|
||||||
switch tunnel.status {
|
switch tunnel.status {
|
||||||
case .connected(_):
|
case .connected:
|
||||||
Button("Disconnect", action: stop)
|
Button("Disconnect", action: stop)
|
||||||
case .permissionRequired:
|
case .permissionRequired:
|
||||||
Button("Allow", action: configure)
|
Button("Allow", action: configure)
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,7 @@
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
dependencies = (
|
dependencies = (
|
||||||
|
D0BCC6122A0B328800AD070D /* PBXTargetDependency */,
|
||||||
);
|
);
|
||||||
name = NetworkExtension;
|
name = NetworkExtension;
|
||||||
productName = BurrowNetworkExtension;
|
productName = BurrowNetworkExtension;
|
||||||
|
|
@ -194,6 +195,7 @@
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
dependencies = (
|
dependencies = (
|
||||||
|
D0BCC6142A0B329200AD070D /* PBXTargetDependency */,
|
||||||
D020F65C29E4A697002790F6 /* PBXTargetDependency */,
|
D020F65C29E4A697002790F6 /* PBXTargetDependency */,
|
||||||
);
|
);
|
||||||
name = App;
|
name = App;
|
||||||
|
|
@ -228,6 +230,9 @@
|
||||||
Base,
|
Base,
|
||||||
);
|
);
|
||||||
mainGroup = D05B9F6929E39EEC008CB1F9;
|
mainGroup = D05B9F6929E39EEC008CB1F9;
|
||||||
|
packageReferences = (
|
||||||
|
D0BCC6102A0B327700AD070D /* XCRemoteSwiftPackageReference "SwiftLint" */,
|
||||||
|
);
|
||||||
productRefGroup = D05B9F7329E39EEC008CB1F9 /* Products */;
|
productRefGroup = D05B9F7329E39EEC008CB1F9 /* Products */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
|
|
@ -309,6 +314,14 @@
|
||||||
target = D020F65229E4A697002790F6 /* NetworkExtension */;
|
target = D020F65229E4A697002790F6 /* NetworkExtension */;
|
||||||
targetProxy = D020F65B29E4A697002790F6 /* PBXContainerItemProxy */;
|
targetProxy = D020F65B29E4A697002790F6 /* PBXContainerItemProxy */;
|
||||||
};
|
};
|
||||||
|
D0BCC6122A0B328800AD070D /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
productRef = D0BCC6112A0B328800AD070D /* SwiftLintPlugin */;
|
||||||
|
};
|
||||||
|
D0BCC6142A0B329200AD070D /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
productRef = D0BCC6132A0B329200AD070D /* SwiftLintPlugin */;
|
||||||
|
};
|
||||||
/* End PBXTargetDependency section */
|
/* End PBXTargetDependency section */
|
||||||
|
|
||||||
/* Begin XCBuildConfiguration section */
|
/* Begin XCBuildConfiguration section */
|
||||||
|
|
@ -385,6 +398,30 @@
|
||||||
defaultConfigurationName = Release;
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
|
|
||||||
|
/* Begin XCRemoteSwiftPackageReference section */
|
||||||
|
D0BCC6102A0B327700AD070D /* XCRemoteSwiftPackageReference "SwiftLint" */ = {
|
||||||
|
isa = XCRemoteSwiftPackageReference;
|
||||||
|
repositoryURL = "https://github.com/realm/SwiftLint.git";
|
||||||
|
requirement = {
|
||||||
|
kind = upToNextMajorVersion;
|
||||||
|
minimumVersion = 0.51.0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/* End XCRemoteSwiftPackageReference section */
|
||||||
|
|
||||||
|
/* Begin XCSwiftPackageProductDependency section */
|
||||||
|
D0BCC6112A0B328800AD070D /* SwiftLintPlugin */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = D0BCC6102A0B327700AD070D /* XCRemoteSwiftPackageReference "SwiftLint" */;
|
||||||
|
productName = "plugin:SwiftLintPlugin";
|
||||||
|
};
|
||||||
|
D0BCC6132A0B329200AD070D /* SwiftLintPlugin */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = D0BCC6102A0B327700AD070D /* XCRemoteSwiftPackageReference "SwiftLint" */;
|
||||||
|
productName = "plugin:SwiftLintPlugin";
|
||||||
|
};
|
||||||
|
/* End XCSwiftPackageProductDependency section */
|
||||||
};
|
};
|
||||||
rootObject = D05B9F6A29E39EEC008CB1F9 /* Project object */;
|
rootObject = D05B9F6A29E39EEC008CB1F9 /* Project object */;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
{
|
||||||
|
"pins" : [
|
||||||
|
{
|
||||||
|
"identity" : "collectionconcurrencykit",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/JohnSundell/CollectionConcurrencyKit.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "b4f23e24b5a1bff301efc5e70871083ca029ff95",
|
||||||
|
"version" : "0.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "sourcekitten",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/jpsim/SourceKitten.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "b6dc09ee51dfb0c66e042d2328c017483a1a5d56",
|
||||||
|
"version" : "0.34.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "swift-argument-parser",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/apple/swift-argument-parser.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "fee6933f37fde9a5e12a1e4aeaa93fe60116ff2a",
|
||||||
|
"version" : "1.2.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "swift-syntax",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/apple/swift-syntax.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "013a48e2312e57b7b355db25bd3ea75282ebf274",
|
||||||
|
"version" : "0.50900.0-swift-DEVELOPMENT-SNAPSHOT-2023-02-06-a"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "swiftlint",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/realm/SwiftLint.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "eb85125a5f293de3d3248af259980c98bc2b1faa",
|
||||||
|
"version" : "0.51.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "swiftytexttable",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/scottrhoyt/SwiftyTextTable.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "c6df6cf533d120716bff38f8ff9885e1ce2a4ac3",
|
||||||
|
"version" : "0.9.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "swxmlhash",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/drmohundro/SWXMLHash.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "4d0f62f561458cbe1f732171e625f03195151b60",
|
||||||
|
"version" : "7.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "yams",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/jpsim/Yams.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "f47ba4838c30dbd59998a4e4c87ab620ff959e8a",
|
||||||
|
"version" : "5.0.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 2
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import NetworkExtension
|
import NetworkExtension
|
||||||
|
|
||||||
class PacketTunnelProvider: NEPacketTunnelProvider {
|
class PacketTunnelProvider: NEPacketTunnelProvider {
|
||||||
|
override func startTunnel(options: [String: NSObject]?, completionHandler: @escaping (Error?) -> Void) {
|
||||||
override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) {
|
|
||||||
completionHandler(nil)
|
completionHandler(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue