├── .gitignore ├── CleanClosure.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── CleanClosure ├── CleanClosure.entitlements ├── Info.plist ├── SourceEditorCommand.swift └── SourceEditorExtension.swift ├── Demo ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ └── Main.storyboard ├── Info.plist └── ViewController.swift ├── LICENSE ├── README.md └── demo.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | -------------------------------------------------------------------------------- /CleanClosure.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | AE9BC40E1D15E0BB00392254 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE9BC40D1D15E0BB00392254 /* AppDelegate.swift */; }; 11 | AE9BC4101D15E0BB00392254 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE9BC40F1D15E0BB00392254 /* ViewController.swift */; }; 12 | AE9BC4121D15E0BB00392254 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AE9BC4111D15E0BB00392254 /* Assets.xcassets */; }; 13 | AE9BC4151D15E0BB00392254 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AE9BC4131D15E0BB00392254 /* Main.storyboard */; }; 14 | AE9BC4231D15E0D700392254 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AE9BC4221D15E0D700392254 /* Cocoa.framework */; }; 15 | AE9BC4281D15E0D700392254 /* SourceEditorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE9BC4271D15E0D700392254 /* SourceEditorExtension.swift */; }; 16 | AE9BC42A1D15E0D700392254 /* SourceEditorCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE9BC4291D15E0D700392254 /* SourceEditorCommand.swift */; }; 17 | AE9BC42E1D15E0D700392254 /* Clean Closure.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = AE9BC4201D15E0D700392254 /* Clean Closure.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | AE9BC42C1D15E0D700392254 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = AE9BC4021D15E0BB00392254 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = AE9BC41F1D15E0D700392254; 26 | remoteInfo = CleanClosure; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXCopyFilesBuildPhase section */ 31 | AE9BC4321D15E0D700392254 /* Embed App Extensions */ = { 32 | isa = PBXCopyFilesBuildPhase; 33 | buildActionMask = 2147483647; 34 | dstPath = ""; 35 | dstSubfolderSpec = 13; 36 | files = ( 37 | AE9BC42E1D15E0D700392254 /* Clean Closure.appex in Embed App Extensions */, 38 | ); 39 | name = "Embed App Extensions"; 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXCopyFilesBuildPhase section */ 43 | 44 | /* Begin PBXFileReference section */ 45 | AE9BC40A1D15E0BB00392254 /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = Demo.app; path = CleanClosure.app; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | AE9BC40D1D15E0BB00392254 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 47 | AE9BC40F1D15E0BB00392254 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 48 | AE9BC4111D15E0BB00392254 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 49 | AE9BC4141D15E0BB00392254 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 50 | AE9BC4161D15E0BB00392254 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | AE9BC4201D15E0D700392254 /* Clean Closure.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Clean Closure.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | AE9BC4221D15E0D700392254 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 53 | AE9BC4261D15E0D700392254 /* CleanClosure.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = CleanClosure.entitlements; sourceTree = ""; }; 54 | AE9BC4271D15E0D700392254 /* SourceEditorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceEditorExtension.swift; sourceTree = ""; }; 55 | AE9BC4291D15E0D700392254 /* SourceEditorCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceEditorCommand.swift; sourceTree = ""; }; 56 | AE9BC42B1D15E0D700392254 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | AE9BC4071D15E0BB00392254 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | AE9BC41D1D15E0D700392254 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | AE9BC4231D15E0D700392254 /* Cocoa.framework in Frameworks */, 72 | ); 73 | runOnlyForDeploymentPostprocessing = 0; 74 | }; 75 | /* End PBXFrameworksBuildPhase section */ 76 | 77 | /* Begin PBXGroup section */ 78 | AE9BC4011D15E0BB00392254 = { 79 | isa = PBXGroup; 80 | children = ( 81 | AE9BC40C1D15E0BB00392254 /* CleanClosure */, 82 | AE9BC4241D15E0D700392254 /* CleanClosure Extension */, 83 | AE9BC4211D15E0D700392254 /* Frameworks */, 84 | AE9BC40B1D15E0BB00392254 /* Products */, 85 | ); 86 | sourceTree = ""; 87 | }; 88 | AE9BC40B1D15E0BB00392254 /* Products */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | AE9BC40A1D15E0BB00392254 /* Demo.app */, 92 | AE9BC4201D15E0D700392254 /* Clean Closure.appex */, 93 | ); 94 | name = Products; 95 | sourceTree = ""; 96 | }; 97 | AE9BC40C1D15E0BB00392254 /* CleanClosure */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | AE9BC40D1D15E0BB00392254 /* AppDelegate.swift */, 101 | AE9BC40F1D15E0BB00392254 /* ViewController.swift */, 102 | AE9BC4111D15E0BB00392254 /* Assets.xcassets */, 103 | AE9BC4131D15E0BB00392254 /* Main.storyboard */, 104 | AE9BC4161D15E0BB00392254 /* Info.plist */, 105 | ); 106 | name = CleanClosure; 107 | path = Demo; 108 | sourceTree = ""; 109 | }; 110 | AE9BC4211D15E0D700392254 /* Frameworks */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | AE9BC4221D15E0D700392254 /* Cocoa.framework */, 114 | ); 115 | name = Frameworks; 116 | sourceTree = ""; 117 | }; 118 | AE9BC4241D15E0D700392254 /* CleanClosure Extension */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | AE9BC4271D15E0D700392254 /* SourceEditorExtension.swift */, 122 | AE9BC4291D15E0D700392254 /* SourceEditorCommand.swift */, 123 | AE9BC42B1D15E0D700392254 /* Info.plist */, 124 | AE9BC4251D15E0D700392254 /* Supporting Files */, 125 | ); 126 | name = "CleanClosure Extension"; 127 | path = CleanClosure; 128 | sourceTree = ""; 129 | }; 130 | AE9BC4251D15E0D700392254 /* Supporting Files */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | AE9BC4261D15E0D700392254 /* CleanClosure.entitlements */, 134 | ); 135 | name = "Supporting Files"; 136 | sourceTree = ""; 137 | }; 138 | /* End PBXGroup section */ 139 | 140 | /* Begin PBXNativeTarget section */ 141 | AE9BC4091D15E0BB00392254 /* CleanClosure */ = { 142 | isa = PBXNativeTarget; 143 | buildConfigurationList = AE9BC4191D15E0BB00392254 /* Build configuration list for PBXNativeTarget "CleanClosure" */; 144 | buildPhases = ( 145 | AE9BC4061D15E0BB00392254 /* Sources */, 146 | AE9BC4071D15E0BB00392254 /* Frameworks */, 147 | AE9BC4081D15E0BB00392254 /* Resources */, 148 | AE9BC4321D15E0D700392254 /* Embed App Extensions */, 149 | ); 150 | buildRules = ( 151 | ); 152 | dependencies = ( 153 | AE9BC42D1D15E0D700392254 /* PBXTargetDependency */, 154 | ); 155 | name = CleanClosure; 156 | productName = Demo; 157 | productReference = AE9BC40A1D15E0BB00392254 /* Demo.app */; 158 | productType = "com.apple.product-type.application"; 159 | }; 160 | AE9BC41F1D15E0D700392254 /* CleanClosure Extension */ = { 161 | isa = PBXNativeTarget; 162 | buildConfigurationList = AE9BC42F1D15E0D700392254 /* Build configuration list for PBXNativeTarget "CleanClosure Extension" */; 163 | buildPhases = ( 164 | AE9BC41C1D15E0D700392254 /* Sources */, 165 | AE9BC41D1D15E0D700392254 /* Frameworks */, 166 | AE9BC41E1D15E0D700392254 /* Resources */, 167 | ); 168 | buildRules = ( 169 | ); 170 | dependencies = ( 171 | ); 172 | name = "CleanClosure Extension"; 173 | productName = CleanClosure; 174 | productReference = AE9BC4201D15E0D700392254 /* Clean Closure.appex */; 175 | productType = "com.apple.product-type.xcode-extension"; 176 | }; 177 | /* End PBXNativeTarget section */ 178 | 179 | /* Begin PBXProject section */ 180 | AE9BC4021D15E0BB00392254 /* Project object */ = { 181 | isa = PBXProject; 182 | attributes = { 183 | LastSwiftUpdateCheck = 0800; 184 | LastUpgradeCheck = 0800; 185 | ORGANIZATIONNAME = "Patrick Balestra"; 186 | TargetAttributes = { 187 | AE9BC4091D15E0BB00392254 = { 188 | CreatedOnToolsVersion = 8.0; 189 | DevelopmentTeam = 2EZDW5DVTJ; 190 | DevelopmentTeamName = "Patrick Balestra"; 191 | ProvisioningStyle = Automatic; 192 | }; 193 | AE9BC41F1D15E0D700392254 = { 194 | CreatedOnToolsVersion = 8.0; 195 | DevelopmentTeam = 2EZDW5DVTJ; 196 | DevelopmentTeamName = "Patrick Balestra"; 197 | ProvisioningStyle = Automatic; 198 | }; 199 | }; 200 | }; 201 | buildConfigurationList = AE9BC4051D15E0BB00392254 /* Build configuration list for PBXProject "CleanClosure" */; 202 | compatibilityVersion = "Xcode 3.2"; 203 | developmentRegion = English; 204 | hasScannedForEncodings = 0; 205 | knownRegions = ( 206 | en, 207 | Base, 208 | ); 209 | mainGroup = AE9BC4011D15E0BB00392254; 210 | productRefGroup = AE9BC40B1D15E0BB00392254 /* Products */; 211 | projectDirPath = ""; 212 | projectRoot = ""; 213 | targets = ( 214 | AE9BC4091D15E0BB00392254 /* CleanClosure */, 215 | AE9BC41F1D15E0D700392254 /* CleanClosure Extension */, 216 | ); 217 | }; 218 | /* End PBXProject section */ 219 | 220 | /* Begin PBXResourcesBuildPhase section */ 221 | AE9BC4081D15E0BB00392254 /* Resources */ = { 222 | isa = PBXResourcesBuildPhase; 223 | buildActionMask = 2147483647; 224 | files = ( 225 | AE9BC4121D15E0BB00392254 /* Assets.xcassets in Resources */, 226 | AE9BC4151D15E0BB00392254 /* Main.storyboard in Resources */, 227 | ); 228 | runOnlyForDeploymentPostprocessing = 0; 229 | }; 230 | AE9BC41E1D15E0D700392254 /* Resources */ = { 231 | isa = PBXResourcesBuildPhase; 232 | buildActionMask = 2147483647; 233 | files = ( 234 | ); 235 | runOnlyForDeploymentPostprocessing = 0; 236 | }; 237 | /* End PBXResourcesBuildPhase section */ 238 | 239 | /* Begin PBXSourcesBuildPhase section */ 240 | AE9BC4061D15E0BB00392254 /* Sources */ = { 241 | isa = PBXSourcesBuildPhase; 242 | buildActionMask = 2147483647; 243 | files = ( 244 | AE9BC4101D15E0BB00392254 /* ViewController.swift in Sources */, 245 | AE9BC40E1D15E0BB00392254 /* AppDelegate.swift in Sources */, 246 | ); 247 | runOnlyForDeploymentPostprocessing = 0; 248 | }; 249 | AE9BC41C1D15E0D700392254 /* Sources */ = { 250 | isa = PBXSourcesBuildPhase; 251 | buildActionMask = 2147483647; 252 | files = ( 253 | AE9BC4281D15E0D700392254 /* SourceEditorExtension.swift in Sources */, 254 | AE9BC42A1D15E0D700392254 /* SourceEditorCommand.swift in Sources */, 255 | ); 256 | runOnlyForDeploymentPostprocessing = 0; 257 | }; 258 | /* End PBXSourcesBuildPhase section */ 259 | 260 | /* Begin PBXTargetDependency section */ 261 | AE9BC42D1D15E0D700392254 /* PBXTargetDependency */ = { 262 | isa = PBXTargetDependency; 263 | target = AE9BC41F1D15E0D700392254 /* CleanClosure Extension */; 264 | targetProxy = AE9BC42C1D15E0D700392254 /* PBXContainerItemProxy */; 265 | }; 266 | /* End PBXTargetDependency section */ 267 | 268 | /* Begin PBXVariantGroup section */ 269 | AE9BC4131D15E0BB00392254 /* Main.storyboard */ = { 270 | isa = PBXVariantGroup; 271 | children = ( 272 | AE9BC4141D15E0BB00392254 /* Base */, 273 | ); 274 | name = Main.storyboard; 275 | sourceTree = ""; 276 | }; 277 | /* End PBXVariantGroup section */ 278 | 279 | /* Begin XCBuildConfiguration section */ 280 | AE9BC4171D15E0BB00392254 /* Debug */ = { 281 | isa = XCBuildConfiguration; 282 | buildSettings = { 283 | ALWAYS_SEARCH_USER_PATHS = NO; 284 | CLANG_ANALYZER_NONNULL = YES; 285 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 286 | CLANG_CXX_LIBRARY = "libc++"; 287 | CLANG_ENABLE_MODULES = YES; 288 | CLANG_ENABLE_OBJC_ARC = YES; 289 | CLANG_WARN_BOOL_CONVERSION = YES; 290 | CLANG_WARN_CONSTANT_CONVERSION = YES; 291 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 292 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 293 | CLANG_WARN_EMPTY_BODY = YES; 294 | CLANG_WARN_ENUM_CONVERSION = YES; 295 | CLANG_WARN_INT_CONVERSION = YES; 296 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 297 | CLANG_WARN_UNREACHABLE_CODE = YES; 298 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 299 | CODE_SIGN_IDENTITY = "-"; 300 | COPY_PHASE_STRIP = NO; 301 | DEBUG_INFORMATION_FORMAT = dwarf; 302 | ENABLE_STRICT_OBJC_MSGSEND = YES; 303 | ENABLE_TESTABILITY = YES; 304 | GCC_C_LANGUAGE_STANDARD = gnu99; 305 | GCC_DYNAMIC_NO_PIC = NO; 306 | GCC_NO_COMMON_BLOCKS = YES; 307 | GCC_OPTIMIZATION_LEVEL = 0; 308 | GCC_PREPROCESSOR_DEFINITIONS = ( 309 | "DEBUG=1", 310 | "$(inherited)", 311 | ); 312 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 313 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 314 | GCC_WARN_UNDECLARED_SELECTOR = YES; 315 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 316 | GCC_WARN_UNUSED_FUNCTION = YES; 317 | GCC_WARN_UNUSED_VARIABLE = YES; 318 | MACOSX_DEPLOYMENT_TARGET = 10.11; 319 | MTL_ENABLE_DEBUG_INFO = YES; 320 | ONLY_ACTIVE_ARCH = YES; 321 | SDKROOT = macosx; 322 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 323 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 324 | }; 325 | name = Debug; 326 | }; 327 | AE9BC4181D15E0BB00392254 /* Release */ = { 328 | isa = XCBuildConfiguration; 329 | buildSettings = { 330 | ALWAYS_SEARCH_USER_PATHS = NO; 331 | CLANG_ANALYZER_NONNULL = YES; 332 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 333 | CLANG_CXX_LIBRARY = "libc++"; 334 | CLANG_ENABLE_MODULES = YES; 335 | CLANG_ENABLE_OBJC_ARC = YES; 336 | CLANG_WARN_BOOL_CONVERSION = YES; 337 | CLANG_WARN_CONSTANT_CONVERSION = YES; 338 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 339 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 340 | CLANG_WARN_EMPTY_BODY = YES; 341 | CLANG_WARN_ENUM_CONVERSION = YES; 342 | CLANG_WARN_INT_CONVERSION = YES; 343 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 344 | CLANG_WARN_UNREACHABLE_CODE = YES; 345 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 346 | CODE_SIGN_IDENTITY = "-"; 347 | COPY_PHASE_STRIP = NO; 348 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 349 | ENABLE_NS_ASSERTIONS = NO; 350 | ENABLE_STRICT_OBJC_MSGSEND = YES; 351 | GCC_C_LANGUAGE_STANDARD = gnu99; 352 | GCC_NO_COMMON_BLOCKS = YES; 353 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 354 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 355 | GCC_WARN_UNDECLARED_SELECTOR = YES; 356 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 357 | GCC_WARN_UNUSED_FUNCTION = YES; 358 | GCC_WARN_UNUSED_VARIABLE = YES; 359 | MACOSX_DEPLOYMENT_TARGET = 10.11; 360 | MTL_ENABLE_DEBUG_INFO = NO; 361 | SDKROOT = macosx; 362 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 363 | }; 364 | name = Release; 365 | }; 366 | AE9BC41A1D15E0BB00392254 /* Debug */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 370 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 371 | COMBINE_HIDPI_IMAGES = YES; 372 | INFOPLIST_FILE = Demo/Info.plist; 373 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 374 | PRODUCT_BUNDLE_IDENTIFIER = com.patrickbalestra.Demo; 375 | PRODUCT_NAME = "$(TARGET_NAME)"; 376 | SWIFT_VERSION = 3.0; 377 | }; 378 | name = Debug; 379 | }; 380 | AE9BC41B1D15E0BB00392254 /* Release */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 384 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 385 | COMBINE_HIDPI_IMAGES = YES; 386 | INFOPLIST_FILE = Demo/Info.plist; 387 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 388 | PRODUCT_BUNDLE_IDENTIFIER = com.patrickbalestra.Demo; 389 | PRODUCT_NAME = "$(TARGET_NAME)"; 390 | SWIFT_VERSION = 3.0; 391 | }; 392 | name = Release; 393 | }; 394 | AE9BC4301D15E0D700392254 /* Debug */ = { 395 | isa = XCBuildConfiguration; 396 | buildSettings = { 397 | CODE_SIGN_ENTITLEMENTS = CleanClosure/CleanClosure.entitlements; 398 | COMBINE_HIDPI_IMAGES = YES; 399 | INFOPLIST_FILE = CleanClosure/Info.plist; 400 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks"; 401 | MACOSX_DEPLOYMENT_TARGET = 10.11; 402 | PRODUCT_BUNDLE_IDENTIFIER = com.patrickbalestra.Demo.CleanClosure; 403 | PRODUCT_NAME = "Clean Closure"; 404 | SKIP_INSTALL = YES; 405 | SWIFT_VERSION = 3.0; 406 | }; 407 | name = Debug; 408 | }; 409 | AE9BC4311D15E0D700392254 /* Release */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | CODE_SIGN_ENTITLEMENTS = CleanClosure/CleanClosure.entitlements; 413 | COMBINE_HIDPI_IMAGES = YES; 414 | INFOPLIST_FILE = CleanClosure/Info.plist; 415 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks"; 416 | MACOSX_DEPLOYMENT_TARGET = 10.11; 417 | PRODUCT_BUNDLE_IDENTIFIER = com.patrickbalestra.Demo.CleanClosure; 418 | PRODUCT_NAME = "Clean Closure"; 419 | SKIP_INSTALL = YES; 420 | SWIFT_VERSION = 3.0; 421 | }; 422 | name = Release; 423 | }; 424 | /* End XCBuildConfiguration section */ 425 | 426 | /* Begin XCConfigurationList section */ 427 | AE9BC4051D15E0BB00392254 /* Build configuration list for PBXProject "CleanClosure" */ = { 428 | isa = XCConfigurationList; 429 | buildConfigurations = ( 430 | AE9BC4171D15E0BB00392254 /* Debug */, 431 | AE9BC4181D15E0BB00392254 /* Release */, 432 | ); 433 | defaultConfigurationIsVisible = 0; 434 | defaultConfigurationName = Release; 435 | }; 436 | AE9BC4191D15E0BB00392254 /* Build configuration list for PBXNativeTarget "CleanClosure" */ = { 437 | isa = XCConfigurationList; 438 | buildConfigurations = ( 439 | AE9BC41A1D15E0BB00392254 /* Debug */, 440 | AE9BC41B1D15E0BB00392254 /* Release */, 441 | ); 442 | defaultConfigurationIsVisible = 0; 443 | defaultConfigurationName = Release; 444 | }; 445 | AE9BC42F1D15E0D700392254 /* Build configuration list for PBXNativeTarget "CleanClosure Extension" */ = { 446 | isa = XCConfigurationList; 447 | buildConfigurations = ( 448 | AE9BC4301D15E0D700392254 /* Debug */, 449 | AE9BC4311D15E0D700392254 /* Release */, 450 | ); 451 | defaultConfigurationIsVisible = 0; 452 | defaultConfigurationName = Release; 453 | }; 454 | /* End XCConfigurationList section */ 455 | }; 456 | rootObject = AE9BC4021D15E0BB00392254 /* Project object */; 457 | } 458 | -------------------------------------------------------------------------------- /CleanClosure.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CleanClosure/CleanClosure.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CleanClosure/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | Clean Closure 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | XPC! 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSExtension 28 | 29 | NSExtensionAttributes 30 | 31 | XCSourceEditorCommandDefinitions 32 | 33 | 34 | XCSourceEditorCommandClassName 35 | $(PRODUCT_MODULE_NAME).SourceEditorCommand 36 | XCSourceEditorCommandIdentifier 37 | com.patrickbalestra.Demo.CleanClosure.SourceEditorCommand 38 | XCSourceEditorCommandName 39 | Source Editor Command 40 | 41 | 42 | XCSourceEditorExtensionPrincipalClass 43 | $(PRODUCT_MODULE_NAME).SourceEditorExtension 44 | 45 | NSExtensionPointIdentifier 46 | com.apple.dt.Xcode.extension.source-editor 47 | 48 | NSHumanReadableCopyright 49 | Copyright © 2016 Patrick Balestra. All rights reserved. 50 | 51 | 52 | -------------------------------------------------------------------------------- /CleanClosure/SourceEditorCommand.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SourceEditorCommand.swift 3 | // CleanClosure 4 | // 5 | // Created by Patrick Balestra on 6/18/16. 6 | // Copyright © 2016 Patrick Balestra. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import XcodeKit 11 | 12 | extension NSString { 13 | func remove(character: String, in range: NSRange) -> NSString { 14 | return self.replacingOccurrences(of: character, with: "", options: .caseInsensitiveSearch, range: range) 15 | } 16 | } 17 | 18 | class SourceEditorCommand: NSObject, XCSourceEditorCommand { 19 | 20 | func perform(with invocation: XCSourceEditorCommandInvocation, completionHandler: (NSError?) -> Void ) -> Void { 21 | 22 | var updatedLineIndexes = [Int]() 23 | 24 | for lineIndex in 0 ..< invocation.buffer.lines.count { 25 | let line = invocation.buffer.lines[lineIndex] as! NSString 26 | do { 27 | let regex = try RegularExpression(pattern: "\\{[\\s]*\\([a-zA-Z0-9_\\-,\\s]+\\)[\\s]*in", options: .caseInsensitive) 28 | let range = NSRange(location: 0, length: line.length) 29 | let results = regex.matches(in: line as String, options: .reportProgress, range: range) 30 | for result in results { 31 | let cleanLine = line.remove(character: "(", in: result.range).remove(character: ")", in: result.range) 32 | updatedLineIndexes.append(lineIndex) 33 | invocation.buffer.lines[lineIndex] = cleanLine 34 | } 35 | } catch { 36 | completionHandler(error as NSError) 37 | } 38 | } 39 | 40 | let updatedSelections: [XCSourceTextRange] = updatedLineIndexes.map { lineIndex in 41 | let lineSelection = XCSourceTextRange() 42 | lineSelection.start = XCSourceTextPosition(line: lineIndex, column: 0) 43 | lineSelection.end = XCSourceTextPosition(line: lineIndex, column: 0) 44 | return lineSelection 45 | } 46 | 47 | if updatedSelections.count > 0 { 48 | invocation.buffer.selections.setArray(updatedSelections) 49 | } 50 | 51 | completionHandler(nil) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /CleanClosure/SourceEditorExtension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SourceEditorExtension.swift 3 | // CleanClosure 4 | // 5 | // Created by Patrick Balestra on 6/18/16. 6 | // Copyright © 2016 Patrick Balestra. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import XcodeKit 11 | 12 | class SourceEditorExtension: NSObject, XCSourceEditorExtension { 13 | 14 | /* 15 | func extensionDidFinishLaunching() { 16 | // If your extension needs to do any work at launch, implement this optional method. 17 | } 18 | */ 19 | 20 | /* 21 | var commandDefinitions: [[XCSourceEditorCommandDefinitionKey: AnyObject]] { 22 | // If your extension needs to return a collection of command definitions that differs from those in its Info.plist, implement this optional property getter. 23 | return [] 24 | } 25 | */ 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Demo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Demo 4 | // 5 | // Created by Patrick Balestra on 6/18/16. 6 | // Copyright © 2016 Patrick Balestra. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | 15 | 16 | func applicationDidFinishLaunching(_ aNotification: Notification) { 17 | // Insert code here to initialize your application 18 | } 19 | 20 | func applicationWillTerminate(_ aNotification: Notification) { 21 | // Insert code here to tear down your application 22 | } 23 | 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /Demo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /Demo/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 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | Default 509 | 510 | 511 | 512 | 513 | 514 | 515 | Left to Right 516 | 517 | 518 | 519 | 520 | 521 | 522 | Right to Left 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | Default 534 | 535 | 536 | 537 | 538 | 539 | 540 | Left to Right 541 | 542 | 543 | 544 | 545 | 546 | 547 | Right to Left 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | -------------------------------------------------------------------------------- /Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2016 Patrick Balestra. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /Demo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Demo 4 | // 5 | // Created by Patrick Balestra on 6/18/16. 6 | // Copyright © 2016 Patrick Balestra. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class ViewController: NSViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | // Do any additional setup after loading the view. 17 | } 18 | 19 | override var representedObject: AnyObject? { 20 | didSet { 21 | // Update the view, if already loaded. 22 | } 23 | } 24 | 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Patrick Balestra 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Clean Closure - Xcode Source Editor Extension 2 | 3 |

4 | 5 | 6 | Clean Closure is a simple Xcode Source Editor Extension for Xcode 8. It parses each line of a file to simplify the syntax of closures in your Swift code by removing the useless `()`. 7 | 8 | The code is pretty straighforward and it uses a `RegularExpression` to find out where a closure is by looking for `(`, `)` and `in` characters. 9 | 10 | ## Requirements 11 | Xcode 8.0 🛠 12 | 13 | Please run `sudo /usr/libexec/xpccachectl` and restart your Mac before running the extension if you are on macOS 10.11 El Capitan. 14 | 15 | ## Author 16 | 17 | I'm [Patrick Balestra](http://www.patrickbalestra.com). 18 | Email: [me@patrickbalestra.com](mailto:me@patrickbalestra.com) 19 | Twitter: [@BalestraPatrick](http://twitter.com/BalestraPatrick). 20 | 21 | ## License 22 | 23 | `CleanClosureXcode` is available under the MIT license. See the [LICENSE](LICENSE) file for more info. 24 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrielPeart/CleanClosureXcode/c33df35c618c673ad4764f443a309178b727a7e6/demo.gif --------------------------------------------------------------------------------