├── .gitignore ├── Clash.xcodeproj ├── project.pbxproj └── xcshareddata │ └── xcschemes │ ├── Clash.xcscheme │ ├── PacketTunnel.xcscheme │ └── ShareLib.xcscheme ├── Clash ├── AppDelegate.swift ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── icon_1024.png │ │ ├── icon_120.png │ │ ├── icon_152.png │ │ ├── icon_167.png │ │ ├── icon_180.png │ │ ├── icon_20.png │ │ ├── icon_29.png │ │ ├── icon_40.png │ │ ├── icon_58.png │ │ ├── icon_60.png │ │ ├── icon_76.png │ │ ├── icon_80.png │ │ └── icon_87.png │ └── Contents.json ├── Clash.entitlements ├── ClashApp.swift ├── ClashTrafficFormatter.swift ├── ContentView.swift ├── Country.mmdb ├── DocumentPickerView.swift ├── Home │ ├── ClashConfigView.swift │ ├── ClashHomeView.swift │ ├── ClashTrafficView.swift │ ├── ClashTunnelModeView.swift │ ├── InstallVPNView.swift │ ├── VPNConnecteDurationView.swift │ └── VPNStateView.swift ├── Info.plist ├── List │ ├── ClashConfigImportButton.swift │ ├── ClashConfigImportView.swift │ └── ClashConfigListView.swift ├── ManagedObjectFetchView.swift ├── ModalPresentationLink.swift ├── NSManagedObjectContext+File.swift ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json ├── Setting │ ├── ClashLogView.swift │ ├── SettingView.swift │ └── UninstallVPNView.swift └── VPNManager.swift ├── CommonKit ├── ClashCommand.swift ├── ClashError.swift ├── ClashLogLevel.swift ├── ClashTraffic.swift ├── ClashTunnelMode.swift ├── CommonKit.h ├── Constant.swift ├── CoreData │ ├── Clash.xcdatamodeld │ │ └── Clash.xcdatamodel │ │ │ └── contents │ └── CoreDataStack.swift └── UserDefaults+AppGroup.swift ├── Config-Debug.xcconfig ├── Config-Release.xcconfig ├── Config.xcconfig ├── LICENSE ├── PacketTunnel ├── Info.plist ├── PacketTunnel.entitlements ├── PacketTunnelProvider+Clash.swift └── PacketTunnelProvider.swift └── README.txt /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/swift,xcode,swiftpackagemanager 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=swift,xcode,swiftpackagemanager 4 | 5 | ### Swift ### 6 | # Xcode 7 | # 8 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 9 | 10 | ## User settings 11 | xcuserdata/ 12 | 13 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 14 | *.xcscmblueprint 15 | *.xccheckout 16 | 17 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 18 | build/ 19 | DerivedData/ 20 | *.moved-aside 21 | *.pbxuser 22 | !default.pbxuser 23 | *.mode1v3 24 | !default.mode1v3 25 | *.mode2v3 26 | !default.mode2v3 27 | *.perspectivev3 28 | !default.perspectivev3 29 | 30 | ## Obj-C/Swift specific 31 | *.hmap 32 | 33 | ## App packaging 34 | *.ipa 35 | *.dSYM.zip 36 | *.dSYM 37 | 38 | ## Playgrounds 39 | timeline.xctimeline 40 | playground.xcworkspace 41 | 42 | # Swift Package Manager 43 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 44 | # Packages/ 45 | # Package.pins 46 | # Package.resolved 47 | # *.xcodeproj 48 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 49 | # hence it is not needed unless you have added a package configuration file to your project 50 | # .swiftpm 51 | 52 | .build/ 53 | 54 | # CocoaPods 55 | # We recommend against adding the Pods directory to your .gitignore. However 56 | # you should judge for yourself, the pros and cons are mentioned at: 57 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 58 | # Pods/ 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 64 | # Carthage/Checkouts 65 | 66 | Carthage/Build/ 67 | 68 | # Accio dependency management 69 | Dependencies/ 70 | .accio/ 71 | 72 | # fastlane 73 | # It is recommended to not store the screenshots in the git repo. 74 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 75 | # For more information about the recommended setup visit: 76 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 77 | 78 | fastlane/report.xml 79 | fastlane/Preview.html 80 | fastlane/screenshots/**/*.png 81 | fastlane/test_output 82 | 83 | # Code Injection 84 | # After new code Injection tools there's a generated folder /iOSInjectionProject 85 | # https://github.com/johnno1962/injectionforxcode 86 | 87 | iOSInjectionProject/ 88 | 89 | 90 | ### Xcode ### 91 | 92 | ## Xcode 8 and earlier 93 | 94 | ### Xcode Patch ### 95 | *.xcodeproj/* 96 | !*.xcodeproj/project.pbxproj 97 | !*.xcodeproj/xcshareddata/ 98 | !*.xcworkspace/contents.xcworkspacedata 99 | /*.gcno 100 | **/xcshareddata/WorkspaceSettings.xcsettings 101 | 102 | **/ClashKit.xcframework 103 | 104 | # End of https://www.toptal.com/developers/gitignore/api/swift,xcode,swiftpackagemanager -------------------------------------------------------------------------------- /Clash.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 55; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 70A9E33C279ED48E00E6E8AF /* DocumentPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70A9E33B279ED48E00E6E8AF /* DocumentPickerView.swift */; }; 11 | D913C9A427BF2F6500A790FF /* Config.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = D913C9A327BF2F6500A790FF /* Config.xcconfig */; }; 12 | D913C9A627BF2F6500A790FF /* Config.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = D913C9A327BF2F6500A790FF /* Config.xcconfig */; }; 13 | D913C9A827BF2F7900A790FF /* Config-Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = D913C9A727BF2F7900A790FF /* Config-Debug.xcconfig */; }; 14 | D913C9AA27BF2F7900A790FF /* Config-Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = D913C9A727BF2F7900A790FF /* Config-Debug.xcconfig */; }; 15 | D955EE5327A513D6003C072A /* NSManagedObjectContext+File.swift in Sources */ = {isa = PBXBuildFile; fileRef = D955EE5227A513D6003C072A /* NSManagedObjectContext+File.swift */; }; 16 | D958FB3D27D8AE84009BDFEA /* InstallVPNView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D958FB3C27D8AE84009BDFEA /* InstallVPNView.swift */; }; 17 | D958FB3F27D8AEBF009BDFEA /* UninstallVPNView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D958FB3E27D8AEBF009BDFEA /* UninstallVPNView.swift */; }; 18 | D964786627A0E455003A6648 /* ClashHomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D964786527A0E455003A6648 /* ClashHomeView.swift */; }; 19 | D964786927A0E793003A6648 /* ClashConfigListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D964786827A0E793003A6648 /* ClashConfigListView.swift */; }; 20 | D964786B27A12718003A6648 /* ManagedObjectFetchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D964786A27A12718003A6648 /* ManagedObjectFetchView.swift */; }; 21 | D964787527A266FB003A6648 /* VPNManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D964787427A266FB003A6648 /* VPNManager.swift */; }; 22 | D9823B6D27CCD81C0043A9FB /* PacketTunnelProvider+Clash.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9823B6C27CCD81C0043A9FB /* PacketTunnelProvider+Clash.swift */; }; 23 | D9A3992727CF6BA70047E47D /* ClashConfigView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A3992627CF6BA70047E47D /* ClashConfigView.swift */; }; 24 | D9A3992927CF6E800047E47D /* VPNStateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A3992827CF6E800047E47D /* VPNStateView.swift */; }; 25 | D9A3992B27D06B430047E47D /* ClashTraffic.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A3992A27D06B430047E47D /* ClashTraffic.swift */; }; 26 | D9A3992D27D07E4A0047E47D /* ModalPresentationLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A3992C27D07E4A0047E47D /* ModalPresentationLink.swift */; }; 27 | D9A3992F27D094050047E47D /* ClashConfigImportButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A3992E27D094050047E47D /* ClashConfigImportButton.swift */; }; 28 | D9ACEEFF2797F45F0004E32D /* ClashApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9ACEEFE2797F45F0004E32D /* ClashApp.swift */; }; 29 | D9ACEF012797F45F0004E32D /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9ACEF002797F45F0004E32D /* ContentView.swift */; }; 30 | D9ACEF032797F4640004E32D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D9ACEF022797F4640004E32D /* Assets.xcassets */; }; 31 | D9ACEF062797F4640004E32D /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D9ACEF052797F4640004E32D /* Preview Assets.xcassets */; }; 32 | D9ACEF162797FCFE0004E32D /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9ACEF152797FCFE0004E32D /* NetworkExtension.framework */; }; 33 | D9ACEF1C2797FD4B0004E32D /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9ACEF152797FCFE0004E32D /* NetworkExtension.framework */; }; 34 | D9ACEF1F2797FD4B0004E32D /* PacketTunnelProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9ACEF1E2797FD4B0004E32D /* PacketTunnelProvider.swift */; }; 35 | D9ACEF242797FD4B0004E32D /* PacketTunnel.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = D9ACEF1B2797FD4B0004E32D /* PacketTunnel.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 36 | D9B4FC7B27CE0C240018035A /* CommonKit.h in Headers */ = {isa = PBXBuildFile; fileRef = D9B4FC7A27CE0C240018035A /* CommonKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; 37 | D9B4FC7E27CE0C240018035A /* CommonKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9B4FC7827CE0C240018035A /* CommonKit.framework */; }; 38 | D9B4FC7F27CE0C240018035A /* CommonKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D9B4FC7827CE0C240018035A /* CommonKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 39 | D9B4FC8327CE0C370018035A /* Constant.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9823B6227CCD06F0043A9FB /* Constant.swift */; }; 40 | D9B4FC8427CE0C370018035A /* UserDefaults+AppGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9823B6627CCD25D0043A9FB /* UserDefaults+AppGroup.swift */; }; 41 | D9B4FC8527CE0C370018035A /* ClashTunnelMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9823B6A27CCD7AF0043A9FB /* ClashTunnelMode.swift */; }; 42 | D9B4FC8627CE0C370018035A /* ClashCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9823B6E27CCD9420043A9FB /* ClashCommand.swift */; }; 43 | D9B4FC8727CE0C370018035A /* ClashError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D955EE5427A51F57003C072A /* ClashError.swift */; }; 44 | D9B4FC8B27CF01880018035A /* ClashTunnelModeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B4FC8A27CF01880018035A /* ClashTunnelModeView.swift */; }; 45 | D9B4FC8D27CF07E60018035A /* ClashTrafficView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B4FC8C27CF07E60018035A /* ClashTrafficView.swift */; }; 46 | D9B4FC8F27CF0A670018035A /* ClashTrafficFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B4FC8E27CF0A670018035A /* ClashTrafficFormatter.swift */; }; 47 | D9B4FC9327CF28100018035A /* ClashKit in Frameworks */ = {isa = PBXBuildFile; productRef = D9B4FC9227CF28100018035A /* ClashKit */; }; 48 | D9B4FC9727CF38980018035A /* VPNConnecteDurationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B4FC9627CF38980018035A /* VPNConnecteDurationView.swift */; }; 49 | D9BBA6A927980571002420FA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9BBA6A827980571002420FA /* AppDelegate.swift */; }; 50 | D9BBA6AB27980B52002420FA /* Country.mmdb in Resources */ = {isa = PBXBuildFile; fileRef = D9BBA6AA27980B52002420FA /* Country.mmdb */; }; 51 | D9BBA841279EAE26002420FA /* ClashConfigImportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9BBA840279EAE26002420FA /* ClashConfigImportView.swift */; }; 52 | D9D9ED4B27D6EB82006CDF61 /* CoreDataStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9647861279FE3C6003A6648 /* CoreDataStack.swift */; }; 53 | D9D9ED4C27D6EB88006CDF61 /* Clash.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = D964785E279FE37A003A6648 /* Clash.xcdatamodeld */; }; 54 | D9D9ED4E27D7152F006CDF61 /* ClashLogView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9D9ED4D27D7152F006CDF61 /* ClashLogView.swift */; }; 55 | D9D9ED5027D72ADD006CDF61 /* ClashLogLevel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9D9ED4F27D72ADD006CDF61 /* ClashLogLevel.swift */; }; 56 | D9D9ED5327D76328006CDF61 /* SettingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9D9ED5227D76327006CDF61 /* SettingView.swift */; }; 57 | /* End PBXBuildFile section */ 58 | 59 | /* Begin PBXContainerItemProxy section */ 60 | D9ACEF222797FD4B0004E32D /* PBXContainerItemProxy */ = { 61 | isa = PBXContainerItemProxy; 62 | containerPortal = D9ACEEF32797F45F0004E32D /* Project object */; 63 | proxyType = 1; 64 | remoteGlobalIDString = D9ACEF1A2797FD4B0004E32D; 65 | remoteInfo = PacketTunnel; 66 | }; 67 | D9B4FC7C27CE0C240018035A /* PBXContainerItemProxy */ = { 68 | isa = PBXContainerItemProxy; 69 | containerPortal = D9ACEEF32797F45F0004E32D /* Project object */; 70 | proxyType = 1; 71 | remoteGlobalIDString = D9B4FC7727CE0C240018035A; 72 | remoteInfo = CommonKit; 73 | }; 74 | D9B4FC8827CE0D160018035A /* PBXContainerItemProxy */ = { 75 | isa = PBXContainerItemProxy; 76 | containerPortal = D9ACEEF32797F45F0004E32D /* Project object */; 77 | proxyType = 1; 78 | remoteGlobalIDString = D9B4FC7727CE0C240018035A; 79 | remoteInfo = CommonKit; 80 | }; 81 | /* End PBXContainerItemProxy section */ 82 | 83 | /* Begin PBXCopyFilesBuildPhase section */ 84 | D9ACEF282797FD4B0004E32D /* Embed App Extensions */ = { 85 | isa = PBXCopyFilesBuildPhase; 86 | buildActionMask = 2147483647; 87 | dstPath = ""; 88 | dstSubfolderSpec = 13; 89 | files = ( 90 | D9ACEF242797FD4B0004E32D /* PacketTunnel.appex in Embed App Extensions */, 91 | ); 92 | name = "Embed App Extensions"; 93 | runOnlyForDeploymentPostprocessing = 0; 94 | }; 95 | D9ACEF392797FDBB0004E32D /* Embed Frameworks */ = { 96 | isa = PBXCopyFilesBuildPhase; 97 | buildActionMask = 2147483647; 98 | dstPath = ""; 99 | dstSubfolderSpec = 10; 100 | files = ( 101 | D9B4FC7F27CE0C240018035A /* CommonKit.framework in Embed Frameworks */, 102 | ); 103 | name = "Embed Frameworks"; 104 | runOnlyForDeploymentPostprocessing = 0; 105 | }; 106 | /* End PBXCopyFilesBuildPhase section */ 107 | 108 | /* Begin PBXFileReference section */ 109 | 70A9E33B279ED48E00E6E8AF /* DocumentPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentPickerView.swift; sourceTree = ""; }; 110 | D913C9A327BF2F6500A790FF /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; 111 | D913C9A727BF2F7900A790FF /* Config-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Config-Debug.xcconfig"; sourceTree = ""; }; 112 | D913C9AB27BF2F8700A790FF /* Config-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Config-Release.xcconfig"; sourceTree = ""; }; 113 | D955EE5227A513D6003C072A /* NSManagedObjectContext+File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSManagedObjectContext+File.swift"; sourceTree = ""; }; 114 | D955EE5427A51F57003C072A /* ClashError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashError.swift; sourceTree = ""; }; 115 | D958FB3C27D8AE84009BDFEA /* InstallVPNView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallVPNView.swift; sourceTree = ""; }; 116 | D958FB3E27D8AEBF009BDFEA /* UninstallVPNView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UninstallVPNView.swift; sourceTree = ""; }; 117 | D964785F279FE37A003A6648 /* Clash.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Clash.xcdatamodel; sourceTree = ""; }; 118 | D9647861279FE3C6003A6648 /* CoreDataStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataStack.swift; sourceTree = ""; }; 119 | D964786527A0E455003A6648 /* ClashHomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashHomeView.swift; sourceTree = ""; }; 120 | D964786827A0E793003A6648 /* ClashConfigListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashConfigListView.swift; sourceTree = ""; }; 121 | D964786A27A12718003A6648 /* ManagedObjectFetchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManagedObjectFetchView.swift; sourceTree = ""; }; 122 | D964787427A266FB003A6648 /* VPNManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNManager.swift; sourceTree = ""; }; 123 | D9823B6227CCD06F0043A9FB /* Constant.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constant.swift; sourceTree = ""; }; 124 | D9823B6627CCD25D0043A9FB /* UserDefaults+AppGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserDefaults+AppGroup.swift"; sourceTree = ""; }; 125 | D9823B6A27CCD7AF0043A9FB /* ClashTunnelMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashTunnelMode.swift; sourceTree = ""; }; 126 | D9823B6C27CCD81C0043A9FB /* PacketTunnelProvider+Clash.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PacketTunnelProvider+Clash.swift"; sourceTree = ""; }; 127 | D9823B6E27CCD9420043A9FB /* ClashCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashCommand.swift; sourceTree = ""; }; 128 | D9A3992627CF6BA70047E47D /* ClashConfigView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashConfigView.swift; sourceTree = ""; }; 129 | D9A3992827CF6E800047E47D /* VPNStateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNStateView.swift; sourceTree = ""; }; 130 | D9A3992A27D06B430047E47D /* ClashTraffic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashTraffic.swift; sourceTree = ""; }; 131 | D9A3992C27D07E4A0047E47D /* ModalPresentationLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalPresentationLink.swift; sourceTree = ""; }; 132 | D9A3992E27D094050047E47D /* ClashConfigImportButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashConfigImportButton.swift; sourceTree = ""; }; 133 | D9ACEEFB2797F45F0004E32D /* Clash.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Clash.app; sourceTree = BUILT_PRODUCTS_DIR; }; 134 | D9ACEEFE2797F45F0004E32D /* ClashApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashApp.swift; sourceTree = ""; }; 135 | D9ACEF002797F45F0004E32D /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 136 | D9ACEF022797F4640004E32D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 137 | D9ACEF052797F4640004E32D /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 138 | D9ACEF0C2797F4880004E32D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 139 | D9ACEF132797FCEA0004E32D /* Clash.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Clash.entitlements; sourceTree = ""; }; 140 | D9ACEF152797FCFE0004E32D /* NetworkExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NetworkExtension.framework; path = System/Library/Frameworks/NetworkExtension.framework; sourceTree = SDKROOT; }; 141 | D9ACEF1B2797FD4B0004E32D /* PacketTunnel.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = PacketTunnel.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 142 | D9ACEF1E2797FD4B0004E32D /* PacketTunnelProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PacketTunnelProvider.swift; sourceTree = ""; }; 143 | D9ACEF202797FD4B0004E32D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 144 | D9ACEF212797FD4B0004E32D /* PacketTunnel.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PacketTunnel.entitlements; sourceTree = ""; }; 145 | D9B4FC7827CE0C240018035A /* CommonKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CommonKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 146 | D9B4FC7A27CE0C240018035A /* CommonKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CommonKit.h; sourceTree = ""; }; 147 | D9B4FC8A27CF01880018035A /* ClashTunnelModeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashTunnelModeView.swift; sourceTree = ""; }; 148 | D9B4FC8C27CF07E60018035A /* ClashTrafficView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashTrafficView.swift; sourceTree = ""; }; 149 | D9B4FC8E27CF0A670018035A /* ClashTrafficFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashTrafficFormatter.swift; sourceTree = ""; }; 150 | D9B4FC9627CF38980018035A /* VPNConnecteDurationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNConnecteDurationView.swift; sourceTree = ""; }; 151 | D9BBA6A827980571002420FA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 152 | D9BBA6AA27980B52002420FA /* Country.mmdb */ = {isa = PBXFileReference; lastKnownFileType = file; path = Country.mmdb; sourceTree = ""; }; 153 | D9BBA840279EAE26002420FA /* ClashConfigImportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashConfigImportView.swift; sourceTree = ""; }; 154 | D9D9ED4D27D7152F006CDF61 /* ClashLogView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashLogView.swift; sourceTree = ""; }; 155 | D9D9ED4F27D72ADD006CDF61 /* ClashLogLevel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashLogLevel.swift; sourceTree = ""; }; 156 | D9D9ED5227D76327006CDF61 /* SettingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingView.swift; sourceTree = ""; }; 157 | /* End PBXFileReference section */ 158 | 159 | /* Begin PBXFrameworksBuildPhase section */ 160 | D9ACEEF82797F45F0004E32D /* Frameworks */ = { 161 | isa = PBXFrameworksBuildPhase; 162 | buildActionMask = 2147483647; 163 | files = ( 164 | D9B4FC7E27CE0C240018035A /* CommonKit.framework in Frameworks */, 165 | D9ACEF162797FCFE0004E32D /* NetworkExtension.framework in Frameworks */, 166 | D9B4FC9327CF28100018035A /* ClashKit in Frameworks */, 167 | ); 168 | runOnlyForDeploymentPostprocessing = 0; 169 | }; 170 | D9ACEF182797FD4B0004E32D /* Frameworks */ = { 171 | isa = PBXFrameworksBuildPhase; 172 | buildActionMask = 2147483647; 173 | files = ( 174 | D9ACEF1C2797FD4B0004E32D /* NetworkExtension.framework in Frameworks */, 175 | ); 176 | runOnlyForDeploymentPostprocessing = 0; 177 | }; 178 | D9B4FC7527CE0C240018035A /* Frameworks */ = { 179 | isa = PBXFrameworksBuildPhase; 180 | buildActionMask = 2147483647; 181 | files = ( 182 | ); 183 | runOnlyForDeploymentPostprocessing = 0; 184 | }; 185 | /* End PBXFrameworksBuildPhase section */ 186 | 187 | /* Begin PBXGroup section */ 188 | D964786427A0E43D003A6648 /* Home */ = { 189 | isa = PBXGroup; 190 | children = ( 191 | D964786527A0E455003A6648 /* ClashHomeView.swift */, 192 | D9A3992627CF6BA70047E47D /* ClashConfigView.swift */, 193 | D9A3992827CF6E800047E47D /* VPNStateView.swift */, 194 | D958FB3C27D8AE84009BDFEA /* InstallVPNView.swift */, 195 | D9B4FC9627CF38980018035A /* VPNConnecteDurationView.swift */, 196 | D9B4FC8A27CF01880018035A /* ClashTunnelModeView.swift */, 197 | D9B4FC8C27CF07E60018035A /* ClashTrafficView.swift */, 198 | ); 199 | path = Home; 200 | sourceTree = ""; 201 | }; 202 | D964786727A0E76E003A6648 /* List */ = { 203 | isa = PBXGroup; 204 | children = ( 205 | D964786827A0E793003A6648 /* ClashConfigListView.swift */, 206 | D9A3992E27D094050047E47D /* ClashConfigImportButton.swift */, 207 | D9BBA840279EAE26002420FA /* ClashConfigImportView.swift */, 208 | ); 209 | path = List; 210 | sourceTree = ""; 211 | }; 212 | D9ACEEF22797F45F0004E32D = { 213 | isa = PBXGroup; 214 | children = ( 215 | D913C9A327BF2F6500A790FF /* Config.xcconfig */, 216 | D913C9A727BF2F7900A790FF /* Config-Debug.xcconfig */, 217 | D913C9AB27BF2F8700A790FF /* Config-Release.xcconfig */, 218 | D9ACEEFD2797F45F0004E32D /* Clash */, 219 | D9B4FC7927CE0C240018035A /* CommonKit */, 220 | D9ACEF1D2797FD4B0004E32D /* PacketTunnel */, 221 | D9ACEEFC2797F45F0004E32D /* Products */, 222 | D9ACEF142797FCFE0004E32D /* Frameworks */, 223 | ); 224 | sourceTree = ""; 225 | }; 226 | D9ACEEFC2797F45F0004E32D /* Products */ = { 227 | isa = PBXGroup; 228 | children = ( 229 | D9ACEEFB2797F45F0004E32D /* Clash.app */, 230 | D9ACEF1B2797FD4B0004E32D /* PacketTunnel.appex */, 231 | D9B4FC7827CE0C240018035A /* CommonKit.framework */, 232 | ); 233 | name = Products; 234 | sourceTree = ""; 235 | }; 236 | D9ACEEFD2797F45F0004E32D /* Clash */ = { 237 | isa = PBXGroup; 238 | children = ( 239 | D9BBA6A827980571002420FA /* AppDelegate.swift */, 240 | D9ACEEFE2797F45F0004E32D /* ClashApp.swift */, 241 | D9ACEF002797F45F0004E32D /* ContentView.swift */, 242 | D964787427A266FB003A6648 /* VPNManager.swift */, 243 | D955EE5227A513D6003C072A /* NSManagedObjectContext+File.swift */, 244 | D9B4FC8E27CF0A670018035A /* ClashTrafficFormatter.swift */, 245 | D964786A27A12718003A6648 /* ManagedObjectFetchView.swift */, 246 | D9A3992C27D07E4A0047E47D /* ModalPresentationLink.swift */, 247 | 70A9E33B279ED48E00E6E8AF /* DocumentPickerView.swift */, 248 | D964786427A0E43D003A6648 /* Home */, 249 | D964786727A0E76E003A6648 /* List */, 250 | D9D9ED5127D76311006CDF61 /* Setting */, 251 | D9BBA6AA27980B52002420FA /* Country.mmdb */, 252 | D9ACEF022797F4640004E32D /* Assets.xcassets */, 253 | D9ACEF0C2797F4880004E32D /* Info.plist */, 254 | D9ACEF132797FCEA0004E32D /* Clash.entitlements */, 255 | D9ACEF042797F4640004E32D /* Preview Content */, 256 | ); 257 | path = Clash; 258 | sourceTree = ""; 259 | }; 260 | D9ACEF042797F4640004E32D /* Preview Content */ = { 261 | isa = PBXGroup; 262 | children = ( 263 | D9ACEF052797F4640004E32D /* Preview Assets.xcassets */, 264 | ); 265 | path = "Preview Content"; 266 | sourceTree = ""; 267 | }; 268 | D9ACEF142797FCFE0004E32D /* Frameworks */ = { 269 | isa = PBXGroup; 270 | children = ( 271 | D9ACEF152797FCFE0004E32D /* NetworkExtension.framework */, 272 | ); 273 | name = Frameworks; 274 | sourceTree = ""; 275 | }; 276 | D9ACEF1D2797FD4B0004E32D /* PacketTunnel */ = { 277 | isa = PBXGroup; 278 | children = ( 279 | D9ACEF1E2797FD4B0004E32D /* PacketTunnelProvider.swift */, 280 | D9823B6C27CCD81C0043A9FB /* PacketTunnelProvider+Clash.swift */, 281 | D9ACEF202797FD4B0004E32D /* Info.plist */, 282 | D9ACEF212797FD4B0004E32D /* PacketTunnel.entitlements */, 283 | ); 284 | path = PacketTunnel; 285 | sourceTree = ""; 286 | }; 287 | D9B4FC7927CE0C240018035A /* CommonKit */ = { 288 | isa = PBXGroup; 289 | children = ( 290 | D9B4FC7A27CE0C240018035A /* CommonKit.h */, 291 | D9823B6227CCD06F0043A9FB /* Constant.swift */, 292 | D9823B6627CCD25D0043A9FB /* UserDefaults+AppGroup.swift */, 293 | D9823B6A27CCD7AF0043A9FB /* ClashTunnelMode.swift */, 294 | D9A3992A27D06B430047E47D /* ClashTraffic.swift */, 295 | D9823B6E27CCD9420043A9FB /* ClashCommand.swift */, 296 | D955EE5427A51F57003C072A /* ClashError.swift */, 297 | D9D9ED4F27D72ADD006CDF61 /* ClashLogLevel.swift */, 298 | D9D9ED4A27D6EB4E006CDF61 /* CoreData */, 299 | ); 300 | path = CommonKit; 301 | sourceTree = ""; 302 | }; 303 | D9D9ED4A27D6EB4E006CDF61 /* CoreData */ = { 304 | isa = PBXGroup; 305 | children = ( 306 | D9647861279FE3C6003A6648 /* CoreDataStack.swift */, 307 | D964785E279FE37A003A6648 /* Clash.xcdatamodeld */, 308 | ); 309 | path = CoreData; 310 | sourceTree = ""; 311 | }; 312 | D9D9ED5127D76311006CDF61 /* Setting */ = { 313 | isa = PBXGroup; 314 | children = ( 315 | D9D9ED5227D76327006CDF61 /* SettingView.swift */, 316 | D9D9ED4D27D7152F006CDF61 /* ClashLogView.swift */, 317 | D958FB3E27D8AEBF009BDFEA /* UninstallVPNView.swift */, 318 | ); 319 | path = Setting; 320 | sourceTree = ""; 321 | }; 322 | /* End PBXGroup section */ 323 | 324 | /* Begin PBXHeadersBuildPhase section */ 325 | D9B4FC7327CE0C240018035A /* Headers */ = { 326 | isa = PBXHeadersBuildPhase; 327 | buildActionMask = 2147483647; 328 | files = ( 329 | D9B4FC7B27CE0C240018035A /* CommonKit.h in Headers */, 330 | ); 331 | runOnlyForDeploymentPostprocessing = 0; 332 | }; 333 | /* End PBXHeadersBuildPhase section */ 334 | 335 | /* Begin PBXNativeTarget section */ 336 | D9ACEEFA2797F45F0004E32D /* Clash */ = { 337 | isa = PBXNativeTarget; 338 | buildConfigurationList = D9ACEF092797F4640004E32D /* Build configuration list for PBXNativeTarget "Clash" */; 339 | buildPhases = ( 340 | D9ACEEF72797F45F0004E32D /* Sources */, 341 | D9ACEEF82797F45F0004E32D /* Frameworks */, 342 | D9ACEEF92797F45F0004E32D /* Resources */, 343 | D9ACEF282797FD4B0004E32D /* Embed App Extensions */, 344 | D9ACEF392797FDBB0004E32D /* Embed Frameworks */, 345 | ); 346 | buildRules = ( 347 | ); 348 | dependencies = ( 349 | D9B4FC7D27CE0C240018035A /* PBXTargetDependency */, 350 | D9ACEF232797FD4B0004E32D /* PBXTargetDependency */, 351 | ); 352 | name = Clash; 353 | packageProductDependencies = ( 354 | D9B4FC9227CF28100018035A /* ClashKit */, 355 | ); 356 | productName = Clash; 357 | productReference = D9ACEEFB2797F45F0004E32D /* Clash.app */; 358 | productType = "com.apple.product-type.application"; 359 | }; 360 | D9ACEF1A2797FD4B0004E32D /* PacketTunnel */ = { 361 | isa = PBXNativeTarget; 362 | buildConfigurationList = D9ACEF252797FD4B0004E32D /* Build configuration list for PBXNativeTarget "PacketTunnel" */; 363 | buildPhases = ( 364 | D9ACEF172797FD4B0004E32D /* Sources */, 365 | D9ACEF182797FD4B0004E32D /* Frameworks */, 366 | D9ACEF192797FD4B0004E32D /* Resources */, 367 | ); 368 | buildRules = ( 369 | ); 370 | dependencies = ( 371 | D9B4FC8927CE0D160018035A /* PBXTargetDependency */, 372 | ); 373 | name = PacketTunnel; 374 | productName = PacketTunnel; 375 | productReference = D9ACEF1B2797FD4B0004E32D /* PacketTunnel.appex */; 376 | productType = "com.apple.product-type.app-extension"; 377 | }; 378 | D9B4FC7727CE0C240018035A /* CommonKit */ = { 379 | isa = PBXNativeTarget; 380 | buildConfigurationList = D9B4FC8227CE0C250018035A /* Build configuration list for PBXNativeTarget "CommonKit" */; 381 | buildPhases = ( 382 | D9B4FC7327CE0C240018035A /* Headers */, 383 | D9B4FC7427CE0C240018035A /* Sources */, 384 | D9B4FC7527CE0C240018035A /* Frameworks */, 385 | D9B4FC7627CE0C240018035A /* Resources */, 386 | ); 387 | buildRules = ( 388 | ); 389 | dependencies = ( 390 | ); 391 | name = CommonKit; 392 | productName = CommonKit; 393 | productReference = D9B4FC7827CE0C240018035A /* CommonKit.framework */; 394 | productType = "com.apple.product-type.framework"; 395 | }; 396 | /* End PBXNativeTarget section */ 397 | 398 | /* Begin PBXProject section */ 399 | D9ACEEF32797F45F0004E32D /* Project object */ = { 400 | isa = PBXProject; 401 | attributes = { 402 | BuildIndependentTargetsInParallel = 1; 403 | LastSwiftUpdateCheck = 1310; 404 | LastUpgradeCheck = 1310; 405 | TargetAttributes = { 406 | D9ACEEFA2797F45F0004E32D = { 407 | CreatedOnToolsVersion = 13.1; 408 | }; 409 | D9ACEF1A2797FD4B0004E32D = { 410 | CreatedOnToolsVersion = 13.1; 411 | }; 412 | D9B4FC7727CE0C240018035A = { 413 | CreatedOnToolsVersion = 13.1; 414 | }; 415 | }; 416 | }; 417 | buildConfigurationList = D9ACEEF62797F45F0004E32D /* Build configuration list for PBXProject "Clash" */; 418 | compatibilityVersion = "Xcode 13.0"; 419 | developmentRegion = "zh-Hans"; 420 | hasScannedForEncodings = 0; 421 | knownRegions = ( 422 | "zh-Hans", 423 | ); 424 | mainGroup = D9ACEEF22797F45F0004E32D; 425 | packageReferences = ( 426 | D9B4FC9127CF28100018035A /* XCRemoteSwiftPackageReference "ClashKit" */, 427 | ); 428 | productRefGroup = D9ACEEFC2797F45F0004E32D /* Products */; 429 | projectDirPath = ""; 430 | projectRoot = ""; 431 | targets = ( 432 | D9ACEEFA2797F45F0004E32D /* Clash */, 433 | D9B4FC7727CE0C240018035A /* CommonKit */, 434 | D9ACEF1A2797FD4B0004E32D /* PacketTunnel */, 435 | ); 436 | }; 437 | /* End PBXProject section */ 438 | 439 | /* Begin PBXResourcesBuildPhase section */ 440 | D9ACEEF92797F45F0004E32D /* Resources */ = { 441 | isa = PBXResourcesBuildPhase; 442 | buildActionMask = 2147483647; 443 | files = ( 444 | D913C9A427BF2F6500A790FF /* Config.xcconfig in Resources */, 445 | D9ACEF062797F4640004E32D /* Preview Assets.xcassets in Resources */, 446 | D9ACEF032797F4640004E32D /* Assets.xcassets in Resources */, 447 | D913C9A827BF2F7900A790FF /* Config-Debug.xcconfig in Resources */, 448 | D9BBA6AB27980B52002420FA /* Country.mmdb in Resources */, 449 | ); 450 | runOnlyForDeploymentPostprocessing = 0; 451 | }; 452 | D9ACEF192797FD4B0004E32D /* Resources */ = { 453 | isa = PBXResourcesBuildPhase; 454 | buildActionMask = 2147483647; 455 | files = ( 456 | D913C9AA27BF2F7900A790FF /* Config-Debug.xcconfig in Resources */, 457 | D913C9A627BF2F6500A790FF /* Config.xcconfig in Resources */, 458 | ); 459 | runOnlyForDeploymentPostprocessing = 0; 460 | }; 461 | D9B4FC7627CE0C240018035A /* Resources */ = { 462 | isa = PBXResourcesBuildPhase; 463 | buildActionMask = 2147483647; 464 | files = ( 465 | ); 466 | runOnlyForDeploymentPostprocessing = 0; 467 | }; 468 | /* End PBXResourcesBuildPhase section */ 469 | 470 | /* Begin PBXSourcesBuildPhase section */ 471 | D9ACEEF72797F45F0004E32D /* Sources */ = { 472 | isa = PBXSourcesBuildPhase; 473 | buildActionMask = 2147483647; 474 | files = ( 475 | D955EE5327A513D6003C072A /* NSManagedObjectContext+File.swift in Sources */, 476 | D9D9ED4E27D7152F006CDF61 /* ClashLogView.swift in Sources */, 477 | D9A3992F27D094050047E47D /* ClashConfigImportButton.swift in Sources */, 478 | D9D9ED5327D76328006CDF61 /* SettingView.swift in Sources */, 479 | D9A3992927CF6E800047E47D /* VPNStateView.swift in Sources */, 480 | D9BBA6A927980571002420FA /* AppDelegate.swift in Sources */, 481 | D9ACEF012797F45F0004E32D /* ContentView.swift in Sources */, 482 | D964786B27A12718003A6648 /* ManagedObjectFetchView.swift in Sources */, 483 | D9B4FC9727CF38980018035A /* VPNConnecteDurationView.swift in Sources */, 484 | D958FB3D27D8AE84009BDFEA /* InstallVPNView.swift in Sources */, 485 | D9BBA841279EAE26002420FA /* ClashConfigImportView.swift in Sources */, 486 | 70A9E33C279ED48E00E6E8AF /* DocumentPickerView.swift in Sources */, 487 | D9B4FC8D27CF07E60018035A /* ClashTrafficView.swift in Sources */, 488 | D9A3992727CF6BA70047E47D /* ClashConfigView.swift in Sources */, 489 | D958FB3F27D8AEBF009BDFEA /* UninstallVPNView.swift in Sources */, 490 | D964787527A266FB003A6648 /* VPNManager.swift in Sources */, 491 | D9B4FC8B27CF01880018035A /* ClashTunnelModeView.swift in Sources */, 492 | D964786627A0E455003A6648 /* ClashHomeView.swift in Sources */, 493 | D9A3992D27D07E4A0047E47D /* ModalPresentationLink.swift in Sources */, 494 | D9B4FC8F27CF0A670018035A /* ClashTrafficFormatter.swift in Sources */, 495 | D964786927A0E793003A6648 /* ClashConfigListView.swift in Sources */, 496 | D9ACEEFF2797F45F0004E32D /* ClashApp.swift in Sources */, 497 | ); 498 | runOnlyForDeploymentPostprocessing = 0; 499 | }; 500 | D9ACEF172797FD4B0004E32D /* Sources */ = { 501 | isa = PBXSourcesBuildPhase; 502 | buildActionMask = 2147483647; 503 | files = ( 504 | D9823B6D27CCD81C0043A9FB /* PacketTunnelProvider+Clash.swift in Sources */, 505 | D9ACEF1F2797FD4B0004E32D /* PacketTunnelProvider.swift in Sources */, 506 | ); 507 | runOnlyForDeploymentPostprocessing = 0; 508 | }; 509 | D9B4FC7427CE0C240018035A /* Sources */ = { 510 | isa = PBXSourcesBuildPhase; 511 | buildActionMask = 2147483647; 512 | files = ( 513 | D9D9ED4B27D6EB82006CDF61 /* CoreDataStack.swift in Sources */, 514 | D9B4FC8727CE0C370018035A /* ClashError.swift in Sources */, 515 | D9A3992B27D06B430047E47D /* ClashTraffic.swift in Sources */, 516 | D9B4FC8427CE0C370018035A /* UserDefaults+AppGroup.swift in Sources */, 517 | D9D9ED5027D72ADD006CDF61 /* ClashLogLevel.swift in Sources */, 518 | D9B4FC8327CE0C370018035A /* Constant.swift in Sources */, 519 | D9D9ED4C27D6EB88006CDF61 /* Clash.xcdatamodeld in Sources */, 520 | D9B4FC8527CE0C370018035A /* ClashTunnelMode.swift in Sources */, 521 | D9B4FC8627CE0C370018035A /* ClashCommand.swift in Sources */, 522 | ); 523 | runOnlyForDeploymentPostprocessing = 0; 524 | }; 525 | /* End PBXSourcesBuildPhase section */ 526 | 527 | /* Begin PBXTargetDependency section */ 528 | D9ACEF232797FD4B0004E32D /* PBXTargetDependency */ = { 529 | isa = PBXTargetDependency; 530 | target = D9ACEF1A2797FD4B0004E32D /* PacketTunnel */; 531 | targetProxy = D9ACEF222797FD4B0004E32D /* PBXContainerItemProxy */; 532 | }; 533 | D9B4FC7D27CE0C240018035A /* PBXTargetDependency */ = { 534 | isa = PBXTargetDependency; 535 | target = D9B4FC7727CE0C240018035A /* CommonKit */; 536 | targetProxy = D9B4FC7C27CE0C240018035A /* PBXContainerItemProxy */; 537 | }; 538 | D9B4FC8927CE0D160018035A /* PBXTargetDependency */ = { 539 | isa = PBXTargetDependency; 540 | target = D9B4FC7727CE0C240018035A /* CommonKit */; 541 | targetProxy = D9B4FC8827CE0D160018035A /* PBXContainerItemProxy */; 542 | }; 543 | /* End PBXTargetDependency section */ 544 | 545 | /* Begin XCBuildConfiguration section */ 546 | D9ACEF072797F4640004E32D /* Debug */ = { 547 | isa = XCBuildConfiguration; 548 | baseConfigurationReference = D913C9A727BF2F7900A790FF /* Config-Debug.xcconfig */; 549 | buildSettings = { 550 | ALWAYS_SEARCH_USER_PATHS = NO; 551 | CLANG_ANALYZER_NONNULL = YES; 552 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 553 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 554 | CLANG_CXX_LIBRARY = "libc++"; 555 | CLANG_ENABLE_MODULES = YES; 556 | CLANG_ENABLE_OBJC_ARC = YES; 557 | CLANG_ENABLE_OBJC_WEAK = YES; 558 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 559 | CLANG_WARN_BOOL_CONVERSION = YES; 560 | CLANG_WARN_COMMA = YES; 561 | CLANG_WARN_CONSTANT_CONVERSION = YES; 562 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 563 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 564 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 565 | CLANG_WARN_EMPTY_BODY = YES; 566 | CLANG_WARN_ENUM_CONVERSION = YES; 567 | CLANG_WARN_INFINITE_RECURSION = YES; 568 | CLANG_WARN_INT_CONVERSION = YES; 569 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 570 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 571 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 572 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 573 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 574 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 575 | CLANG_WARN_STRICT_PROTOTYPES = YES; 576 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 577 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 578 | CLANG_WARN_UNREACHABLE_CODE = YES; 579 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 580 | COPY_PHASE_STRIP = NO; 581 | DEBUG_INFORMATION_FORMAT = dwarf; 582 | ENABLE_STRICT_OBJC_MSGSEND = YES; 583 | ENABLE_TESTABILITY = YES; 584 | GCC_C_LANGUAGE_STANDARD = gnu11; 585 | GCC_DYNAMIC_NO_PIC = NO; 586 | GCC_NO_COMMON_BLOCKS = YES; 587 | GCC_OPTIMIZATION_LEVEL = 0; 588 | GCC_PREPROCESSOR_DEFINITIONS = ( 589 | "DEBUG=1", 590 | "$(inherited)", 591 | ); 592 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 593 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 594 | GCC_WARN_UNDECLARED_SELECTOR = YES; 595 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 596 | GCC_WARN_UNUSED_FUNCTION = YES; 597 | GCC_WARN_UNUSED_VARIABLE = YES; 598 | IPHONEOS_DEPLOYMENT_TARGET = 15.0; 599 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 600 | MTL_FAST_MATH = YES; 601 | ONLY_ACTIVE_ARCH = YES; 602 | SDKROOT = iphoneos; 603 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 604 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 605 | }; 606 | name = Debug; 607 | }; 608 | D9ACEF082797F4640004E32D /* Release */ = { 609 | isa = XCBuildConfiguration; 610 | baseConfigurationReference = D913C9AB27BF2F8700A790FF /* Config-Release.xcconfig */; 611 | buildSettings = { 612 | ALWAYS_SEARCH_USER_PATHS = NO; 613 | CLANG_ANALYZER_NONNULL = YES; 614 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 615 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 616 | CLANG_CXX_LIBRARY = "libc++"; 617 | CLANG_ENABLE_MODULES = YES; 618 | CLANG_ENABLE_OBJC_ARC = YES; 619 | CLANG_ENABLE_OBJC_WEAK = YES; 620 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 621 | CLANG_WARN_BOOL_CONVERSION = YES; 622 | CLANG_WARN_COMMA = YES; 623 | CLANG_WARN_CONSTANT_CONVERSION = YES; 624 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 625 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 626 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 627 | CLANG_WARN_EMPTY_BODY = YES; 628 | CLANG_WARN_ENUM_CONVERSION = YES; 629 | CLANG_WARN_INFINITE_RECURSION = YES; 630 | CLANG_WARN_INT_CONVERSION = YES; 631 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 632 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 633 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 634 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 635 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 636 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 637 | CLANG_WARN_STRICT_PROTOTYPES = YES; 638 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 639 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 640 | CLANG_WARN_UNREACHABLE_CODE = YES; 641 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 642 | COPY_PHASE_STRIP = NO; 643 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 644 | ENABLE_NS_ASSERTIONS = NO; 645 | ENABLE_STRICT_OBJC_MSGSEND = YES; 646 | GCC_C_LANGUAGE_STANDARD = gnu11; 647 | GCC_NO_COMMON_BLOCKS = YES; 648 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 649 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 650 | GCC_WARN_UNDECLARED_SELECTOR = YES; 651 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 652 | GCC_WARN_UNUSED_FUNCTION = YES; 653 | GCC_WARN_UNUSED_VARIABLE = YES; 654 | IPHONEOS_DEPLOYMENT_TARGET = 15.0; 655 | MTL_ENABLE_DEBUG_INFO = NO; 656 | MTL_FAST_MATH = YES; 657 | SDKROOT = iphoneos; 658 | SWIFT_COMPILATION_MODE = wholemodule; 659 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 660 | VALIDATE_PRODUCT = YES; 661 | }; 662 | name = Release; 663 | }; 664 | D9ACEF0A2797F4640004E32D /* Debug */ = { 665 | isa = XCBuildConfiguration; 666 | baseConfigurationReference = D913C9A727BF2F7900A790FF /* Config-Debug.xcconfig */; 667 | buildSettings = { 668 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 669 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 670 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 671 | CODE_SIGN_ENTITLEMENTS = Clash/Clash.entitlements; 672 | CODE_SIGN_STYLE = Automatic; 673 | CURRENT_PROJECT_VERSION = "$(CLASH_CURRENT_PROJECT_VERSION)"; 674 | DEVELOPMENT_ASSET_PATHS = "\"Clash/Preview Content\""; 675 | DEVELOPMENT_TEAM = A8XWAF2UFT; 676 | ENABLE_PREVIEWS = YES; 677 | GENERATE_INFOPLIST_FILE = YES; 678 | INFOPLIST_FILE = Clash/Info.plist; 679 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 680 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 681 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 682 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 683 | LD_RUNPATH_SEARCH_PATHS = ( 684 | "$(inherited)", 685 | "@executable_path/Frameworks", 686 | ); 687 | MARKETING_VERSION = "$(CLASH_MARKETING_VERSION)"; 688 | PRODUCT_BUNDLE_IDENTIFIER = "$(CLASH_PRODUCT_BUNDLE_IDENTIFIER)"; 689 | PRODUCT_NAME = "$(TARGET_NAME)"; 690 | SWIFT_EMIT_LOC_STRINGS = YES; 691 | SWIFT_VERSION = 5.0; 692 | TARGETED_DEVICE_FAMILY = "1,2"; 693 | }; 694 | name = Debug; 695 | }; 696 | D9ACEF0B2797F4640004E32D /* Release */ = { 697 | isa = XCBuildConfiguration; 698 | baseConfigurationReference = D913C9AB27BF2F8700A790FF /* Config-Release.xcconfig */; 699 | buildSettings = { 700 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 701 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 702 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 703 | CODE_SIGN_ENTITLEMENTS = Clash/Clash.entitlements; 704 | CODE_SIGN_STYLE = Automatic; 705 | CURRENT_PROJECT_VERSION = "$(CLASH_CURRENT_PROJECT_VERSION)"; 706 | DEVELOPMENT_ASSET_PATHS = "\"Clash/Preview Content\""; 707 | DEVELOPMENT_TEAM = A8XWAF2UFT; 708 | ENABLE_PREVIEWS = YES; 709 | GENERATE_INFOPLIST_FILE = YES; 710 | INFOPLIST_FILE = Clash/Info.plist; 711 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 712 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 713 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 714 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 715 | LD_RUNPATH_SEARCH_PATHS = ( 716 | "$(inherited)", 717 | "@executable_path/Frameworks", 718 | ); 719 | MARKETING_VERSION = "$(CLASH_MARKETING_VERSION)"; 720 | PRODUCT_BUNDLE_IDENTIFIER = "$(CLASH_PRODUCT_BUNDLE_IDENTIFIER)"; 721 | PRODUCT_NAME = "$(TARGET_NAME)"; 722 | SWIFT_EMIT_LOC_STRINGS = YES; 723 | SWIFT_VERSION = 5.0; 724 | TARGETED_DEVICE_FAMILY = "1,2"; 725 | }; 726 | name = Release; 727 | }; 728 | D9ACEF262797FD4B0004E32D /* Debug */ = { 729 | isa = XCBuildConfiguration; 730 | baseConfigurationReference = D913C9A727BF2F7900A790FF /* Config-Debug.xcconfig */; 731 | buildSettings = { 732 | CODE_SIGN_ENTITLEMENTS = PacketTunnel/PacketTunnel.entitlements; 733 | CODE_SIGN_STYLE = Automatic; 734 | CURRENT_PROJECT_VERSION = "$(CLASH_CURRENT_PROJECT_VERSION)"; 735 | DEVELOPMENT_TEAM = A8XWAF2UFT; 736 | GENERATE_INFOPLIST_FILE = YES; 737 | INFOPLIST_FILE = PacketTunnel/Info.plist; 738 | INFOPLIST_KEY_CFBundleDisplayName = PacketTunnel; 739 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 740 | LD_RUNPATH_SEARCH_PATHS = ( 741 | "$(inherited)", 742 | "@executable_path/Frameworks", 743 | "@executable_path/../../Frameworks", 744 | ); 745 | MARKETING_VERSION = "$(CLASH_MARKETING_VERSION)"; 746 | PRODUCT_BUNDLE_IDENTIFIER = "$(CLASH_PRODUCT_BUNDLE_IDENTIFIER).PacketTunnel"; 747 | PRODUCT_NAME = "$(TARGET_NAME)"; 748 | SKIP_INSTALL = YES; 749 | SWIFT_EMIT_LOC_STRINGS = YES; 750 | SWIFT_VERSION = 5.0; 751 | TARGETED_DEVICE_FAMILY = "1,2"; 752 | }; 753 | name = Debug; 754 | }; 755 | D9ACEF272797FD4B0004E32D /* Release */ = { 756 | isa = XCBuildConfiguration; 757 | baseConfigurationReference = D913C9AB27BF2F8700A790FF /* Config-Release.xcconfig */; 758 | buildSettings = { 759 | CODE_SIGN_ENTITLEMENTS = PacketTunnel/PacketTunnel.entitlements; 760 | CODE_SIGN_STYLE = Automatic; 761 | CURRENT_PROJECT_VERSION = "$(CLASH_CURRENT_PROJECT_VERSION)"; 762 | DEVELOPMENT_TEAM = A8XWAF2UFT; 763 | GENERATE_INFOPLIST_FILE = YES; 764 | INFOPLIST_FILE = PacketTunnel/Info.plist; 765 | INFOPLIST_KEY_CFBundleDisplayName = PacketTunnel; 766 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 767 | LD_RUNPATH_SEARCH_PATHS = ( 768 | "$(inherited)", 769 | "@executable_path/Frameworks", 770 | "@executable_path/../../Frameworks", 771 | ); 772 | MARKETING_VERSION = "$(CLASH_MARKETING_VERSION)"; 773 | PRODUCT_BUNDLE_IDENTIFIER = "$(CLASH_PRODUCT_BUNDLE_IDENTIFIER).PacketTunnel"; 774 | PRODUCT_NAME = "$(TARGET_NAME)"; 775 | SKIP_INSTALL = YES; 776 | SWIFT_EMIT_LOC_STRINGS = YES; 777 | SWIFT_VERSION = 5.0; 778 | TARGETED_DEVICE_FAMILY = "1,2"; 779 | }; 780 | name = Release; 781 | }; 782 | D9B4FC8027CE0C250018035A /* Debug */ = { 783 | isa = XCBuildConfiguration; 784 | buildSettings = { 785 | APPLICATION_EXTENSION_API_ONLY = YES; 786 | CODE_SIGN_STYLE = Automatic; 787 | CURRENT_PROJECT_VERSION = 1; 788 | DEFINES_MODULE = YES; 789 | DEVELOPMENT_TEAM = A8XWAF2UFT; 790 | DYLIB_COMPATIBILITY_VERSION = 1; 791 | DYLIB_CURRENT_VERSION = 1; 792 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 793 | GENERATE_INFOPLIST_FILE = YES; 794 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 795 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 796 | LD_RUNPATH_SEARCH_PATHS = ( 797 | "$(inherited)", 798 | "@executable_path/Frameworks", 799 | "@loader_path/Frameworks", 800 | ); 801 | MARKETING_VERSION = 1.0; 802 | PRODUCT_BUNDLE_IDENTIFIER = com.Arror.CommonKit; 803 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 804 | SKIP_INSTALL = YES; 805 | SWIFT_EMIT_LOC_STRINGS = YES; 806 | SWIFT_VERSION = 5.0; 807 | TARGETED_DEVICE_FAMILY = "1,2"; 808 | VERSIONING_SYSTEM = "apple-generic"; 809 | VERSION_INFO_PREFIX = ""; 810 | }; 811 | name = Debug; 812 | }; 813 | D9B4FC8127CE0C250018035A /* Release */ = { 814 | isa = XCBuildConfiguration; 815 | buildSettings = { 816 | APPLICATION_EXTENSION_API_ONLY = YES; 817 | CODE_SIGN_STYLE = Automatic; 818 | CURRENT_PROJECT_VERSION = 1; 819 | DEFINES_MODULE = YES; 820 | DEVELOPMENT_TEAM = A8XWAF2UFT; 821 | DYLIB_COMPATIBILITY_VERSION = 1; 822 | DYLIB_CURRENT_VERSION = 1; 823 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 824 | GENERATE_INFOPLIST_FILE = YES; 825 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 826 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 827 | LD_RUNPATH_SEARCH_PATHS = ( 828 | "$(inherited)", 829 | "@executable_path/Frameworks", 830 | "@loader_path/Frameworks", 831 | ); 832 | MARKETING_VERSION = 1.0; 833 | PRODUCT_BUNDLE_IDENTIFIER = com.Arror.CommonKit; 834 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 835 | SKIP_INSTALL = YES; 836 | SWIFT_EMIT_LOC_STRINGS = YES; 837 | SWIFT_VERSION = 5.0; 838 | TARGETED_DEVICE_FAMILY = "1,2"; 839 | VERSIONING_SYSTEM = "apple-generic"; 840 | VERSION_INFO_PREFIX = ""; 841 | }; 842 | name = Release; 843 | }; 844 | /* End XCBuildConfiguration section */ 845 | 846 | /* Begin XCConfigurationList section */ 847 | D9ACEEF62797F45F0004E32D /* Build configuration list for PBXProject "Clash" */ = { 848 | isa = XCConfigurationList; 849 | buildConfigurations = ( 850 | D9ACEF072797F4640004E32D /* Debug */, 851 | D9ACEF082797F4640004E32D /* Release */, 852 | ); 853 | defaultConfigurationIsVisible = 0; 854 | defaultConfigurationName = Release; 855 | }; 856 | D9ACEF092797F4640004E32D /* Build configuration list for PBXNativeTarget "Clash" */ = { 857 | isa = XCConfigurationList; 858 | buildConfigurations = ( 859 | D9ACEF0A2797F4640004E32D /* Debug */, 860 | D9ACEF0B2797F4640004E32D /* Release */, 861 | ); 862 | defaultConfigurationIsVisible = 0; 863 | defaultConfigurationName = Release; 864 | }; 865 | D9ACEF252797FD4B0004E32D /* Build configuration list for PBXNativeTarget "PacketTunnel" */ = { 866 | isa = XCConfigurationList; 867 | buildConfigurations = ( 868 | D9ACEF262797FD4B0004E32D /* Debug */, 869 | D9ACEF272797FD4B0004E32D /* Release */, 870 | ); 871 | defaultConfigurationIsVisible = 0; 872 | defaultConfigurationName = Release; 873 | }; 874 | D9B4FC8227CE0C250018035A /* Build configuration list for PBXNativeTarget "CommonKit" */ = { 875 | isa = XCConfigurationList; 876 | buildConfigurations = ( 877 | D9B4FC8027CE0C250018035A /* Debug */, 878 | D9B4FC8127CE0C250018035A /* Release */, 879 | ); 880 | defaultConfigurationIsVisible = 0; 881 | defaultConfigurationName = Release; 882 | }; 883 | /* End XCConfigurationList section */ 884 | 885 | /* Begin XCRemoteSwiftPackageReference section */ 886 | D9B4FC9127CF28100018035A /* XCRemoteSwiftPackageReference "ClashKit" */ = { 887 | isa = XCRemoteSwiftPackageReference; 888 | repositoryURL = "https://github.com/Clash-for-Apple/ClashKit.git"; 889 | requirement = { 890 | kind = exactVersion; 891 | version = 1.0.8; 892 | }; 893 | }; 894 | /* End XCRemoteSwiftPackageReference section */ 895 | 896 | /* Begin XCSwiftPackageProductDependency section */ 897 | D9B4FC9227CF28100018035A /* ClashKit */ = { 898 | isa = XCSwiftPackageProductDependency; 899 | package = D9B4FC9127CF28100018035A /* XCRemoteSwiftPackageReference "ClashKit" */; 900 | productName = ClashKit; 901 | }; 902 | /* End XCSwiftPackageProductDependency section */ 903 | 904 | /* Begin XCVersionGroup section */ 905 | D964785E279FE37A003A6648 /* Clash.xcdatamodeld */ = { 906 | isa = XCVersionGroup; 907 | children = ( 908 | D964785F279FE37A003A6648 /* Clash.xcdatamodel */, 909 | ); 910 | currentVersion = D964785F279FE37A003A6648 /* Clash.xcdatamodel */; 911 | path = Clash.xcdatamodeld; 912 | sourceTree = ""; 913 | versionGroupType = wrapper.xcdatamodel; 914 | }; 915 | /* End XCVersionGroup section */ 916 | }; 917 | rootObject = D9ACEEF32797F45F0004E32D /* Project object */; 918 | } 919 | -------------------------------------------------------------------------------- /Clash.xcodeproj/xcshareddata/xcschemes/Clash.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 60 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Clash.xcodeproj/xcshareddata/xcschemes/PacketTunnel.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 6 | 9 | 10 | 16 | 22 | 23 | 24 | 30 | 36 | 37 | 38 | 39 | 40 | 45 | 46 | 47 | 48 | 60 | 62 | 68 | 69 | 70 | 71 | 79 | 81 | 87 | 88 | 89 | 90 | 92 | 93 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /Clash.xcodeproj/xcshareddata/xcschemes/ShareLib.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 57 | 58 | 59 | 60 | 62 | 63 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /Clash/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import CommonKit 3 | 4 | public final class AppDelegate: NSObject, UIApplicationDelegate { 5 | 6 | public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { 7 | 8 | self.copyCountryDB() 9 | 10 | return true 11 | } 12 | 13 | private func copyCountryDB() { 14 | let dbFileName = "Country" 15 | let dbFileExtension = "mmdb" 16 | let dbURL = Constant.homeDirectoryURL.appendingPathComponent("\(dbFileName).\(dbFileExtension)") 17 | guard !FileManager.default.fileExists(atPath: dbURL.path) else { 18 | return 19 | } 20 | guard let local = Bundle.main.url(forResource: dbFileName, withExtension: dbFileExtension) else { 21 | return 22 | } 23 | do { 24 | try FileManager.default.copyItem(at: local, to: dbURL) 25 | } catch { 26 | debugPrint(error.localizedDescription) 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | }, 6 | { 7 | "appearances" : [ 8 | { 9 | "appearance" : "luminosity", 10 | "value" : "dark" 11 | } 12 | ], 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "icon_40.png", 5 | "idiom" : "iphone", 6 | "scale" : "2x", 7 | "size" : "20x20" 8 | }, 9 | { 10 | "filename" : "icon_60.png", 11 | "idiom" : "iphone", 12 | "scale" : "3x", 13 | "size" : "20x20" 14 | }, 15 | { 16 | "filename" : "icon_58.png", 17 | "idiom" : "iphone", 18 | "scale" : "2x", 19 | "size" : "29x29" 20 | }, 21 | { 22 | "filename" : "icon_87.png", 23 | "idiom" : "iphone", 24 | "scale" : "3x", 25 | "size" : "29x29" 26 | }, 27 | { 28 | "filename" : "icon_80.png", 29 | "idiom" : "iphone", 30 | "scale" : "2x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "filename" : "icon_120.png", 35 | "idiom" : "iphone", 36 | "scale" : "3x", 37 | "size" : "40x40" 38 | }, 39 | { 40 | "filename" : "icon_120.png", 41 | "idiom" : "iphone", 42 | "scale" : "2x", 43 | "size" : "60x60" 44 | }, 45 | { 46 | "filename" : "icon_180.png", 47 | "idiom" : "iphone", 48 | "scale" : "3x", 49 | "size" : "60x60" 50 | }, 51 | { 52 | "filename" : "icon_20.png", 53 | "idiom" : "ipad", 54 | "scale" : "1x", 55 | "size" : "20x20" 56 | }, 57 | { 58 | "filename" : "icon_40.png", 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "20x20" 62 | }, 63 | { 64 | "filename" : "icon_29.png", 65 | "idiom" : "ipad", 66 | "scale" : "1x", 67 | "size" : "29x29" 68 | }, 69 | { 70 | "filename" : "icon_58.png", 71 | "idiom" : "ipad", 72 | "scale" : "2x", 73 | "size" : "29x29" 74 | }, 75 | { 76 | "filename" : "icon_40.png", 77 | "idiom" : "ipad", 78 | "scale" : "1x", 79 | "size" : "40x40" 80 | }, 81 | { 82 | "filename" : "icon_80.png", 83 | "idiom" : "ipad", 84 | "scale" : "2x", 85 | "size" : "40x40" 86 | }, 87 | { 88 | "filename" : "icon_76.png", 89 | "idiom" : "ipad", 90 | "scale" : "1x", 91 | "size" : "76x76" 92 | }, 93 | { 94 | "filename" : "icon_152.png", 95 | "idiom" : "ipad", 96 | "scale" : "2x", 97 | "size" : "76x76" 98 | }, 99 | { 100 | "filename" : "icon_167.png", 101 | "idiom" : "ipad", 102 | "scale" : "2x", 103 | "size" : "83.5x83.5" 104 | }, 105 | { 106 | "filename" : "icon_1024.png", 107 | "idiom" : "ios-marketing", 108 | "scale" : "1x", 109 | "size" : "1024x1024" 110 | } 111 | ], 112 | "info" : { 113 | "author" : "xcode", 114 | "version" : 1 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Assets.xcassets/AppIcon.appiconset/icon_1024.png -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/icon_120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Assets.xcassets/AppIcon.appiconset/icon_120.png -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/icon_152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Assets.xcassets/AppIcon.appiconset/icon_152.png -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/icon_167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Assets.xcassets/AppIcon.appiconset/icon_167.png -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/icon_180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Assets.xcassets/AppIcon.appiconset/icon_180.png -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/icon_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Assets.xcassets/AppIcon.appiconset/icon_20.png -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/icon_29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Assets.xcassets/AppIcon.appiconset/icon_29.png -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/icon_40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Assets.xcassets/AppIcon.appiconset/icon_40.png -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/icon_58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Assets.xcassets/AppIcon.appiconset/icon_58.png -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/icon_60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Assets.xcassets/AppIcon.appiconset/icon_60.png -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/icon_76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Assets.xcassets/AppIcon.appiconset/icon_76.png -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/icon_80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Assets.xcassets/AppIcon.appiconset/icon_80.png -------------------------------------------------------------------------------- /Clash/Assets.xcassets/AppIcon.appiconset/icon_87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Assets.xcassets/AppIcon.appiconset/icon_87.png -------------------------------------------------------------------------------- /Clash/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Clash/Clash.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.developer.networking.networkextension 6 | 7 | packet-tunnel-provider 8 | 9 | com.apple.security.application-groups 10 | 11 | ${CLASH_APP_GROUP} 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Clash/ClashApp.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import CommonKit 3 | 4 | @main 5 | struct ClashApp: App { 6 | 7 | @UIApplicationDelegateAdaptor private var delegate: AppDelegate 8 | 9 | @StateObject var manager = VPNManager() 10 | 11 | var body: some Scene { 12 | WindowGroup { 13 | ContentView() 14 | .environmentObject(manager) 15 | .environment(\.trafficFormatter, ClashTrafficFormatterKey.defaultValue) 16 | .environment(\.managedObjectContext, CoreDataStack.shared.container.viewContext) 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Clash/ClashTrafficFormatter.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import SwiftUI 3 | 4 | private class ClashTrafficFormatter: NumberFormatter { 5 | 6 | static let `default` = ClashTrafficFormatter() 7 | 8 | override init() { 9 | super.init() 10 | } 11 | 12 | @available(*, unavailable) 13 | required init?(coder: NSCoder) { 14 | fatalError("init(coder:) has not been implemented") 15 | } 16 | 17 | @available(*, unavailable) 18 | public override func number(from string: String) -> NSNumber? { 19 | fatalError("number(from:) has not been implemented") 20 | } 21 | 22 | override func string(from number: NSNumber) -> String? { 23 | let kb = number.int64Value / 1024 24 | guard kb >= 1024 else { 25 | return "\(kb)KB/s" 26 | } 27 | let mb = number.doubleValue / 1024.0 / 1024.0 28 | if mb >= 1000 { 29 | return String(format: "%.1fGB/s", mb / 1024.0) 30 | } else if mb >= 100 { 31 | return String(format: "%.1fMB/s", mb) 32 | } else { 33 | return String(format: "%.2fMB/s", mb) 34 | } 35 | } 36 | } 37 | 38 | enum ClashTrafficFormatterKey: EnvironmentKey { 39 | static let defaultValue: NumberFormatter = ClashTrafficFormatter.default 40 | } 41 | 42 | extension EnvironmentValues { 43 | 44 | public var trafficFormatter: NumberFormatter { 45 | get { self[ClashTrafficFormatterKey.self] } 46 | set { self[ClashTrafficFormatterKey.self] = newValue } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Clash/ContentView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | struct ContentView: View { 4 | var body: some View { 5 | TabView { 6 | ClashHomeView() 7 | .tabItem { 8 | Image(systemName: "house") 9 | Text("主页") 10 | } 11 | SettingView() 12 | .tabItem { 13 | Image(systemName: "gearshape.fill") 14 | Text("设置") 15 | } 16 | } 17 | 18 | } 19 | } 20 | 21 | struct ContentView_Previews: PreviewProvider { 22 | static var previews: some View { 23 | ContentView() 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Clash/Country.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParseDark/iOS/edb790cf3da79c80cc4d495ec5b937eb795178f9/Clash/Country.mmdb -------------------------------------------------------------------------------- /Clash/DocumentPickerView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import UniformTypeIdentifiers 3 | 4 | struct DocumentPickerView: UIViewControllerRepresentable { 5 | 6 | let filenameExtension: String 7 | let binding: Binding 8 | 9 | init(filenameExtension: String, binding: Binding) { 10 | self.filenameExtension = filenameExtension 11 | self.binding = binding 12 | } 13 | 14 | func makeCoordinator() -> Coordinator { 15 | Coordinator(parent: self) 16 | } 17 | 18 | func makeUIViewController(context: Context) -> UIDocumentPickerViewController { 19 | let types = [UTType(filenameExtension: filenameExtension)].compactMap { $0 } 20 | let picker = UIDocumentPickerViewController(forOpeningContentTypes: types, asCopy: true) 21 | picker.allowsMultipleSelection = false 22 | picker.delegate = context.coordinator 23 | return picker 24 | } 25 | 26 | func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: Context) {} 27 | 28 | class Coordinator: NSObject, UIDocumentPickerDelegate { 29 | 30 | let parent: DocumentPickerView 31 | 32 | init(parent: DocumentPickerView) { 33 | self.parent = parent 34 | } 35 | 36 | func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { 37 | parent.binding.wrappedValue = urls.first 38 | } 39 | 40 | func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) { 41 | parent.binding.wrappedValue = nil 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Clash/Home/ClashConfigView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import CommonKit 3 | 4 | struct ClashConfigView: View { 5 | 6 | @AppStorage(Constant.currentConfigUUID, store: .shared) private var uuidString: String = "" 7 | 8 | private var predicate: NSPredicate { 9 | NSPredicate(format: "%K == %@", "uuid", (UUID(uuidString: self.uuidString) ?? UUID()).uuidString) 10 | } 11 | 12 | var body: some View { 13 | ManagedObjectFetchView(predicate: predicate) { (result: FetchedResults) in 14 | ModalPresentationLink { 15 | ClashConfigListView() 16 | } label: { 17 | HStack { 18 | Image(systemName: "square.text.square") 19 | .font(.title2) 20 | .foregroundColor(Color.accentColor) 21 | Text("配置") 22 | Spacer() 23 | Text(result.first.flatMap({ $0.name ?? "-" }) ?? "未选择") 24 | .fontWeight(.bold) 25 | .foregroundColor(Color.accentColor) 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Clash/Home/ClashHomeView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import CommonKit 3 | 4 | struct ClashHomeView: View { 5 | 6 | @EnvironmentObject private var manager: VPNManager 7 | 8 | var body: some View { 9 | NavigationView { 10 | Form { 11 | Section { 12 | ClashConfigView() 13 | if let controller = self.manager.controller { 14 | VPNStateView() 15 | .environmentObject(controller) 16 | VPNConnecteDurationView() 17 | .environmentObject(controller) 18 | } else { 19 | InstallVPNView() 20 | } 21 | } 22 | Section { 23 | ClashTunnelModeView() 24 | } 25 | Section { 26 | ClashTrafficUpView() 27 | ClashTrafficDownView() 28 | } 29 | } 30 | .navigationBarTitle("主页") 31 | .navigationBarTitleDisplayMode(.inline) 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Clash/Home/ClashTrafficView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import CommonKit 3 | 4 | private extension ClashTraffic { 5 | 6 | var title: String { 7 | switch self { 8 | case .up: 9 | return "上行速率" 10 | case .down: 11 | return "下行速率" 12 | } 13 | } 14 | 15 | var imageName: String { 16 | switch self { 17 | case .up: 18 | return "arrow.up" 19 | case .down: 20 | return "arrow.down" 21 | } 22 | } 23 | } 24 | 25 | struct ClashTrafficUpView: View { 26 | 27 | @AppStorage(ClashTraffic.up.rawValue, store: .shared) private var up: Double = 0 28 | 29 | var body: some View { 30 | ClashTrafficView(traffic: .up, binding: $up) 31 | } 32 | } 33 | 34 | struct ClashTrafficDownView: View { 35 | 36 | @AppStorage(ClashTraffic.down.rawValue, store: .shared) private var down: Double = 0 37 | 38 | var body: some View { 39 | ClashTrafficView(traffic: .down, binding: $down) 40 | } 41 | } 42 | 43 | private struct ClashTrafficView: View { 44 | 45 | @Environment(\.trafficFormatter) private var formatter: NumberFormatter 46 | 47 | let traffic: ClashTraffic 48 | let binding: Binding 49 | 50 | init(traffic: ClashTraffic, binding: Binding) { 51 | self.traffic = traffic 52 | self.binding = binding 53 | } 54 | 55 | var body: some View { 56 | HStack { 57 | Image(systemName: self.traffic.imageName) 58 | .font(.title2) 59 | .foregroundColor(Color.accentColor) 60 | Text(self.traffic.title) 61 | Spacer() 62 | Text(formatter.string(from: NSNumber(value: self.binding.wrappedValue)) ?? "-") 63 | .fontWeight(.bold) 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Clash/Home/ClashTunnelModeView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import CommonKit 3 | 4 | struct ClashTunnelModeView: View { 5 | 6 | @EnvironmentObject private var manager: VPNManager 7 | 8 | @AppStorage(Constant.tunnelMode, store: .shared) private var tunnelMode: ClashTunnelMode = .rule 9 | 10 | var body: some View { 11 | Picker(selection: $tunnelMode) { 12 | ForEach(ClashTunnelMode.allCases) { mode in 13 | HStack { 14 | Image(systemName: mode.imageName) 15 | .font(.title2) 16 | .foregroundColor(Color.accentColor) 17 | VStack(alignment: .leading, spacing: 4) { 18 | Text(mode.title) 19 | Text(mode.detail) 20 | .font(Font.body) 21 | .foregroundColor(Color.secondary) 22 | } 23 | } 24 | .padding(.vertical, 6) 25 | } 26 | } label: { 27 | 28 | } 29 | .pickerStyle(InlinePickerStyle()) 30 | .task(id: tunnelMode) { 31 | guard let controller = self.manager.controller else { 32 | return 33 | } 34 | do { 35 | try await controller.execute(command: .setTunnelMode) 36 | } catch { 37 | debugPrint(error) 38 | } 39 | } 40 | } 41 | } 42 | 43 | fileprivate extension ClashTunnelMode { 44 | 45 | var imageName: String { 46 | switch self { 47 | case .global: 48 | return "globe" 49 | case .rule: 50 | return "arrow.triangle.branch" 51 | case .direct: 52 | return "arrow.forward" 53 | } 54 | } 55 | 56 | var title: String { 57 | switch self { 58 | case .global: 59 | return "全局" 60 | case .rule: 61 | return "规则" 62 | case .direct: 63 | return "直连" 64 | } 65 | } 66 | 67 | var detail: String { 68 | switch self { 69 | case .global: 70 | return "流量全部经过指定的全局代理" 71 | case .rule: 72 | return "流量会按规则分流" 73 | case .direct: 74 | return "流量不会经过任何代理" 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Clash/Home/InstallVPNView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | struct InstallVPNView: View { 4 | 5 | @EnvironmentObject private var manager: VPNManager 6 | 7 | var body: some View { 8 | HStack { 9 | Image(systemName: "link") 10 | .font(.title2) 11 | .foregroundColor(Color.accentColor) 12 | Text("状态") 13 | Spacer() 14 | Toggle("状态", isOn: .constant(false)) 15 | .labelsHidden() 16 | .allowsHitTesting(false) 17 | .overlay { 18 | Text("VPN") 19 | .foregroundColor(.clear) 20 | .onTapGesture { 21 | Task(priority: .high) { 22 | do { 23 | try await self.manager.installVPNConfiguration() 24 | } catch { 25 | debugPrint(error.localizedDescription) 26 | } 27 | } 28 | } 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Clash/Home/VPNConnecteDurationView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | struct VPNConnecteDurationView: View { 4 | 5 | @EnvironmentObject private var controller: VPNController 6 | 7 | @State private var connectedDuration: String = "" 8 | 9 | var body: some View { 10 | HStack { 11 | Image(systemName: "clock") 12 | .font(.title2) 13 | .foregroundColor(Color.accentColor) 14 | Text("连接时间") 15 | Spacer() 16 | Text(connectedDuration) 17 | .foregroundColor(.secondary) 18 | } 19 | .onReceive(Timer.publish(every: 0.5, on: .current, in: .common).autoconnect()) { _ in 20 | guard let date = controller.connectedDate else { 21 | return connectedDuration = "" 22 | } 23 | let duration = Int64(abs(date.timeIntervalSinceNow)) 24 | let hs = duration / 3600 25 | let ms = duration % 3600 / 60 26 | let ss = duration % 60 27 | connectedDuration = String(format: "%02d:%02d:%02d", hs, ms, ss) 28 | } 29 | .onChange(of: controller.connectionStatus) { status in 30 | switch status { 31 | case .invalid, .connecting, .disconnected: 32 | connectedDuration = "" 33 | case .connected, .disconnecting, .reasserting: 34 | break 35 | @unknown default: 36 | connectedDuration = "" 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Clash/Home/VPNStateView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import NetworkExtension 3 | 4 | struct VPNStateView: View { 5 | 6 | @EnvironmentObject private var controller: VPNController 7 | 8 | @State private var isVPNOn = false 9 | 10 | var body: some View { 11 | HStack { 12 | Image(systemName: "link") 13 | .font(.title2) 14 | .foregroundColor(Color.accentColor) 15 | Text("状态") 16 | Spacer() 17 | Text(self.controller.connectionStatus.displayString) 18 | .foregroundColor(.secondary) 19 | Toggle("状态", isOn: .constant(isVPNOn)) 20 | .labelsHidden() 21 | .allowsHitTesting(false) 22 | .overlay { 23 | Text("VPN") 24 | .foregroundColor(.clear) 25 | .onTapGesture(perform: toggleVPN) 26 | } 27 | } 28 | .onChange(of: controller.connectionStatus, perform: updateToggle(_:)) 29 | .onAppear { self.updateToggle(controller.connectionStatus) } 30 | } 31 | 32 | private func updateToggle(_ status: NEVPNStatus) { 33 | withAnimation(.default) { 34 | switch status { 35 | case .invalid, .disconnecting, .disconnected: 36 | isVPNOn = false 37 | case .connecting, .connected, .reasserting: 38 | isVPNOn = true 39 | @unknown default: 40 | isVPNOn = false 41 | } 42 | } 43 | } 44 | 45 | private func toggleVPN() { 46 | switch self.controller.connectionStatus { 47 | case .invalid, .connected, .disconnected: 48 | break 49 | case .connecting, .disconnecting, .reasserting: 50 | return 51 | @unknown default: 52 | break 53 | } 54 | withAnimation(.default) { 55 | isVPNOn.toggle() 56 | } 57 | let isOn = isVPNOn 58 | Task(priority: .high) { 59 | do { 60 | isOn ? try await self.controller.startVPN() : self.controller.stopVPN() 61 | } catch { 62 | debugPrint(error) 63 | } 64 | } 65 | } 66 | } 67 | 68 | fileprivate extension NEVPNStatus { 69 | 70 | var displayString: String { 71 | switch self { 72 | case .invalid: 73 | return "不可用" 74 | case .connecting: 75 | return "正在连接..." 76 | case .connected: 77 | return "已连接" 78 | case .reasserting: 79 | return "正在重新连接..." 80 | case .disconnecting: 81 | return "正在断开连接..." 82 | case .disconnected: 83 | return "未连接" 84 | @unknown default: 85 | return "未知" 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Clash/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CLASH_APP_GROUP 6 | ${CLASH_APP_GROUP} 7 | UIApplicationSceneManifest 8 | 9 | UIApplicationSupportsMultipleScenes 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Clash/List/ClashConfigImportButton.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | struct ClashConfigImportItem: Identifiable { 4 | 5 | let id: UUID 6 | let fileURL: URL? 7 | 8 | init(fileURL: URL?) { 9 | self.id = UUID() 10 | self.fileURL = fileURL 11 | } 12 | } 13 | 14 | struct ClashConfigImportButton: View { 15 | 16 | @State private var isConfirmationDialogPresented = false 17 | @State private var isDocumentPickerViewPresented = false 18 | @State private var importItem: ClashConfigImportItem? 19 | @State private var fileURL: URL? 20 | 21 | var body: some View { 22 | Button { 23 | isConfirmationDialogPresented.toggle() 24 | } label: { 25 | Image(systemName: "plus") 26 | } 27 | .confirmationDialog(Text("添加配置"), isPresented: $isConfirmationDialogPresented, titleVisibility: .visible) { 28 | Button(role: nil) { 29 | importItem = ClashConfigImportItem(fileURL: nil) 30 | } label: { 31 | Text("下载配置文件") 32 | } 33 | Button(role: nil) { 34 | isDocumentPickerViewPresented.toggle() 35 | } label: { 36 | Text("导入本地配置文件") 37 | } 38 | Button("取消", role: .cancel, action: {}) 39 | } message: { 40 | Text("从网络下载或者文件App导入配置文件, 配置文件暂不支持Rule Provider") 41 | } 42 | .sheet(item: $importItem, onDismiss: nil) { 43 | ClashConfigImportView(importItem: $0) 44 | } 45 | .sheet(isPresented: $isDocumentPickerViewPresented) { 46 | DispatchQueue.main.async { 47 | importItem = ClashConfigImportItem(fileURL: fileURL) 48 | } 49 | } content: { 50 | DocumentPickerView(filenameExtension: "yaml", binding: $fileURL) 51 | .ignoresSafeArea() 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Clash/List/ClashConfigImportView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import CommonKit 3 | 4 | struct ClashConfigImportView: View { 5 | 6 | @Environment(\.managedObjectContext) private var context 7 | @Environment(\.dismiss) private var dismiss 8 | 9 | @State private var name: String = "" 10 | @State private var url: String = "" 11 | @State private var isURLEditable: Bool = true 12 | 13 | let importItem: ClashConfigImportItem 14 | 15 | @MainActor @State private var isProcessing: Bool = false 16 | 17 | var body: some View { 18 | NavigationView { 19 | Form { 20 | Section { 21 | HStack { 22 | Text("名称:") 23 | TextField("名称", text: $name, prompt: Text("请输入名称")) 24 | } 25 | if isURLEditable { 26 | HStack { 27 | Text("地址:") 28 | TextField("地址", text: $url, prompt: Text("请输入地址")) 29 | } 30 | } 31 | } 32 | Section { 33 | Button(action: importClashConfig) { 34 | HStack { 35 | Spacer() 36 | if isProcessing { 37 | ProgressView() 38 | } else { 39 | Text(importItem.fileURL == nil ? "下载" : "添加") 40 | } 41 | Spacer() 42 | } 43 | } 44 | .disabled(name.isEmpty || url.isEmpty) 45 | } 46 | } 47 | .navigationTitle("\(importItem.fileURL == nil ? "下载" : "添加")配置") 48 | .navigationBarTitleDisplayMode(.inline) 49 | } 50 | .disabled(isProcessing) 51 | .interactiveDismissDisabled(isProcessing) 52 | .onAppear { 53 | guard let fileURL = importItem.fileURL else { 54 | return 55 | } 56 | self.name = fileURL.deletingPathExtension().lastPathComponent 57 | self.url = fileURL.absoluteString 58 | self.isURLEditable = !fileURL.isFileURL 59 | } 60 | } 61 | 62 | private func importClashConfig() { 63 | guard let url = URL(string: url) else { 64 | return 65 | } 66 | Task(priority: .high) { 67 | await MainActor.run { 68 | isProcessing = true 69 | } 70 | do { 71 | try await context.importClashConfig(name: name, url: url) 72 | dismiss() 73 | } catch { 74 | debugPrint(error.localizedDescription) 75 | } 76 | await MainActor.run { 77 | isProcessing = false 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Clash/List/ClashConfigListView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import CommonKit 3 | 4 | struct ClashConfigListView: View { 5 | 6 | @AppStorage(Constant.currentConfigUUID, store: .shared) private var uuidString: String = "" 7 | 8 | @Environment(\.dismiss) private var dismiss 9 | @Environment(\.managedObjectContext) private var context 10 | @FetchRequest( 11 | sortDescriptors: [NSSortDescriptor(keyPath: \ClashConfig.date, ascending: false)], 12 | animation: .default 13 | ) private var configs: FetchedResults 14 | 15 | var body: some View { 16 | NavigationView { 17 | List(configs) { config in 18 | HStack { 19 | Text(config.name ?? "-") 20 | Spacer() 21 | if config.uuid.flatMap({ $0.uuidString }) == uuidString { 22 | Text(Image(systemName: "checkmark")) 23 | .fontWeight(.medium) 24 | .foregroundColor(Color.accentColor) 25 | } 26 | } 27 | .lineLimit(1) 28 | .contentShape(Rectangle()) 29 | .onTapGesture { onCellTapGesture(config: config) } 30 | .swipeActions(edge: .trailing, allowsFullSwipe: false) { 31 | Button("删除", role: .destructive) { onCellDeleteAction(config: config) } 32 | } 33 | } 34 | .navigationBarTitle("配置管理") 35 | .navigationBarTitleDisplayMode(.inline) 36 | .toolbar { 37 | ToolbarItem(placement: .navigationBarTrailing) { 38 | ClashConfigImportButton() 39 | } 40 | } 41 | } 42 | } 43 | 44 | private func onCellTapGesture(config: ClashConfig) { 45 | uuidString = config.uuid?.uuidString ?? "" 46 | dismiss() 47 | } 48 | 49 | private func onCellDeleteAction(config: ClashConfig) { 50 | do { 51 | if config.uuid.flatMap({ $0.uuidString }) == uuidString { 52 | uuidString = "" 53 | } 54 | try context.deleteClashConfig(config) 55 | } catch { 56 | debugPrint(error.localizedDescription) 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Clash/ManagedObjectFetchView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import CoreData 3 | 4 | public struct ManagedObjectFetchView: View { 5 | 6 | @FetchRequest private var results: FetchedResults 7 | 8 | private let content: (FetchedResults) -> Content 9 | 10 | public init( 11 | sortDescriptors: [NSSortDescriptor] = [], 12 | predicate: NSPredicate? = nil, 13 | animation: Animation? = nil, 14 | content: @escaping (FetchedResults) -> Content 15 | ) { 16 | _results = FetchRequest(entity: Object.entity(), sortDescriptors: sortDescriptors, predicate: predicate, animation: animation) 17 | self.content = content 18 | } 19 | 20 | public var body: some View { 21 | self.content(self.results) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Clash/ModalPresentationLink.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | struct ModalPresentationLink: View { 4 | 5 | private let destination: () -> Destination 6 | private let label: () -> Label 7 | private let onDismiss: (() -> Void)? 8 | 9 | @State private var isPresented = false 10 | 11 | init(destination: @escaping () -> Destination, label: @escaping () -> Label, onDismiss: (() -> Void)? = nil) { 12 | self.destination = destination 13 | self.label = label 14 | self.onDismiss = onDismiss 15 | } 16 | 17 | var body: some View { 18 | label() 19 | .contentShape(Rectangle()) 20 | .onTapGesture { isPresented.toggle() } 21 | .sheet(isPresented: $isPresented, onDismiss: onDismiss, content: destination) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Clash/NSManagedObjectContext+File.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import CoreData 3 | import CommonKit 4 | 5 | extension NSManagedObjectContext { 6 | 7 | func importClashConfig(name: String, url: URL) async throws { 8 | let content: String 9 | if url.isFileURL { 10 | content = try String(contentsOf: url) 11 | } else { 12 | let (data, _) = try await URLSession.shared.data(from: url, delegate: nil) 13 | content = String(data: data, encoding: .utf8) ?? "" 14 | } 15 | let uuid = UUID() 16 | let directoryURL = Constant.homeDirectoryURL.appendingPathComponent("\(uuid.uuidString)") 17 | try FileManager.default.createDirectory(at: directoryURL, withIntermediateDirectories: true, attributes: nil) 18 | let targetURL = directoryURL.appendingPathComponent("config.yaml") 19 | FileManager.default.createFile(atPath: targetURL.path, contents: content.data(using: .utf8), attributes: nil) 20 | let configuration = ClashConfig(context: self) 21 | configuration.uuid = uuid 22 | configuration.name = name 23 | configuration.link = targetURL 24 | configuration.date = Date() 25 | try self.save() 26 | } 27 | 28 | func deleteClashConfig(_ config: ClashConfig) throws { 29 | self.delete(config) 30 | try self.save() 31 | guard let uuid = config.uuid else { 32 | return 33 | } 34 | try FileManager.default.removeItem(at: Constant.homeDirectoryURL.appendingPathComponent("\(uuid.uuidString)")) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Clash/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Clash/Setting/ClashLogView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import CommonKit 3 | 4 | struct ClashLogView: View { 5 | 6 | @EnvironmentObject private var manager: VPNManager 7 | 8 | @AppStorage(Constant.logLevel, store: .shared) private var logLevel: ClashLogLevel = .silent 9 | 10 | var body: some View { 11 | NavigationLink { 12 | Form { 13 | Picker("日志等级", selection: $logLevel) { 14 | ForEach(ClashLogLevel.allCases) { level in 15 | Text(level.displayName) 16 | } 17 | } 18 | .pickerStyle(.inline) 19 | .labelsHidden() 20 | } 21 | .navigationBarTitle("日志等级") 22 | .task(id: logLevel) { 23 | guard let controller = self.manager.controller else { 24 | return 25 | } 26 | do { 27 | try await controller.execute(command: .setLogLevel) 28 | } catch { 29 | debugPrint(error) 30 | } 31 | } 32 | } label: { 33 | HStack { 34 | Image(systemName: "doc.text") 35 | .font(.title2) 36 | .foregroundColor(Color.accentColor) 37 | Text("日志等级") 38 | Spacer() 39 | Text(logLevel.displayName) 40 | .fontWeight(.bold) 41 | } 42 | } 43 | } 44 | } 45 | 46 | fileprivate extension ClashLogLevel { 47 | 48 | var displayName: String { 49 | switch self { 50 | case .silent: 51 | return "静默" 52 | case .info: 53 | return "信息" 54 | case .debug: 55 | return "调试" 56 | case .warning: 57 | return "警告" 58 | case .error: 59 | return "错误" 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Clash/Setting/SettingView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | struct SettingView: View { 4 | 5 | @EnvironmentObject private var manager: VPNManager 6 | 7 | var body: some View { 8 | NavigationView { 9 | Form { 10 | Section { 11 | ClashLogView() 12 | } 13 | Section { 14 | UninstallVPNView() 15 | .disabled(manager.controller == nil) 16 | } 17 | } 18 | .navigationTitle("设置") 19 | .navigationBarTitleDisplayMode(.inline) 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Clash/Setting/UninstallVPNView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | struct UninstallVPNView: View { 4 | 5 | @EnvironmentObject private var manager: VPNManager 6 | 7 | @State private var isAlertPresented = false 8 | 9 | var body: some View { 10 | Button(role: .destructive, action: { isAlertPresented.toggle() }) { 11 | HStack { 12 | Spacer() 13 | Text("移除VPN配置") 14 | .fontWeight(.bold) 15 | Spacer() 16 | } 17 | } 18 | .alert("移除VPN配置", isPresented: $isAlertPresented) { 19 | Button("确定", role: .destructive) { 20 | Task(priority: .high) { 21 | guard let controller = manager.controller else { 22 | return 23 | } 24 | do { 25 | try await controller.uninstallVPNConfiguration() 26 | await manager.refreshController() 27 | } catch { 28 | debugPrint(error.localizedDescription) 29 | } 30 | } 31 | } 32 | } message: { 33 | Text("移除VPN配置后, 您可以在主页点击配置开关重新添加VPN配置") 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Clash/VPNManager.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Combine 3 | import NetworkExtension 4 | import CommonKit 5 | 6 | @MainActor public final class VPNManager: ObservableObject { 7 | 8 | private var cancellables: Set = [] 9 | 10 | @Published public var controller: VPNController? 11 | 12 | public init() { 13 | NotificationCenter.default 14 | .publisher(for: UIApplication.willEnterForegroundNotification, object: nil) 15 | .receive(on: DispatchQueue.main) 16 | .sink { [unowned self] in self.handleWillEnterForegroundNotification($0) } 17 | .store(in: &self.cancellables) 18 | } 19 | 20 | private func handleWillEnterForegroundNotification(_ notification: Notification) { 21 | Task(priority: .high) { 22 | await self.refreshController() 23 | } 24 | } 25 | 26 | public func refreshController() async { 27 | if let manager = try? await self.loadCurrentTunnelProviderManager() { 28 | if let controller = self.controller, controller.isEqually(manager: manager) { 29 | // Nothing 30 | } else { 31 | self.controller = VPNController(providerManager: manager) 32 | } 33 | } else { 34 | self.controller = nil 35 | } 36 | } 37 | 38 | private func loadCurrentTunnelProviderManager() async throws -> NETunnelProviderManager? { 39 | let managers = try await NETunnelProviderManager.loadAllFromPreferences() 40 | if let manager = managers.first(where: { $0.localizedDescription == "Clash" }) { 41 | try await manager.loadFromPreferences() 42 | return manager 43 | } else { 44 | return nil 45 | } 46 | } 47 | 48 | public func installVPNConfiguration() async throws { 49 | let manager = NETunnelProviderManager() 50 | manager.localizedDescription = "Clash" 51 | manager.protocolConfiguration = { 52 | let configuration = NETunnelProviderProtocol() 53 | configuration.providerBundleIdentifier = "com.Arror.Clash.PacketTunnel" 54 | configuration.serverAddress = "Clash" 55 | configuration.includeAllNetworks = true 56 | configuration.excludeLocalNetworks = true 57 | return configuration 58 | }() 59 | manager.isEnabled = true 60 | manager.isOnDemandEnabled = true 61 | try await manager.saveToPreferences() 62 | } 63 | } 64 | 65 | @MainActor public final class VPNController: ObservableObject { 66 | 67 | private var cancellables: Set = [] 68 | private let providerManager: NETunnelProviderManager 69 | 70 | public var connectedDate: Date? { 71 | self.providerManager.connection.connectedDate 72 | } 73 | 74 | @Published public var connectionStatus: NEVPNStatus 75 | 76 | public init(providerManager: NETunnelProviderManager) { 77 | self.providerManager = providerManager 78 | self.connectionStatus = providerManager.connection.status 79 | NotificationCenter.default 80 | .publisher(for: Notification.Name.NEVPNStatusDidChange, object: self.providerManager.connection) 81 | .receive(on: DispatchQueue.main) 82 | .sink { [unowned self] in self.handleVPNStatusDidChangeNotification($0) } 83 | .store(in: &self.cancellables) 84 | } 85 | 86 | private func handleVPNStatusDidChangeNotification(_ notification: Notification) { 87 | guard let connection = notification.object as? NEVPNConnection, connection === self.providerManager.connection else { 88 | return 89 | } 90 | self.connectionStatus = connection.status 91 | } 92 | 93 | public func isEqually(manager: NETunnelProviderManager) -> Bool { 94 | self.providerManager === manager 95 | } 96 | 97 | public func startVPN() async throws { 98 | switch self.providerManager.connection.status { 99 | case .disconnecting, .disconnected: 100 | break 101 | case .connecting, .connected, .reasserting, .invalid: 102 | return 103 | @unknown default: 104 | break 105 | } 106 | if !self.providerManager.isEnabled { 107 | self.providerManager.isEnabled = true 108 | try await self.providerManager.saveToPreferences() 109 | } 110 | try self.providerManager.connection.startVPNTunnel() 111 | } 112 | 113 | public func stopVPN() { 114 | switch self.providerManager.connection.status { 115 | case .disconnecting, .disconnected, .invalid: 116 | return 117 | case .connecting, .connected, .reasserting: 118 | break 119 | @unknown default: 120 | break 121 | } 122 | self.providerManager.connection.stopVPNTunnel() 123 | } 124 | 125 | public func uninstallVPNConfiguration() async throws { 126 | try await self.providerManager.removeFromPreferences() 127 | } 128 | 129 | public func execute(command: ClashCommand) async throws { 130 | try await self.providerManager.sendProviderMessage(data: Data(repeating: command.rawValue, count: 1)) 131 | } 132 | } 133 | 134 | 135 | fileprivate extension NETunnelProviderManager { 136 | 137 | @discardableResult 138 | func sendProviderMessage(data: Data) async throws -> Data? { 139 | return try await withCheckedThrowingContinuation { continuation in 140 | do { 141 | try (self.connection as! NETunnelProviderSession).sendProviderMessage(data) { 142 | continuation.resume(with: .success($0)) 143 | } 144 | } catch { 145 | continuation.resume(with: .failure(error)) 146 | } 147 | } 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /CommonKit/ClashCommand.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public enum ClashCommand: UInt8 { 4 | case setCurrentConfig 5 | case setTunnelMode 6 | case setLogLevel 7 | } 8 | -------------------------------------------------------------------------------- /CommonKit/ClashError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public struct ClashError: CustomNSError { 4 | 5 | public static let errorDomain: String = "com.Arror.Clash" 6 | 7 | public let errorCode: Int 8 | 9 | public let errorUserInfo: [String : Any] 10 | 11 | public init(code: Int, localizedDescription: String) { 12 | self.errorCode = code 13 | self.errorUserInfo = [NSLocalizedDescriptionKey: localizedDescription] 14 | } 15 | 16 | public static func custom(withLocalizedDescription description: String) -> ClashError { 17 | ClashError(code: 0, localizedDescription: description) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CommonKit/ClashLogLevel.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public enum ClashLogLevel: String, Identifiable, CaseIterable { 4 | 5 | public var id: Self { self } 6 | 7 | case silent, info, debug, warning, error 8 | } 9 | -------------------------------------------------------------------------------- /CommonKit/ClashTraffic.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public enum ClashTraffic: String { 4 | case up = "ClashTrafficUP" 5 | case down = "ClashTrafficDOWN" 6 | } 7 | -------------------------------------------------------------------------------- /CommonKit/ClashTunnelMode.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public enum ClashTunnelMode: String, Hashable, Identifiable, CaseIterable { 4 | 5 | public var id: Self { self } 6 | 7 | case global, rule, direct 8 | } 9 | -------------------------------------------------------------------------------- /CommonKit/CommonKit.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | FOUNDATION_EXPORT double CommonKitVersionNumber; 4 | 5 | FOUNDATION_EXPORT const unsigned char CommonKitVersionString[]; 6 | -------------------------------------------------------------------------------- /CommonKit/Constant.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public enum Constant { 4 | 5 | public static let appGroup: String = Bundle.main.infoDictionary?["CLASH_APP_GROUP"] as! String 6 | 7 | public static let tunnelMode: String = "ClashTunnelMode" 8 | 9 | public static let logLevel: String = "ClashLogLevel" 10 | 11 | public static let currentConfigUUID: String = "CurrentConfigUUID" 12 | 13 | public static let homeDirectoryURL: URL = { 14 | guard let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: Constant.appGroup) else { 15 | fatalError("无法加载共享文件路径") 16 | } 17 | let url = containerURL.appendingPathComponent("Library/Application Support/Clash") 18 | guard FileManager.default.fileExists(atPath: url.path) == false else { 19 | return url 20 | } 21 | do { 22 | try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true, attributes: nil) 23 | } catch { 24 | fatalError(error.localizedDescription) 25 | } 26 | return url 27 | }() 28 | } 29 | -------------------------------------------------------------------------------- /CommonKit/CoreData/Clash.xcdatamodeld/Clash.xcdatamodel/contents: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /CommonKit/CoreData/CoreDataStack.swift: -------------------------------------------------------------------------------- 1 | import CoreData 2 | 3 | private class ClashPersistentContainer: NSPersistentContainer { 4 | 5 | override class func defaultDirectoryURL() -> URL { 6 | Constant.homeDirectoryURL.appendingPathComponent("CoreData", isDirectory: true) 7 | } 8 | } 9 | 10 | public final class CoreDataStack { 11 | 12 | public static let shared = CoreDataStack() 13 | 14 | public let container: NSPersistentContainer 15 | 16 | private init() { 17 | guard let url = Bundle(for: CoreDataStack.self).url(forResource: "Clash", withExtension: "momd"), 18 | let model = NSManagedObjectModel(contentsOf: url) else { 19 | fatalError("数据库模型文件加载失败") 20 | } 21 | self.container = ClashPersistentContainer(name: "Clash", managedObjectModel: model) 22 | self.loadPersistentStores() 23 | } 24 | 25 | private func loadPersistentStores() { 26 | self.container.loadPersistentStores { storeDescription, error in 27 | guard error != nil else { 28 | return 29 | } 30 | guard let fileURL = storeDescription.url else { 31 | fatalError("无法找到数据库文件") 32 | } 33 | do { 34 | try FileManager.default.removeItem(at: fileURL) 35 | self.loadPersistentStores() 36 | } catch { 37 | fatalError("删除数据库失败: \(error.localizedDescription)") 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /CommonKit/UserDefaults+AppGroup.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension UserDefaults { 4 | 5 | public static let shared: UserDefaults = UserDefaults(suiteName: Constant.appGroup)! 6 | } 7 | -------------------------------------------------------------------------------- /Config-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Config.xcconfig" 2 | -------------------------------------------------------------------------------- /Config-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Config.xcconfig" 2 | -------------------------------------------------------------------------------- /Config.xcconfig: -------------------------------------------------------------------------------- 1 | CLASH_PRODUCT_BUNDLE_IDENTIFIER = com.Arror.Clash 2 | CLASH_APP_GROUP = group.com.Arror.Clash 3 | CLASH_MARKETING_VERSION = 1.0 4 | CLASH_CURRENT_PROJECT_VERSION = 1 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /PacketTunnel/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CLASH_APP_GROUP 6 | ${CLASH_APP_GROUP} 7 | NSExtension 8 | 9 | NSExtensionPointIdentifier 10 | com.apple.networkextension.packet-tunnel 11 | NSExtensionPrincipalClass 12 | $(PRODUCT_MODULE_NAME).PacketTunnelProvider 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /PacketTunnel/PacketTunnel.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.developer.networking.networkextension 6 | 7 | packet-tunnel-provider 8 | 9 | com.apple.security.application-groups 10 | 11 | ${CLASH_APP_GROUP} 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /PacketTunnel/PacketTunnelProvider+Clash.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import CommonKit 3 | import ClashKit 4 | 5 | extension PacketTunnelProvider: ClashPacketFlowProtocol, ClashTrafficReceiverProtocol, ClashRealTimeLoggerProtocol { 6 | 7 | func setupClash() throws { 8 | let config = """ 9 | mixed-port: 8080 10 | mode: \(UserDefaults.shared.string(forKey: Constant.tunnelMode) ?? ClashTunnelMode.rule.rawValue) 11 | log-level: \(UserDefaults.shared.string(forKey: Constant.logLevel) ?? ClashLogLevel.silent.rawValue) 12 | dns: 13 | enable: true 14 | ipv6: false 15 | listen: 0.0.0.0:53 16 | enhanced-mode: redir-host 17 | use-hosts: false 18 | nameserver: 19 | - 114.114.114.114 20 | fallback: 21 | - 8.8.8.8 22 | - 1.1.1.1 23 | - tls://8.8.8.8:853 24 | - tls://1.1.1.1:853 25 | - https://dns.google/dns-query 26 | - https://cloudflare-dns.com/dns-query 27 | fallback-filter: 28 | geoip: true 29 | ipcidr: 30 | - 240.0.0.0/4 31 | """ 32 | var error: NSError? = nil 33 | ClashSetup(self, Constant.homeDirectoryURL.path, config, &error) 34 | if let error = error { 35 | throw error 36 | } 37 | ClashSetRealTimeLogger(self) 38 | ClashSetTrafficReceiver(self) 39 | } 40 | 41 | func setCurrentConfig() throws { 42 | var error: NSError? = nil 43 | ClashSetConfig(UserDefaults.shared.string(forKey: Constant.currentConfigUUID), &error) 44 | guard let error = error else { 45 | return 46 | } 47 | throw error 48 | } 49 | 50 | func writePacket(_ packet: Data?) { 51 | guard let packet = packet else { 52 | return 53 | } 54 | self.packetFlow.writePackets([packet], withProtocols: [AF_INET as NSNumber]) 55 | } 56 | 57 | func receiveTraffic(_ up: Int64, down: Int64) { 58 | UserDefaults.shared.set(Double(up), forKey: ClashTraffic.up.rawValue) 59 | UserDefaults.shared.set(Double(down), forKey: ClashTraffic.down.rawValue) 60 | } 61 | 62 | func log(_ level: String?, payload: String?) { 63 | guard let level = level.flatMap(ClashLogLevel.init(rawValue:)), 64 | let payload = payload, !payload.isEmpty else { 65 | return 66 | } 67 | NSLog("Clash Core: [\(level.rawValue.uppercased())] \(payload)") 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /PacketTunnel/PacketTunnelProvider.swift: -------------------------------------------------------------------------------- 1 | import NetworkExtension 2 | import CommonKit 3 | import ClashKit 4 | 5 | class PacketTunnelProvider: NEPacketTunnelProvider { 6 | 7 | override func startTunnel(options: [String : NSObject]? = nil) async throws { 8 | try self.setupClash() 9 | try self.setCurrentConfig() 10 | let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "240.240.240.240") 11 | settings.mtu = 1500 12 | settings.ipv4Settings = { 13 | let settings = NEIPv4Settings(addresses: ["240.0.0.1"], subnetMasks: ["255.255.255.0"]) 14 | settings.includedRoutes = [NEIPv4Route.default()] 15 | return settings 16 | }() 17 | settings.proxySettings = { 18 | let settings = NEProxySettings() 19 | settings.matchDomains = [""] 20 | settings.excludeSimpleHostnames = true 21 | settings.httpEnabled = true 22 | settings.httpServer = NEProxyServer(address: "127.0.0.1", port: 8080) 23 | settings.httpsEnabled = true 24 | settings.httpsServer = NEProxyServer(address: "127.0.0.1", port: 8080) 25 | return settings 26 | }() 27 | settings.dnsSettings = { 28 | let settings = NEDNSSettings(servers: ["127.0.0.1"]) 29 | return settings 30 | }() 31 | try await self.setTunnelNetworkSettings(settings) 32 | DispatchQueue.main.async(execute: self.readPackets) 33 | } 34 | 35 | private func readPackets() { 36 | self.packetFlow.readPackets { packets, _ in 37 | packets.forEach(ClashReadPacket(_:)) 38 | self.readPackets() 39 | } 40 | } 41 | 42 | override func stopTunnel(with reason: NEProviderStopReason) async { 43 | do { 44 | try await self.setTunnelNetworkSettings(nil) 45 | } catch { 46 | debugPrint(error) 47 | } 48 | self.receiveTraffic(0, down: 0) 49 | } 50 | 51 | override func handleAppMessage(_ messageData: Data) async -> Data? { 52 | guard let command = messageData.first.flatMap(ClashCommand.init(rawValue:)) else { 53 | return nil 54 | } 55 | switch command { 56 | case .setCurrentConfig: 57 | do { 58 | try self.setCurrentConfig() 59 | } catch { 60 | return error.localizedDescription.data(using: .utf8) 61 | } 62 | case .setTunnelMode: 63 | ClashSetTunnelMode(UserDefaults.shared.string(forKey: Constant.tunnelMode)) 64 | case .setLogLevel: 65 | ClashSetLogLevel(UserDefaults.shared.string(forKey: Constant.logLevel)) 66 | } 67 | return nil 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | Clash 2 | 项目基于 clash(https://github.com/Dreamacro/clash) 实现 3 | 4 | 环境要求 5 | iOS 15.0及以上 6 | --------------------------------------------------------------------------------