├── .DS_Store ├── README.md ├── readme └── demo.gif ├── rubberband.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── joekennedy.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── joekennedy.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── rubberband ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── ContentView.swift ├── Info.plist ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json ├── RubberDrag.swift └── rubberbandApp.swift ├── rubberbandTests ├── Info.plist └── rubberbandTests.swift └── rubberbandUITests ├── Info.plist └── rubberbandUITests.swift /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joekndy/RubberDrag/8b5b6c9da46da74320a6591a25522f7aebd98f17/.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RubberDrag 2 | 3 | A gesture that enables dragging on a view with a "rubberband" effect. Similar to Apple's native scrollview or half sheet interaction. 4 | 5 | ![RubberDrag Demo](readme/demo.gif) 6 | 7 | ## Usage 8 | Download RubberDrag.swift and drop it into your project. 9 | 10 | ```swift 11 | import SwiftUI 12 | 13 | struct ContentView: View { 14 | var body: some View { 15 | Circle() 16 | .rubberDrag(dragLimit: 100) 17 | } 18 | } 19 | ``` 20 | You can optionally disable horizontal or vertical dragging 21 | 22 | ```swift 23 | import SwiftUI 24 | 25 | struct ContentView: View { 26 | var body: some View { 27 | Circle() 28 | .rubberDrag(dragLimit: 100, horizontalEnabled: false, verticalEnabled: true) 29 | } 30 | } 31 | ``` 32 | 33 | ## License 34 | 35 | You can use this software under the terms and conditions of the MIT License. 36 | 37 | Joe Kennedy © 2021 38 | -------------------------------------------------------------------------------- /readme/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joekndy/RubberDrag/8b5b6c9da46da74320a6591a25522f7aebd98f17/readme/demo.gif -------------------------------------------------------------------------------- /rubberband.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E4EA349A25DC922500449A03 /* rubberbandApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4EA349925DC922500449A03 /* rubberbandApp.swift */; }; 11 | E4EA349C25DC922500449A03 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4EA349B25DC922500449A03 /* ContentView.swift */; }; 12 | E4EA349E25DC922A00449A03 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E4EA349D25DC922A00449A03 /* Assets.xcassets */; }; 13 | E4EA34A125DC922A00449A03 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E4EA34A025DC922A00449A03 /* Preview Assets.xcassets */; }; 14 | E4EA34AC25DC922A00449A03 /* rubberbandTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4EA34AB25DC922A00449A03 /* rubberbandTests.swift */; }; 15 | E4EA34B725DC922A00449A03 /* rubberbandUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4EA34B625DC922A00449A03 /* rubberbandUITests.swift */; }; 16 | E4EA34CB25DDADAB00449A03 /* RubberDrag.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4EA34CA25DDADAB00449A03 /* RubberDrag.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | E4EA34A825DC922A00449A03 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = E4EA348E25DC922500449A03 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = E4EA349525DC922500449A03; 25 | remoteInfo = rubberband; 26 | }; 27 | E4EA34B325DC922A00449A03 /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = E4EA348E25DC922500449A03 /* Project object */; 30 | proxyType = 1; 31 | remoteGlobalIDString = E4EA349525DC922500449A03; 32 | remoteInfo = rubberband; 33 | }; 34 | /* End PBXContainerItemProxy section */ 35 | 36 | /* Begin PBXFileReference section */ 37 | E4EA349625DC922500449A03 /* rubberband.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = rubberband.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | E4EA349925DC922500449A03 /* rubberbandApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = rubberbandApp.swift; sourceTree = ""; }; 39 | E4EA349B25DC922500449A03 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 40 | E4EA349D25DC922A00449A03 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 41 | E4EA34A025DC922A00449A03 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 42 | E4EA34A225DC922A00449A03 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | E4EA34A725DC922A00449A03 /* rubberbandTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = rubberbandTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | E4EA34AB25DC922A00449A03 /* rubberbandTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = rubberbandTests.swift; sourceTree = ""; }; 45 | E4EA34AD25DC922A00449A03 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | E4EA34B225DC922A00449A03 /* rubberbandUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = rubberbandUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | E4EA34B625DC922A00449A03 /* rubberbandUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = rubberbandUITests.swift; sourceTree = ""; }; 48 | E4EA34B825DC922A00449A03 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | E4EA34CA25DDADAB00449A03 /* RubberDrag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RubberDrag.swift; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | E4EA349325DC922500449A03 /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | E4EA34A425DC922A00449A03 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | E4EA34AF25DC922A00449A03 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | /* End PBXFrameworksBuildPhase section */ 75 | 76 | /* Begin PBXGroup section */ 77 | E4EA348D25DC922500449A03 = { 78 | isa = PBXGroup; 79 | children = ( 80 | E4EA349825DC922500449A03 /* rubberband */, 81 | E4EA34AA25DC922A00449A03 /* rubberbandTests */, 82 | E4EA34B525DC922A00449A03 /* rubberbandUITests */, 83 | E4EA349725DC922500449A03 /* Products */, 84 | ); 85 | sourceTree = ""; 86 | }; 87 | E4EA349725DC922500449A03 /* Products */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | E4EA349625DC922500449A03 /* rubberband.app */, 91 | E4EA34A725DC922A00449A03 /* rubberbandTests.xctest */, 92 | E4EA34B225DC922A00449A03 /* rubberbandUITests.xctest */, 93 | ); 94 | name = Products; 95 | sourceTree = ""; 96 | }; 97 | E4EA349825DC922500449A03 /* rubberband */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | E4EA349925DC922500449A03 /* rubberbandApp.swift */, 101 | E4EA349B25DC922500449A03 /* ContentView.swift */, 102 | E4EA34CA25DDADAB00449A03 /* RubberDrag.swift */, 103 | E4EA349D25DC922A00449A03 /* Assets.xcassets */, 104 | E4EA34A225DC922A00449A03 /* Info.plist */, 105 | E4EA349F25DC922A00449A03 /* Preview Content */, 106 | ); 107 | path = rubberband; 108 | sourceTree = ""; 109 | }; 110 | E4EA349F25DC922A00449A03 /* Preview Content */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | E4EA34A025DC922A00449A03 /* Preview Assets.xcassets */, 114 | ); 115 | path = "Preview Content"; 116 | sourceTree = ""; 117 | }; 118 | E4EA34AA25DC922A00449A03 /* rubberbandTests */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | E4EA34AB25DC922A00449A03 /* rubberbandTests.swift */, 122 | E4EA34AD25DC922A00449A03 /* Info.plist */, 123 | ); 124 | path = rubberbandTests; 125 | sourceTree = ""; 126 | }; 127 | E4EA34B525DC922A00449A03 /* rubberbandUITests */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | E4EA34B625DC922A00449A03 /* rubberbandUITests.swift */, 131 | E4EA34B825DC922A00449A03 /* Info.plist */, 132 | ); 133 | path = rubberbandUITests; 134 | sourceTree = ""; 135 | }; 136 | /* End PBXGroup section */ 137 | 138 | /* Begin PBXNativeTarget section */ 139 | E4EA349525DC922500449A03 /* rubberband */ = { 140 | isa = PBXNativeTarget; 141 | buildConfigurationList = E4EA34BB25DC922A00449A03 /* Build configuration list for PBXNativeTarget "rubberband" */; 142 | buildPhases = ( 143 | E4EA349225DC922500449A03 /* Sources */, 144 | E4EA349325DC922500449A03 /* Frameworks */, 145 | E4EA349425DC922500449A03 /* Resources */, 146 | ); 147 | buildRules = ( 148 | ); 149 | dependencies = ( 150 | ); 151 | name = rubberband; 152 | productName = rubberband; 153 | productReference = E4EA349625DC922500449A03 /* rubberband.app */; 154 | productType = "com.apple.product-type.application"; 155 | }; 156 | E4EA34A625DC922A00449A03 /* rubberbandTests */ = { 157 | isa = PBXNativeTarget; 158 | buildConfigurationList = E4EA34BE25DC922A00449A03 /* Build configuration list for PBXNativeTarget "rubberbandTests" */; 159 | buildPhases = ( 160 | E4EA34A325DC922A00449A03 /* Sources */, 161 | E4EA34A425DC922A00449A03 /* Frameworks */, 162 | E4EA34A525DC922A00449A03 /* Resources */, 163 | ); 164 | buildRules = ( 165 | ); 166 | dependencies = ( 167 | E4EA34A925DC922A00449A03 /* PBXTargetDependency */, 168 | ); 169 | name = rubberbandTests; 170 | productName = rubberbandTests; 171 | productReference = E4EA34A725DC922A00449A03 /* rubberbandTests.xctest */; 172 | productType = "com.apple.product-type.bundle.unit-test"; 173 | }; 174 | E4EA34B125DC922A00449A03 /* rubberbandUITests */ = { 175 | isa = PBXNativeTarget; 176 | buildConfigurationList = E4EA34C125DC922A00449A03 /* Build configuration list for PBXNativeTarget "rubberbandUITests" */; 177 | buildPhases = ( 178 | E4EA34AE25DC922A00449A03 /* Sources */, 179 | E4EA34AF25DC922A00449A03 /* Frameworks */, 180 | E4EA34B025DC922A00449A03 /* Resources */, 181 | ); 182 | buildRules = ( 183 | ); 184 | dependencies = ( 185 | E4EA34B425DC922A00449A03 /* PBXTargetDependency */, 186 | ); 187 | name = rubberbandUITests; 188 | productName = rubberbandUITests; 189 | productReference = E4EA34B225DC922A00449A03 /* rubberbandUITests.xctest */; 190 | productType = "com.apple.product-type.bundle.ui-testing"; 191 | }; 192 | /* End PBXNativeTarget section */ 193 | 194 | /* Begin PBXProject section */ 195 | E4EA348E25DC922500449A03 /* Project object */ = { 196 | isa = PBXProject; 197 | attributes = { 198 | LastSwiftUpdateCheck = 1240; 199 | LastUpgradeCheck = 1240; 200 | TargetAttributes = { 201 | E4EA349525DC922500449A03 = { 202 | CreatedOnToolsVersion = 12.4; 203 | }; 204 | E4EA34A625DC922A00449A03 = { 205 | CreatedOnToolsVersion = 12.4; 206 | TestTargetID = E4EA349525DC922500449A03; 207 | }; 208 | E4EA34B125DC922A00449A03 = { 209 | CreatedOnToolsVersion = 12.4; 210 | TestTargetID = E4EA349525DC922500449A03; 211 | }; 212 | }; 213 | }; 214 | buildConfigurationList = E4EA349125DC922500449A03 /* Build configuration list for PBXProject "rubberband" */; 215 | compatibilityVersion = "Xcode 9.3"; 216 | developmentRegion = en; 217 | hasScannedForEncodings = 0; 218 | knownRegions = ( 219 | en, 220 | Base, 221 | ); 222 | mainGroup = E4EA348D25DC922500449A03; 223 | productRefGroup = E4EA349725DC922500449A03 /* Products */; 224 | projectDirPath = ""; 225 | projectRoot = ""; 226 | targets = ( 227 | E4EA349525DC922500449A03 /* rubberband */, 228 | E4EA34A625DC922A00449A03 /* rubberbandTests */, 229 | E4EA34B125DC922A00449A03 /* rubberbandUITests */, 230 | ); 231 | }; 232 | /* End PBXProject section */ 233 | 234 | /* Begin PBXResourcesBuildPhase section */ 235 | E4EA349425DC922500449A03 /* Resources */ = { 236 | isa = PBXResourcesBuildPhase; 237 | buildActionMask = 2147483647; 238 | files = ( 239 | E4EA34A125DC922A00449A03 /* Preview Assets.xcassets in Resources */, 240 | E4EA349E25DC922A00449A03 /* Assets.xcassets in Resources */, 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | }; 244 | E4EA34A525DC922A00449A03 /* Resources */ = { 245 | isa = PBXResourcesBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | E4EA34B025DC922A00449A03 /* Resources */ = { 252 | isa = PBXResourcesBuildPhase; 253 | buildActionMask = 2147483647; 254 | files = ( 255 | ); 256 | runOnlyForDeploymentPostprocessing = 0; 257 | }; 258 | /* End PBXResourcesBuildPhase section */ 259 | 260 | /* Begin PBXSourcesBuildPhase section */ 261 | E4EA349225DC922500449A03 /* Sources */ = { 262 | isa = PBXSourcesBuildPhase; 263 | buildActionMask = 2147483647; 264 | files = ( 265 | E4EA34CB25DDADAB00449A03 /* RubberDrag.swift in Sources */, 266 | E4EA349C25DC922500449A03 /* ContentView.swift in Sources */, 267 | E4EA349A25DC922500449A03 /* rubberbandApp.swift in Sources */, 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | E4EA34A325DC922A00449A03 /* Sources */ = { 272 | isa = PBXSourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | E4EA34AC25DC922A00449A03 /* rubberbandTests.swift in Sources */, 276 | ); 277 | runOnlyForDeploymentPostprocessing = 0; 278 | }; 279 | E4EA34AE25DC922A00449A03 /* Sources */ = { 280 | isa = PBXSourcesBuildPhase; 281 | buildActionMask = 2147483647; 282 | files = ( 283 | E4EA34B725DC922A00449A03 /* rubberbandUITests.swift in Sources */, 284 | ); 285 | runOnlyForDeploymentPostprocessing = 0; 286 | }; 287 | /* End PBXSourcesBuildPhase section */ 288 | 289 | /* Begin PBXTargetDependency section */ 290 | E4EA34A925DC922A00449A03 /* PBXTargetDependency */ = { 291 | isa = PBXTargetDependency; 292 | target = E4EA349525DC922500449A03 /* rubberband */; 293 | targetProxy = E4EA34A825DC922A00449A03 /* PBXContainerItemProxy */; 294 | }; 295 | E4EA34B425DC922A00449A03 /* PBXTargetDependency */ = { 296 | isa = PBXTargetDependency; 297 | target = E4EA349525DC922500449A03 /* rubberband */; 298 | targetProxy = E4EA34B325DC922A00449A03 /* PBXContainerItemProxy */; 299 | }; 300 | /* End PBXTargetDependency section */ 301 | 302 | /* Begin XCBuildConfiguration section */ 303 | E4EA34B925DC922A00449A03 /* Debug */ = { 304 | isa = XCBuildConfiguration; 305 | buildSettings = { 306 | ALWAYS_SEARCH_USER_PATHS = NO; 307 | CLANG_ANALYZER_NONNULL = YES; 308 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 309 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 310 | CLANG_CXX_LIBRARY = "libc++"; 311 | CLANG_ENABLE_MODULES = YES; 312 | CLANG_ENABLE_OBJC_ARC = YES; 313 | CLANG_ENABLE_OBJC_WEAK = YES; 314 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 315 | CLANG_WARN_BOOL_CONVERSION = YES; 316 | CLANG_WARN_COMMA = YES; 317 | CLANG_WARN_CONSTANT_CONVERSION = YES; 318 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 319 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 320 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 321 | CLANG_WARN_EMPTY_BODY = YES; 322 | CLANG_WARN_ENUM_CONVERSION = YES; 323 | CLANG_WARN_INFINITE_RECURSION = YES; 324 | CLANG_WARN_INT_CONVERSION = YES; 325 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 326 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 327 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 328 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 329 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 330 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 331 | CLANG_WARN_STRICT_PROTOTYPES = YES; 332 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 333 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 334 | CLANG_WARN_UNREACHABLE_CODE = YES; 335 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 336 | COPY_PHASE_STRIP = NO; 337 | DEBUG_INFORMATION_FORMAT = dwarf; 338 | ENABLE_STRICT_OBJC_MSGSEND = YES; 339 | ENABLE_TESTABILITY = YES; 340 | GCC_C_LANGUAGE_STANDARD = gnu11; 341 | GCC_DYNAMIC_NO_PIC = NO; 342 | GCC_NO_COMMON_BLOCKS = YES; 343 | GCC_OPTIMIZATION_LEVEL = 0; 344 | GCC_PREPROCESSOR_DEFINITIONS = ( 345 | "DEBUG=1", 346 | "$(inherited)", 347 | ); 348 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 349 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 350 | GCC_WARN_UNDECLARED_SELECTOR = YES; 351 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 352 | GCC_WARN_UNUSED_FUNCTION = YES; 353 | GCC_WARN_UNUSED_VARIABLE = YES; 354 | IPHONEOS_DEPLOYMENT_TARGET = 14.4; 355 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 356 | MTL_FAST_MATH = YES; 357 | ONLY_ACTIVE_ARCH = YES; 358 | SDKROOT = iphoneos; 359 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 360 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 361 | }; 362 | name = Debug; 363 | }; 364 | E4EA34BA25DC922A00449A03 /* Release */ = { 365 | isa = XCBuildConfiguration; 366 | buildSettings = { 367 | ALWAYS_SEARCH_USER_PATHS = NO; 368 | CLANG_ANALYZER_NONNULL = YES; 369 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 370 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 371 | CLANG_CXX_LIBRARY = "libc++"; 372 | CLANG_ENABLE_MODULES = YES; 373 | CLANG_ENABLE_OBJC_ARC = YES; 374 | CLANG_ENABLE_OBJC_WEAK = YES; 375 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 376 | CLANG_WARN_BOOL_CONVERSION = YES; 377 | CLANG_WARN_COMMA = YES; 378 | CLANG_WARN_CONSTANT_CONVERSION = YES; 379 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 380 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 381 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 382 | CLANG_WARN_EMPTY_BODY = YES; 383 | CLANG_WARN_ENUM_CONVERSION = YES; 384 | CLANG_WARN_INFINITE_RECURSION = YES; 385 | CLANG_WARN_INT_CONVERSION = YES; 386 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 387 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 388 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 389 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 390 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 391 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 392 | CLANG_WARN_STRICT_PROTOTYPES = YES; 393 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 394 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 395 | CLANG_WARN_UNREACHABLE_CODE = YES; 396 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 397 | COPY_PHASE_STRIP = NO; 398 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 399 | ENABLE_NS_ASSERTIONS = NO; 400 | ENABLE_STRICT_OBJC_MSGSEND = YES; 401 | GCC_C_LANGUAGE_STANDARD = gnu11; 402 | GCC_NO_COMMON_BLOCKS = YES; 403 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 404 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 405 | GCC_WARN_UNDECLARED_SELECTOR = YES; 406 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 407 | GCC_WARN_UNUSED_FUNCTION = YES; 408 | GCC_WARN_UNUSED_VARIABLE = YES; 409 | IPHONEOS_DEPLOYMENT_TARGET = 14.4; 410 | MTL_ENABLE_DEBUG_INFO = NO; 411 | MTL_FAST_MATH = YES; 412 | SDKROOT = iphoneos; 413 | SWIFT_COMPILATION_MODE = wholemodule; 414 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 415 | VALIDATE_PRODUCT = YES; 416 | }; 417 | name = Release; 418 | }; 419 | E4EA34BC25DC922A00449A03 /* Debug */ = { 420 | isa = XCBuildConfiguration; 421 | buildSettings = { 422 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 423 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 424 | CODE_SIGN_STYLE = Automatic; 425 | DEVELOPMENT_ASSET_PATHS = "\"rubberband/Preview Content\""; 426 | DEVELOPMENT_TEAM = ALZ7L55592; 427 | ENABLE_PREVIEWS = YES; 428 | INFOPLIST_FILE = rubberband/Info.plist; 429 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 430 | LD_RUNPATH_SEARCH_PATHS = ( 431 | "$(inherited)", 432 | "@executable_path/Frameworks", 433 | ); 434 | PRODUCT_BUNDLE_IDENTIFIER = com.joekndy.rubberband; 435 | PRODUCT_NAME = "$(TARGET_NAME)"; 436 | SWIFT_VERSION = 5.0; 437 | TARGETED_DEVICE_FAMILY = "1,2"; 438 | }; 439 | name = Debug; 440 | }; 441 | E4EA34BD25DC922A00449A03 /* Release */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 445 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 446 | CODE_SIGN_STYLE = Automatic; 447 | DEVELOPMENT_ASSET_PATHS = "\"rubberband/Preview Content\""; 448 | DEVELOPMENT_TEAM = ALZ7L55592; 449 | ENABLE_PREVIEWS = YES; 450 | INFOPLIST_FILE = rubberband/Info.plist; 451 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 452 | LD_RUNPATH_SEARCH_PATHS = ( 453 | "$(inherited)", 454 | "@executable_path/Frameworks", 455 | ); 456 | PRODUCT_BUNDLE_IDENTIFIER = com.joekndy.rubberband; 457 | PRODUCT_NAME = "$(TARGET_NAME)"; 458 | SWIFT_VERSION = 5.0; 459 | TARGETED_DEVICE_FAMILY = "1,2"; 460 | }; 461 | name = Release; 462 | }; 463 | E4EA34BF25DC922A00449A03 /* Debug */ = { 464 | isa = XCBuildConfiguration; 465 | buildSettings = { 466 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 467 | BUNDLE_LOADER = "$(TEST_HOST)"; 468 | CODE_SIGN_STYLE = Automatic; 469 | INFOPLIST_FILE = rubberbandTests/Info.plist; 470 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 471 | LD_RUNPATH_SEARCH_PATHS = ( 472 | "$(inherited)", 473 | "@executable_path/Frameworks", 474 | "@loader_path/Frameworks", 475 | ); 476 | PRODUCT_BUNDLE_IDENTIFIER = com.joekndy.rubberbandTests; 477 | PRODUCT_NAME = "$(TARGET_NAME)"; 478 | SWIFT_VERSION = 5.0; 479 | TARGETED_DEVICE_FAMILY = "1,2"; 480 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/rubberband.app/rubberband"; 481 | }; 482 | name = Debug; 483 | }; 484 | E4EA34C025DC922A00449A03 /* Release */ = { 485 | isa = XCBuildConfiguration; 486 | buildSettings = { 487 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 488 | BUNDLE_LOADER = "$(TEST_HOST)"; 489 | CODE_SIGN_STYLE = Automatic; 490 | INFOPLIST_FILE = rubberbandTests/Info.plist; 491 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 492 | LD_RUNPATH_SEARCH_PATHS = ( 493 | "$(inherited)", 494 | "@executable_path/Frameworks", 495 | "@loader_path/Frameworks", 496 | ); 497 | PRODUCT_BUNDLE_IDENTIFIER = com.joekndy.rubberbandTests; 498 | PRODUCT_NAME = "$(TARGET_NAME)"; 499 | SWIFT_VERSION = 5.0; 500 | TARGETED_DEVICE_FAMILY = "1,2"; 501 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/rubberband.app/rubberband"; 502 | }; 503 | name = Release; 504 | }; 505 | E4EA34C225DC922A00449A03 /* Debug */ = { 506 | isa = XCBuildConfiguration; 507 | buildSettings = { 508 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 509 | CODE_SIGN_STYLE = Automatic; 510 | INFOPLIST_FILE = rubberbandUITests/Info.plist; 511 | LD_RUNPATH_SEARCH_PATHS = ( 512 | "$(inherited)", 513 | "@executable_path/Frameworks", 514 | "@loader_path/Frameworks", 515 | ); 516 | PRODUCT_BUNDLE_IDENTIFIER = com.joekndy.rubberbandUITests; 517 | PRODUCT_NAME = "$(TARGET_NAME)"; 518 | SWIFT_VERSION = 5.0; 519 | TARGETED_DEVICE_FAMILY = "1,2"; 520 | TEST_TARGET_NAME = rubberband; 521 | }; 522 | name = Debug; 523 | }; 524 | E4EA34C325DC922A00449A03 /* Release */ = { 525 | isa = XCBuildConfiguration; 526 | buildSettings = { 527 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 528 | CODE_SIGN_STYLE = Automatic; 529 | INFOPLIST_FILE = rubberbandUITests/Info.plist; 530 | LD_RUNPATH_SEARCH_PATHS = ( 531 | "$(inherited)", 532 | "@executable_path/Frameworks", 533 | "@loader_path/Frameworks", 534 | ); 535 | PRODUCT_BUNDLE_IDENTIFIER = com.joekndy.rubberbandUITests; 536 | PRODUCT_NAME = "$(TARGET_NAME)"; 537 | SWIFT_VERSION = 5.0; 538 | TARGETED_DEVICE_FAMILY = "1,2"; 539 | TEST_TARGET_NAME = rubberband; 540 | }; 541 | name = Release; 542 | }; 543 | /* End XCBuildConfiguration section */ 544 | 545 | /* Begin XCConfigurationList section */ 546 | E4EA349125DC922500449A03 /* Build configuration list for PBXProject "rubberband" */ = { 547 | isa = XCConfigurationList; 548 | buildConfigurations = ( 549 | E4EA34B925DC922A00449A03 /* Debug */, 550 | E4EA34BA25DC922A00449A03 /* Release */, 551 | ); 552 | defaultConfigurationIsVisible = 0; 553 | defaultConfigurationName = Release; 554 | }; 555 | E4EA34BB25DC922A00449A03 /* Build configuration list for PBXNativeTarget "rubberband" */ = { 556 | isa = XCConfigurationList; 557 | buildConfigurations = ( 558 | E4EA34BC25DC922A00449A03 /* Debug */, 559 | E4EA34BD25DC922A00449A03 /* Release */, 560 | ); 561 | defaultConfigurationIsVisible = 0; 562 | defaultConfigurationName = Release; 563 | }; 564 | E4EA34BE25DC922A00449A03 /* Build configuration list for PBXNativeTarget "rubberbandTests" */ = { 565 | isa = XCConfigurationList; 566 | buildConfigurations = ( 567 | E4EA34BF25DC922A00449A03 /* Debug */, 568 | E4EA34C025DC922A00449A03 /* Release */, 569 | ); 570 | defaultConfigurationIsVisible = 0; 571 | defaultConfigurationName = Release; 572 | }; 573 | E4EA34C125DC922A00449A03 /* Build configuration list for PBXNativeTarget "rubberbandUITests" */ = { 574 | isa = XCConfigurationList; 575 | buildConfigurations = ( 576 | E4EA34C225DC922A00449A03 /* Debug */, 577 | E4EA34C325DC922A00449A03 /* Release */, 578 | ); 579 | defaultConfigurationIsVisible = 0; 580 | defaultConfigurationName = Release; 581 | }; 582 | /* End XCConfigurationList section */ 583 | }; 584 | rootObject = E4EA348E25DC922500449A03 /* Project object */; 585 | } 586 | -------------------------------------------------------------------------------- /rubberband.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /rubberband.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /rubberband.xcodeproj/project.xcworkspace/xcuserdata/joekennedy.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joekndy/RubberDrag/8b5b6c9da46da74320a6591a25522f7aebd98f17/rubberband.xcodeproj/project.xcworkspace/xcuserdata/joekennedy.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /rubberband.xcodeproj/xcuserdata/joekennedy.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | rubberband.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /rubberband/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /rubberband/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" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /rubberband/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /rubberband/ContentView.swift: -------------------------------------------------------------------------------- 1 | 2 | import SwiftUI 3 | 4 | struct ContentView: View { 5 | 6 | var body: some View { 7 | ZStack { 8 | Rectangle() 9 | .frame(width: 180, height: 180) 10 | .foregroundColor(.red) 11 | .opacity(0.15) 12 | Circle() 13 | .frame(width: 60, height: 60) 14 | .foregroundColor(.gray) 15 | .rubberDrag(dragLimit: 60) 16 | } 17 | } 18 | } 19 | 20 | struct ContentView_Previews: PreviewProvider { 21 | static var previews: some View { 22 | ContentView() 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /rubberband/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | 28 | UIApplicationSupportsIndirectInputEvents 29 | 30 | UILaunchScreen 31 | 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | UIInterfaceOrientationPortrait 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /rubberband/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /rubberband/RubberDrag.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | private struct RubberDrag: ViewModifier { 4 | @State private var yTranslation: CGFloat = .zero 5 | @State private var xTranslation: CGFloat = .zero 6 | 7 | @State private var isDown = false 8 | 9 | @State var dragLimit: CGFloat 10 | 11 | @State var horizontalEnabled = true 12 | @State var verticalEnabled = true 13 | 14 | func body(content: Content) -> some View { 15 | content 16 | .offset(x: xTranslation, y: yTranslation) 17 | .gesture( 18 | DragGesture() 19 | .onChanged({ value in 20 | if verticalEnabled { 21 | if value.translation.height >= dragLimit { 22 | yTranslation = dragLimit * (1.00 + log10(value.translation.height / dragLimit)) 23 | } else if value.translation.height <= (dragLimit * -1) { 24 | yTranslation = (dragLimit * -1) * (1.00 + log10(value.translation.height / (dragLimit * -1))) 25 | } else { 26 | yTranslation = value.translation.height 27 | } 28 | } 29 | 30 | if horizontalEnabled { 31 | if value.translation.width >= dragLimit { 32 | xTranslation = dragLimit * (1.00 + log10(value.translation.width / dragLimit)) 33 | } else if value.translation.width <= (dragLimit * -1) { 34 | xTranslation = (dragLimit * -1) * (1.00 + log10(value.translation.width / (dragLimit * -1))) 35 | } else { 36 | xTranslation = value.translation.width 37 | } 38 | } 39 | 40 | isDown = true 41 | 42 | }) 43 | .onEnded({ value in 44 | isDown = false 45 | yTranslation = .zero 46 | xTranslation = .zero 47 | }) 48 | ) 49 | .animation(isDown ? .none : .interpolatingSpring(stiffness: 140, damping: 20)) 50 | } 51 | } 52 | 53 | extension View { 54 | func rubberDrag(dragLimit: CGFloat, horizontalEnabled: Bool = true, verticalEnabled: Bool = true) -> some View { 55 | ModifiedContent( 56 | content: self, 57 | modifier: RubberDrag(dragLimit: dragLimit, horizontalEnabled: horizontalEnabled, verticalEnabled: verticalEnabled) 58 | ) 59 | } 60 | } 61 | 62 | 63 | -------------------------------------------------------------------------------- /rubberband/rubberbandApp.swift: -------------------------------------------------------------------------------- 1 | 2 | import SwiftUI 3 | 4 | @main 5 | struct rubberbandApp: App { 6 | var body: some Scene { 7 | WindowGroup { 8 | ContentView() 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /rubberbandTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /rubberbandTests/rubberbandTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // rubberbandTests.swift 3 | // rubberbandTests 4 | // 5 | // Created by Joe Kennedy on 2/16/21. 6 | // 7 | 8 | import XCTest 9 | @testable import rubberband 10 | 11 | class rubberbandTests: XCTestCase { 12 | 13 | override func setUpWithError() throws { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | } 16 | 17 | override func tearDownWithError() throws { 18 | // Put teardown code here. This method is called after the invocation of each test method in the class. 19 | } 20 | 21 | func testExample() throws { 22 | // This is an example of a functional test case. 23 | // Use XCTAssert and related functions to verify your tests produce the correct results. 24 | } 25 | 26 | func testPerformanceExample() throws { 27 | // This is an example of a performance test case. 28 | self.measure { 29 | // Put the code you want to measure the time of here. 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /rubberbandUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /rubberbandUITests/rubberbandUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // rubberbandUITests.swift 3 | // rubberbandUITests 4 | // 5 | // Created by Joe Kennedy on 2/16/21. 6 | // 7 | 8 | import XCTest 9 | 10 | class rubberbandUITests: XCTestCase { 11 | 12 | override func setUpWithError() throws { 13 | // Put setup code here. This method is called before the invocation of each test method in the class. 14 | 15 | // In UI tests it is usually best to stop immediately when a failure occurs. 16 | continueAfterFailure = false 17 | 18 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 19 | } 20 | 21 | override func tearDownWithError() throws { 22 | // Put teardown code here. This method is called after the invocation of each test method in the class. 23 | } 24 | 25 | func testExample() throws { 26 | // UI tests must launch the application that they test. 27 | let app = XCUIApplication() 28 | app.launch() 29 | 30 | // Use recording to get started writing UI tests. 31 | // Use XCTAssert and related functions to verify your tests produce the correct results. 32 | } 33 | 34 | func testLaunchPerformance() throws { 35 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) { 36 | // This measures how long it takes to launch your application. 37 | measure(metrics: [XCTApplicationLaunchMetric()]) { 38 | XCUIApplication().launch() 39 | } 40 | } 41 | } 42 | } 43 | --------------------------------------------------------------------------------