├── .gitignore ├── .swift-version ├── LICENSE ├── README.md ├── SandboxBrowser.podspec ├── SandboxBrowserExample.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── SandboxBrowserExample ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── SandboxBrowser │ ├── Resources │ │ └── Resources.bundle │ │ │ ├── directory.png │ │ │ ├── file.png │ │ │ ├── image.png │ │ │ ├── log.png │ │ │ ├── plist.png │ │ │ └── sqlite.png │ └── SandboxBrowser.swift └── ViewController.swift └── Screenshot ├── SimulatorScreenShot1.png ├── SimulatorScreenShot2.png └── SimulatorScreenShot3.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Adapted from https://github.com/github/gitignore/blob/master/Objective-C.gitignore 2 | 3 | # Finder 4 | .DS_Store 5 | 6 | # Xcode 7 | ## Build generated 8 | build/ 9 | DerivedData/ 10 | 11 | ## Various settings 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata/ 21 | 22 | ## Other 23 | *.moved-aside 24 | *.xccheckout 25 | *.xcscmblueprint 26 | 27 | ## Obj-C/Swift specific 28 | *.hmap 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | .build/ 43 | 44 | # CocoaPods 45 | # 46 | # We recommend against adding the Pods directory to your .gitignore. However 47 | # you should judge for yourself, the pros and cons are mentioned at: 48 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 49 | # 50 | # Pods/ 51 | 52 | # Carthage 53 | # 54 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 55 | # Carthage/Checkouts 56 | 57 | Carthage/Build 58 | 59 | # fastlane 60 | # 61 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 62 | # screenshots whenever they are needed. 63 | # For more information about the recommended setup visit: 64 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 65 | 66 | fastlane/report.xml 67 | fastlane/Preview.html 68 | fastlane/screenshots 69 | fastlane/test_output 70 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 4.2 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 devjoe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### SandboxBrowser 2 | 3 | [![Version](https://img.shields.io/cocoapods/v/SandboxBrowser.svg?style=flat)](http://cocoapods.org/pods/SandboxBrowser) 4 | [![License](https://img.shields.io/cocoapods/l/SandboxBrowser.svg?style=flat)](http://cocoapods.org/pods/SandboxBrowser) 5 | [![Platform](https://img.shields.io/cocoapods/p/SandboxBrowser.svg?style=flat)](http://cocoapods.org/pods/SandboxBrowser) 6 | 7 | A simple iOS sandbox file browser, enable you to view sandbox file system on iOS device, share files via airdrop, super convenient when you want to send log files from iOS device to Mac. reference from [AirSandbox](https://github.com/music4kid/AirSandbox), Thanks ! 8 | 9 | ### Screenshots 10 | 11 | 12 | ### Installation 13 | 14 | To integrate SandboxBrowser into your Xcode project using CocoaPods, specify it in your Podfile: 15 | 16 | ``` 17 | pod 'SandboxBrowser' 18 | ``` 19 | 20 | Then, run pod install. 21 | 22 | 23 | ### Usage 24 | 25 | ``` 26 | import SandboxBrowser 27 | ``` 28 | 29 | ``` 30 | let sandboxBrowser = SandboxBrowser() 31 | present(sandboxBrowser, animated: true, completion: nil) 32 | ``` 33 | Open the sandbox directory by default, and you can specify the directory 34 | 35 | ``` 36 | let sandboxBrowser = SandboxBrowser(initialPath: customURL) 37 | ``` 38 | 39 | Use the didSelectFile closure to change FileBrowser's behaviour when a file is selected. 40 | 41 | ``` 42 | sandboxBrowser.didSelectFile = { file, vc in 43 | print(file.name, file.type) 44 | } 45 | ``` 46 | 47 | Long press file share via AirDrop 48 | 49 | ### License 50 | MIT 51 | 52 | 53 | -------------------------------------------------------------------------------- /SandboxBrowser.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | spec.name = 'SandboxBrowser' 3 | spec.version = '0.0.5' 4 | spec.license = { :type => 'MIT' } 5 | spec.homepage = 'https://github.com/aidevjoe/SandboxBrowser' 6 | spec.authors = { 'Joe' => 'aidevjoe@gmail.com' } 7 | spec.summary = "A simple iOS sandbox file browser." 8 | spec.source = { :git => "https://github.com/aidevjoe/SandboxBrowser.git", :tag => spec.version } 9 | spec.platform = :ios, "11.0" 10 | spec.source_files = 'SandboxBrowserExample/SandboxBrowser/*.{swift}' 11 | spec.resources = 'SandboxBrowserExample/SandboxBrowser/Resources/*.{bundle}' 12 | spec.requires_arc = true 13 | end 14 | -------------------------------------------------------------------------------- /SandboxBrowserExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 770DD25A1F5302D000D054EB /* Resources.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 770DD2591F5302D000D054EB /* Resources.bundle */; }; 11 | 77FD506E1F52E0690037DAE1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77FD50631F52E0690037DAE1 /* AppDelegate.swift */; }; 12 | 77FD506F1F52E0690037DAE1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 77FD50641F52E0690037DAE1 /* Assets.xcassets */; }; 13 | 77FD50701F52E0690037DAE1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 77FD50651F52E0690037DAE1 /* LaunchScreen.storyboard */; }; 14 | 77FD50711F52E0690037DAE1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 77FD50671F52E0690037DAE1 /* Main.storyboard */; }; 15 | 77FD50741F52E0690037DAE1 /* SandboxBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77FD506C1F52E0690037DAE1 /* SandboxBrowser.swift */; }; 16 | 77FD50751F52E0690037DAE1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77FD506D1F52E0690037DAE1 /* ViewController.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 770DD2591F5302D000D054EB /* Resources.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Resources.bundle; sourceTree = ""; }; 21 | 77FD50631F52E0690037DAE1 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | 77FD50641F52E0690037DAE1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 23 | 77FD50661F52E0690037DAE1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 24 | 77FD50681F52E0690037DAE1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 25 | 77FD50691F52E0690037DAE1 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | 77FD506C1F52E0690037DAE1 /* SandboxBrowser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SandboxBrowser.swift; sourceTree = ""; }; 27 | 77FD506D1F52E0690037DAE1 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 28 | BF8EFE321F4FDFC50051A2B7 /* SandboxBrowserExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SandboxBrowserExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | BF8EFE2F1F4FDFC50051A2B7 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 770DD2581F5302D000D054EB /* Resources */ = { 43 | isa = PBXGroup; 44 | children = ( 45 | 770DD2591F5302D000D054EB /* Resources.bundle */, 46 | ); 47 | path = Resources; 48 | sourceTree = ""; 49 | }; 50 | 77FD50621F52E0690037DAE1 /* SandboxBrowserExample */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 77FD50631F52E0690037DAE1 /* AppDelegate.swift */, 54 | 77FD50641F52E0690037DAE1 /* Assets.xcassets */, 55 | 77FD50691F52E0690037DAE1 /* Info.plist */, 56 | 77FD50651F52E0690037DAE1 /* LaunchScreen.storyboard */, 57 | 77FD50671F52E0690037DAE1 /* Main.storyboard */, 58 | 77FD506A1F52E0690037DAE1 /* SandboxBrowser */, 59 | 77FD506D1F52E0690037DAE1 /* ViewController.swift */, 60 | ); 61 | path = SandboxBrowserExample; 62 | sourceTree = ""; 63 | }; 64 | 77FD506A1F52E0690037DAE1 /* SandboxBrowser */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 770DD2581F5302D000D054EB /* Resources */, 68 | 77FD506C1F52E0690037DAE1 /* SandboxBrowser.swift */, 69 | ); 70 | path = SandboxBrowser; 71 | sourceTree = ""; 72 | }; 73 | BF8EFE291F4FDFC50051A2B7 = { 74 | isa = PBXGroup; 75 | children = ( 76 | 77FD50621F52E0690037DAE1 /* SandboxBrowserExample */, 77 | BF8EFE331F4FDFC50051A2B7 /* Products */, 78 | ); 79 | sourceTree = ""; 80 | }; 81 | BF8EFE331F4FDFC50051A2B7 /* Products */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | BF8EFE321F4FDFC50051A2B7 /* SandboxBrowserExample.app */, 85 | ); 86 | name = Products; 87 | sourceTree = ""; 88 | }; 89 | /* End PBXGroup section */ 90 | 91 | /* Begin PBXNativeTarget section */ 92 | BF8EFE311F4FDFC50051A2B7 /* SandboxBrowserExample */ = { 93 | isa = PBXNativeTarget; 94 | buildConfigurationList = BF8EFE441F4FDFC50051A2B7 /* Build configuration list for PBXNativeTarget "SandboxBrowserExample" */; 95 | buildPhases = ( 96 | BF8EFE2E1F4FDFC50051A2B7 /* Sources */, 97 | BF8EFE2F1F4FDFC50051A2B7 /* Frameworks */, 98 | BF8EFE301F4FDFC50051A2B7 /* Resources */, 99 | ); 100 | buildRules = ( 101 | ); 102 | dependencies = ( 103 | ); 104 | name = SandboxBrowserExample; 105 | productName = AirSandboxExample; 106 | productReference = BF8EFE321F4FDFC50051A2B7 /* SandboxBrowserExample.app */; 107 | productType = "com.apple.product-type.application"; 108 | }; 109 | /* End PBXNativeTarget section */ 110 | 111 | /* Begin PBXProject section */ 112 | BF8EFE2A1F4FDFC50051A2B7 /* Project object */ = { 113 | isa = PBXProject; 114 | attributes = { 115 | LastSwiftUpdateCheck = 0830; 116 | LastUpgradeCheck = 1000; 117 | ORGANIZATIONNAME = DanXiao; 118 | TargetAttributes = { 119 | BF8EFE311F4FDFC50051A2B7 = { 120 | CreatedOnToolsVersion = 8.3.3; 121 | ProvisioningStyle = Automatic; 122 | }; 123 | }; 124 | }; 125 | buildConfigurationList = BF8EFE2D1F4FDFC50051A2B7 /* Build configuration list for PBXProject "SandboxBrowserExample" */; 126 | compatibilityVersion = "Xcode 3.2"; 127 | developmentRegion = English; 128 | hasScannedForEncodings = 0; 129 | knownRegions = ( 130 | English, 131 | en, 132 | Base, 133 | ); 134 | mainGroup = BF8EFE291F4FDFC50051A2B7; 135 | productRefGroup = BF8EFE331F4FDFC50051A2B7 /* Products */; 136 | projectDirPath = ""; 137 | projectRoot = ""; 138 | targets = ( 139 | BF8EFE311F4FDFC50051A2B7 /* SandboxBrowserExample */, 140 | ); 141 | }; 142 | /* End PBXProject section */ 143 | 144 | /* Begin PBXResourcesBuildPhase section */ 145 | BF8EFE301F4FDFC50051A2B7 /* Resources */ = { 146 | isa = PBXResourcesBuildPhase; 147 | buildActionMask = 2147483647; 148 | files = ( 149 | 770DD25A1F5302D000D054EB /* Resources.bundle in Resources */, 150 | 77FD50711F52E0690037DAE1 /* Main.storyboard in Resources */, 151 | 77FD506F1F52E0690037DAE1 /* Assets.xcassets in Resources */, 152 | 77FD50701F52E0690037DAE1 /* LaunchScreen.storyboard in Resources */, 153 | ); 154 | runOnlyForDeploymentPostprocessing = 0; 155 | }; 156 | /* End PBXResourcesBuildPhase section */ 157 | 158 | /* Begin PBXSourcesBuildPhase section */ 159 | BF8EFE2E1F4FDFC50051A2B7 /* Sources */ = { 160 | isa = PBXSourcesBuildPhase; 161 | buildActionMask = 2147483647; 162 | files = ( 163 | 77FD50751F52E0690037DAE1 /* ViewController.swift in Sources */, 164 | 77FD50741F52E0690037DAE1 /* SandboxBrowser.swift in Sources */, 165 | 77FD506E1F52E0690037DAE1 /* AppDelegate.swift in Sources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXSourcesBuildPhase section */ 170 | 171 | /* Begin PBXVariantGroup section */ 172 | 77FD50651F52E0690037DAE1 /* LaunchScreen.storyboard */ = { 173 | isa = PBXVariantGroup; 174 | children = ( 175 | 77FD50661F52E0690037DAE1 /* Base */, 176 | ); 177 | name = LaunchScreen.storyboard; 178 | sourceTree = ""; 179 | }; 180 | 77FD50671F52E0690037DAE1 /* Main.storyboard */ = { 181 | isa = PBXVariantGroup; 182 | children = ( 183 | 77FD50681F52E0690037DAE1 /* Base */, 184 | ); 185 | name = Main.storyboard; 186 | sourceTree = ""; 187 | }; 188 | /* End PBXVariantGroup section */ 189 | 190 | /* Begin XCBuildConfiguration section */ 191 | BF8EFE421F4FDFC50051A2B7 /* Debug */ = { 192 | isa = XCBuildConfiguration; 193 | buildSettings = { 194 | ALWAYS_SEARCH_USER_PATHS = NO; 195 | CLANG_ANALYZER_NONNULL = YES; 196 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 197 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 198 | CLANG_CXX_LIBRARY = "libc++"; 199 | CLANG_ENABLE_MODULES = YES; 200 | CLANG_ENABLE_OBJC_ARC = YES; 201 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 202 | CLANG_WARN_BOOL_CONVERSION = YES; 203 | CLANG_WARN_COMMA = YES; 204 | CLANG_WARN_CONSTANT_CONVERSION = YES; 205 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 206 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 207 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 208 | CLANG_WARN_EMPTY_BODY = YES; 209 | CLANG_WARN_ENUM_CONVERSION = YES; 210 | CLANG_WARN_INFINITE_RECURSION = YES; 211 | CLANG_WARN_INT_CONVERSION = YES; 212 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 213 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 214 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 215 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 216 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 217 | CLANG_WARN_STRICT_PROTOTYPES = YES; 218 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 219 | CLANG_WARN_UNREACHABLE_CODE = YES; 220 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 221 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 222 | COPY_PHASE_STRIP = NO; 223 | DEBUG_INFORMATION_FORMAT = dwarf; 224 | ENABLE_STRICT_OBJC_MSGSEND = YES; 225 | ENABLE_TESTABILITY = YES; 226 | GCC_C_LANGUAGE_STANDARD = gnu99; 227 | GCC_DYNAMIC_NO_PIC = NO; 228 | GCC_NO_COMMON_BLOCKS = YES; 229 | GCC_OPTIMIZATION_LEVEL = 0; 230 | GCC_PREPROCESSOR_DEFINITIONS = ( 231 | "DEBUG=1", 232 | "$(inherited)", 233 | ); 234 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 235 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 236 | GCC_WARN_UNDECLARED_SELECTOR = YES; 237 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 238 | GCC_WARN_UNUSED_FUNCTION = YES; 239 | GCC_WARN_UNUSED_VARIABLE = YES; 240 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 241 | MTL_ENABLE_DEBUG_INFO = YES; 242 | ONLY_ACTIVE_ARCH = YES; 243 | SDKROOT = iphoneos; 244 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 245 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 246 | }; 247 | name = Debug; 248 | }; 249 | BF8EFE431F4FDFC50051A2B7 /* Release */ = { 250 | isa = XCBuildConfiguration; 251 | buildSettings = { 252 | ALWAYS_SEARCH_USER_PATHS = NO; 253 | CLANG_ANALYZER_NONNULL = YES; 254 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 255 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 256 | CLANG_CXX_LIBRARY = "libc++"; 257 | CLANG_ENABLE_MODULES = YES; 258 | CLANG_ENABLE_OBJC_ARC = YES; 259 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 260 | CLANG_WARN_BOOL_CONVERSION = YES; 261 | CLANG_WARN_COMMA = YES; 262 | CLANG_WARN_CONSTANT_CONVERSION = YES; 263 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 264 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 265 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 266 | CLANG_WARN_EMPTY_BODY = YES; 267 | CLANG_WARN_ENUM_CONVERSION = YES; 268 | CLANG_WARN_INFINITE_RECURSION = YES; 269 | CLANG_WARN_INT_CONVERSION = YES; 270 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 271 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 272 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 273 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 274 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 275 | CLANG_WARN_STRICT_PROTOTYPES = YES; 276 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 277 | CLANG_WARN_UNREACHABLE_CODE = YES; 278 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 279 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 280 | COPY_PHASE_STRIP = NO; 281 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 282 | ENABLE_NS_ASSERTIONS = NO; 283 | ENABLE_STRICT_OBJC_MSGSEND = YES; 284 | GCC_C_LANGUAGE_STANDARD = gnu99; 285 | GCC_NO_COMMON_BLOCKS = YES; 286 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 287 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 288 | GCC_WARN_UNDECLARED_SELECTOR = YES; 289 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 290 | GCC_WARN_UNUSED_FUNCTION = YES; 291 | GCC_WARN_UNUSED_VARIABLE = YES; 292 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 293 | MTL_ENABLE_DEBUG_INFO = NO; 294 | SDKROOT = iphoneos; 295 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 296 | VALIDATE_PRODUCT = YES; 297 | }; 298 | name = Release; 299 | }; 300 | BF8EFE451F4FDFC50051A2B7 /* Debug */ = { 301 | isa = XCBuildConfiguration; 302 | buildSettings = { 303 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 304 | DEVELOPMENT_TEAM = ""; 305 | INFOPLIST_FILE = SandboxBrowserExample/Info.plist; 306 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 307 | PRODUCT_BUNDLE_IDENTIFIER = com.SandboxBrowser.Example; 308 | PRODUCT_NAME = "$(TARGET_NAME)"; 309 | SWIFT_VERSION = 5.0; 310 | }; 311 | name = Debug; 312 | }; 313 | BF8EFE461F4FDFC50051A2B7 /* Release */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 317 | DEVELOPMENT_TEAM = ""; 318 | INFOPLIST_FILE = SandboxBrowserExample/Info.plist; 319 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 320 | PRODUCT_BUNDLE_IDENTIFIER = com.SandboxBrowser.Example; 321 | PRODUCT_NAME = "$(TARGET_NAME)"; 322 | SWIFT_VERSION = 5.0; 323 | }; 324 | name = Release; 325 | }; 326 | /* End XCBuildConfiguration section */ 327 | 328 | /* Begin XCConfigurationList section */ 329 | BF8EFE2D1F4FDFC50051A2B7 /* Build configuration list for PBXProject "SandboxBrowserExample" */ = { 330 | isa = XCConfigurationList; 331 | buildConfigurations = ( 332 | BF8EFE421F4FDFC50051A2B7 /* Debug */, 333 | BF8EFE431F4FDFC50051A2B7 /* Release */, 334 | ); 335 | defaultConfigurationIsVisible = 0; 336 | defaultConfigurationName = Release; 337 | }; 338 | BF8EFE441F4FDFC50051A2B7 /* Build configuration list for PBXNativeTarget "SandboxBrowserExample" */ = { 339 | isa = XCConfigurationList; 340 | buildConfigurations = ( 341 | BF8EFE451F4FDFC50051A2B7 /* Debug */, 342 | BF8EFE461F4FDFC50051A2B7 /* Release */, 343 | ); 344 | defaultConfigurationIsVisible = 0; 345 | defaultConfigurationName = Release; 346 | }; 347 | /* End XCConfigurationList section */ 348 | }; 349 | rootObject = BF8EFE2A1F4FDFC50051A2B7 /* Project object */; 350 | } 351 | -------------------------------------------------------------------------------- /SandboxBrowserExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SandboxBrowserExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SandboxBrowserExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // AirSandboxExample 4 | // 5 | // Created by Joe on 2017/8/25. 6 | // Copyright © 2017年 Joe. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | 19 | let testUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last 20 | let plistpath = testUrl?.path.appending("/example.plist") 21 | let pngpath = testUrl?.path.appending("/example.png") 22 | let dbpath = testUrl?.path.appending("/example.sqlite3") 23 | let logpath = testUrl?.path.appending("/example.log") 24 | do { 25 | try "Sandbox Browser".write(toFile: plistpath!, atomically: true, encoding: .utf8) 26 | try "Sandbox Browser".write(toFile: pngpath!, atomically: true, encoding: .utf8) 27 | try "Sandbox Browser".write(toFile: dbpath!, atomically: true, encoding: .utf8) 28 | try "Sandbox Browser".write(toFile: logpath!, atomically: true, encoding: .utf8) 29 | } catch { 30 | print(error.localizedDescription) 31 | } 32 | 33 | DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1, execute: { 34 | self.enableSwipe() 35 | }) 36 | 37 | return true 38 | } 39 | 40 | 41 | public func enableSwipe() { 42 | let pan = UISwipeGestureRecognizer(target: self, action: #selector(onSwipeDetected)) 43 | pan.numberOfTouchesRequired = 1 44 | pan.direction = .left 45 | UIApplication.shared.keyWindow?.addGestureRecognizer(pan) 46 | } 47 | 48 | @objc func onSwipeDetected(){ 49 | 50 | let sandboxBrowser = SandboxBrowser() 51 | sandboxBrowser.didSelectFile = { file, vc in 52 | print(file.name, file.type) 53 | } 54 | window?.rootViewController?.present(sandboxBrowser, animated: true, completion: nil) 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /SandboxBrowserExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "scale" : "1x", 46 | "size" : "1024x1024" 47 | } 48 | ], 49 | "info" : { 50 | "author" : "xcode", 51 | "version" : 1 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /SandboxBrowserExample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SandboxBrowserExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /SandboxBrowserExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /SandboxBrowserExample/SandboxBrowser/Resources/Resources.bundle/directory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aidevjoe/SandboxBrowser/837f0bfce04cea63ea8bf50b4fd01168a50bacb2/SandboxBrowserExample/SandboxBrowser/Resources/Resources.bundle/directory.png -------------------------------------------------------------------------------- /SandboxBrowserExample/SandboxBrowser/Resources/Resources.bundle/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aidevjoe/SandboxBrowser/837f0bfce04cea63ea8bf50b4fd01168a50bacb2/SandboxBrowserExample/SandboxBrowser/Resources/Resources.bundle/file.png -------------------------------------------------------------------------------- /SandboxBrowserExample/SandboxBrowser/Resources/Resources.bundle/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aidevjoe/SandboxBrowser/837f0bfce04cea63ea8bf50b4fd01168a50bacb2/SandboxBrowserExample/SandboxBrowser/Resources/Resources.bundle/image.png -------------------------------------------------------------------------------- /SandboxBrowserExample/SandboxBrowser/Resources/Resources.bundle/log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aidevjoe/SandboxBrowser/837f0bfce04cea63ea8bf50b4fd01168a50bacb2/SandboxBrowserExample/SandboxBrowser/Resources/Resources.bundle/log.png -------------------------------------------------------------------------------- /SandboxBrowserExample/SandboxBrowser/Resources/Resources.bundle/plist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aidevjoe/SandboxBrowser/837f0bfce04cea63ea8bf50b4fd01168a50bacb2/SandboxBrowserExample/SandboxBrowser/Resources/Resources.bundle/plist.png -------------------------------------------------------------------------------- /SandboxBrowserExample/SandboxBrowser/Resources/Resources.bundle/sqlite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aidevjoe/SandboxBrowser/837f0bfce04cea63ea8bf50b4fd01168a50bacb2/SandboxBrowserExample/SandboxBrowser/Resources/Resources.bundle/sqlite.png -------------------------------------------------------------------------------- /SandboxBrowserExample/SandboxBrowser/SandboxBrowser.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SandboxBrowser.swift 3 | // SandboxBrowser 4 | // 5 | // Created by Joe on 2017/8/25. 6 | // Copyright © 2017年 Joe. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | public enum FileType: String { 13 | case directory = "directory" 14 | case gif = "gif" 15 | case jpg = "jpg" 16 | case png = "png" 17 | case jpeg = "jpeg" 18 | case json = "json" 19 | case pdf = "pdf" 20 | case plist = "plist" 21 | case file = "file" 22 | case sqlite = "sqlite" 23 | case log = "log" 24 | 25 | var fileName: String { 26 | switch self { 27 | case .directory: return "directory" 28 | case .jpg, .pdf, .gif, .jpeg: return "image" 29 | case .plist: return "plist" 30 | case .sqlite: return "sqlite" 31 | case .log: return "log" 32 | default: return "file" 33 | } 34 | } 35 | } 36 | 37 | public struct FileItem { 38 | public var name: String 39 | public var path: String 40 | public var type: FileType 41 | 42 | public var modificationDate: Date { 43 | do { 44 | let attr = try FileManager.default.attributesOfItem(atPath: path) 45 | return attr[FileAttributeKey.modificationDate] as? Date ?? Date() 46 | } catch { 47 | print(error) 48 | return Date() 49 | } 50 | } 51 | 52 | var image: UIImage { 53 | let bundle = Bundle(for: FileListViewController.self) 54 | let path = bundle.path(forResource: "Resources", ofType: "bundle") 55 | let resBundle = Bundle(path: path!)! 56 | 57 | return UIImage(contentsOfFile: resBundle.path(forResource: type.fileName, ofType: "png")!)! 58 | } 59 | } 60 | 61 | public class SandboxBrowser: UINavigationController { 62 | 63 | var fileListVC: FileListViewController? 64 | 65 | open var didSelectFile: ((FileItem, FileListViewController) -> ())? { 66 | didSet { 67 | fileListVC?.didSelectFile = didSelectFile 68 | } 69 | } 70 | 71 | public convenience init() { 72 | self.init(initialPath: URL(fileURLWithPath: NSHomeDirectory())) 73 | } 74 | 75 | public convenience init(initialPath: URL) { 76 | let fileListVC = FileListViewController(initialPath: initialPath) 77 | self.init(rootViewController: fileListVC) 78 | self.fileListVC = fileListVC 79 | } 80 | } 81 | 82 | public class FileListViewController: UIViewController { 83 | 84 | private struct Misc { 85 | static let cellIdentifier = "FileCell" 86 | } 87 | 88 | private lazy var tableView: UITableView = { 89 | let view = UITableView(frame: self.view.bounds) 90 | view.backgroundColor = .white 91 | view.delegate = self 92 | view.dataSource = self 93 | view.rowHeight = 52 94 | view.separatorInset = .zero 95 | let longPress = UILongPressGestureRecognizer(target: self, action: #selector(onLongPress(gesture:))) 96 | longPress.minimumPressDuration = 0.5 97 | view.addGestureRecognizer(longPress) 98 | return view 99 | }() 100 | 101 | private var items: [FileItem] = [] { 102 | didSet { 103 | tableView.reloadData() 104 | } 105 | } 106 | 107 | public var didSelectFile: ((FileItem, FileListViewController) -> ())? 108 | private var initialPath: URL? 109 | 110 | public convenience init(initialPath: URL) { 111 | self.init() 112 | 113 | self.initialPath = initialPath 114 | self.title = initialPath.lastPathComponent 115 | } 116 | 117 | override public func viewDidLoad() { 118 | super.viewDidLoad() 119 | 120 | view.backgroundColor = .white 121 | view.addSubview(tableView) 122 | 123 | loadPath(initialPath!.relativePath) 124 | navigationItem.rightBarButtonItem = .init(barButtonSystemItem: .stop, target: self, action: #selector(close)) 125 | } 126 | 127 | @objc private func onLongPress(gesture: UILongPressGestureRecognizer) { 128 | 129 | let point = gesture.location(in: tableView) 130 | guard let indexPath = tableView.indexPathForRow(at: point) else { return } 131 | let item = items[indexPath.row] 132 | if item.type != .directory { shareFile(item.path) } 133 | } 134 | 135 | @objc private func close() { 136 | dismiss(animated: true, completion: nil) 137 | } 138 | 139 | private func loadPath(_ path: String = "") { 140 | 141 | guard let paths = try? FileManager.default.contentsOfDirectory(atPath: path) else { 142 | return 143 | } 144 | 145 | var filelist: [FileItem] = [] 146 | paths 147 | .filter { !$0.hasPrefix(".") } 148 | .forEach { subpath in 149 | var isDir: ObjCBool = ObjCBool(false) 150 | 151 | let fullpath = path.appending("/" + subpath) 152 | FileManager.default.fileExists(atPath: fullpath, isDirectory: &isDir) 153 | 154 | var pathExtension = URL(fileURLWithPath: fullpath).pathExtension.lowercased() 155 | if pathExtension.hasPrefix("sqlite") || pathExtension == "db" { pathExtension = "sqlite" } 156 | 157 | let filetype: FileType = isDir.boolValue ? .directory : FileType(rawValue: pathExtension) ?? .file 158 | let fileItem = FileItem(name: subpath, path: fullpath, type: filetype) 159 | filelist.append(fileItem) 160 | } 161 | items = filelist 162 | } 163 | 164 | private func shareFile(_ filePath: String) { 165 | 166 | let controller = UIActivityViewController( 167 | activityItems: [NSURL(fileURLWithPath: filePath)], 168 | applicationActivities: nil) 169 | 170 | controller.excludedActivityTypes = [ 171 | .postToTwitter, .postToFacebook, .postToTencentWeibo, .postToWeibo, 172 | .postToFlickr, .postToVimeo, .message, .addToReadingList, 173 | .print, .copyToPasteboard, .assignToContact, .saveToCameraRoll, 174 | ] 175 | 176 | if UIDevice.current.userInterfaceIdiom == .pad { 177 | controller.popoverPresentationController?.sourceView = view 178 | controller.popoverPresentationController?.sourceRect = CGRect(x: UIScreen.main.bounds.size.width * 0.5, y: UIScreen.main.bounds.size.height * 0.5, width: 10, height: 10) 179 | } 180 | if (self.presentedViewController == nil) { 181 | // The "if" test prevents "Warning: Attempt to present UIActivityViewController:... 182 | // on which is already presenting" warning messages from occurring. 183 | self.present(controller, animated: true, completion: nil) 184 | } 185 | } 186 | } 187 | 188 | final class FileCell: UITableViewCell { 189 | override func layoutSubviews() { 190 | super.layoutSubviews() 191 | 192 | var imageFrame = imageView!.frame 193 | imageFrame.size.width = 42 194 | imageFrame.size.height = 42 195 | imageView?.frame = imageFrame 196 | imageView?.center.y = contentView.center.y 197 | 198 | var textLabelFrame = textLabel!.frame 199 | textLabelFrame.origin.x = imageFrame.maxX + 10 200 | textLabelFrame.origin.y = textLabelFrame.origin.y - 3 201 | textLabel?.frame = textLabelFrame 202 | 203 | var detailLabelFrame = detailTextLabel!.frame 204 | detailLabelFrame.origin.x = textLabelFrame.origin.x 205 | detailLabelFrame.origin.y = detailLabelFrame.origin.y + 3 206 | detailTextLabel?.frame = detailLabelFrame 207 | } 208 | } 209 | 210 | extension FileListViewController: UITableViewDelegate, UITableViewDataSource { 211 | public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 212 | return items.count 213 | } 214 | 215 | public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 216 | var cell = tableView.dequeueReusableCell(withIdentifier: Misc.cellIdentifier) 217 | if cell == nil { cell = FileCell(style: .subtitle, reuseIdentifier: Misc.cellIdentifier) } 218 | 219 | let item = items[indexPath.row] 220 | cell?.textLabel?.text = item.name 221 | cell?.imageView?.image = item.image 222 | cell?.detailTextLabel?.text = DateFormatter.localizedString(from: item.modificationDate, 223 | dateStyle: .medium, 224 | timeStyle: .medium) 225 | if #available(iOS 13.0, *) { 226 | cell?.detailTextLabel?.textColor = .secondaryLabel 227 | } else { 228 | cell?.detailTextLabel?.textColor = .systemGray 229 | } 230 | cell?.accessoryType = item.type == .directory ? .disclosureIndicator : .none 231 | return cell! 232 | } 233 | 234 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 235 | guard indexPath.row < items.count else { return } 236 | 237 | tableView.deselectRow(at: indexPath, animated: true) 238 | 239 | let item = items[indexPath.row] 240 | 241 | switch item.type { 242 | case .directory: 243 | let sandbox = FileListViewController(initialPath: URL(fileURLWithPath: item.path)) 244 | sandbox.didSelectFile = didSelectFile 245 | self.navigationController?.pushViewController(sandbox, animated: true) 246 | default: 247 | didSelectFile?(item, self) 248 | } 249 | } 250 | } 251 | -------------------------------------------------------------------------------- /SandboxBrowserExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // AirSandboxExample 4 | // 5 | // Created by danxiao on 2017/8/25. 6 | // Copyright © 2017年 Joe. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | override func viewDidLoad() { 13 | super.viewDidLoad() 14 | // Do any additional setup after loading the view, typically from a nib. 15 | definesPresentationContext = true 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Screenshot/SimulatorScreenShot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aidevjoe/SandboxBrowser/837f0bfce04cea63ea8bf50b4fd01168a50bacb2/Screenshot/SimulatorScreenShot1.png -------------------------------------------------------------------------------- /Screenshot/SimulatorScreenShot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aidevjoe/SandboxBrowser/837f0bfce04cea63ea8bf50b4fd01168a50bacb2/Screenshot/SimulatorScreenShot2.png -------------------------------------------------------------------------------- /Screenshot/SimulatorScreenShot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aidevjoe/SandboxBrowser/837f0bfce04cea63ea8bf50b4fd01168a50bacb2/Screenshot/SimulatorScreenShot3.png --------------------------------------------------------------------------------