├── .DemoXcodeProject ├── ExampleUse.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── ExampleUse │ ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json │ ├── ContentView.swift │ ├── ExampleUse.entitlements │ ├── ExampleUseApp.swift │ └── Preview Content │ └── Preview Assets.xcassets │ └── Contents.json ├── .gitignore ├── .swift-version ├── .swiftpm └── xcode │ └── package.xcworkspace │ └── contents.xcworkspacedata ├── LICENSE ├── Package.swift ├── Plugins └── SwiftFormat │ ├── Shared │ ├── CommandPlugin+Extension.swift │ └── PluginToolProviding.swift │ ├── SwiftFormatPlugin.swift │ └── SwiftFormatPluginXcode.swift └── README.md /.DemoXcodeProject/ExampleUse.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 56; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8AE3F6B02882212C00BFB82A /* ExampleUseApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE3F6AF2882212C00BFB82A /* ExampleUseApp.swift */; }; 11 | 8AE3F6B22882212C00BFB82A /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE3F6B12882212C00BFB82A /* ContentView.swift */; }; 12 | 8AE3F6B42882212D00BFB82A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8AE3F6B32882212D00BFB82A /* Assets.xcassets */; }; 13 | 8AE3F6B82882212D00BFB82A /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8AE3F6B72882212D00BFB82A /* Preview Assets.xcassets */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXFileReference section */ 17 | 8ACDB4F92882D0A60029C153 /* SwiftFormatPlugin */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = SwiftFormatPlugin; path = ..; sourceTree = ""; }; 18 | 8AE3F6AC2882212C00BFB82A /* ExampleUse.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExampleUse.app; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | 8AE3F6AF2882212C00BFB82A /* ExampleUseApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleUseApp.swift; sourceTree = ""; }; 20 | 8AE3F6B12882212C00BFB82A /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 21 | 8AE3F6B32882212D00BFB82A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 22 | 8AE3F6B52882212D00BFB82A /* ExampleUse.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ExampleUse.entitlements; sourceTree = ""; }; 23 | 8AE3F6B72882212D00BFB82A /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 24 | /* End PBXFileReference section */ 25 | 26 | /* Begin PBXFrameworksBuildPhase section */ 27 | 8AE3F6A92882212C00BFB82A /* Frameworks */ = { 28 | isa = PBXFrameworksBuildPhase; 29 | buildActionMask = 2147483647; 30 | files = ( 31 | ); 32 | runOnlyForDeploymentPostprocessing = 0; 33 | }; 34 | /* End PBXFrameworksBuildPhase section */ 35 | 36 | /* Begin PBXGroup section */ 37 | 8AE3F6A32882212C00BFB82A = { 38 | isa = PBXGroup; 39 | children = ( 40 | 8AE3F6BE2882213C00BFB82A /* Packages */, 41 | 8AE3F6AE2882212C00BFB82A /* ExampleUse */, 42 | 8AE3F6AD2882212C00BFB82A /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | 8AE3F6AD2882212C00BFB82A /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | 8AE3F6AC2882212C00BFB82A /* ExampleUse.app */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | 8AE3F6AE2882212C00BFB82A /* ExampleUse */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | 8AE3F6AF2882212C00BFB82A /* ExampleUseApp.swift */, 58 | 8AE3F6B12882212C00BFB82A /* ContentView.swift */, 59 | 8AE3F6B32882212D00BFB82A /* Assets.xcassets */, 60 | 8AE3F6B52882212D00BFB82A /* ExampleUse.entitlements */, 61 | 8AE3F6B62882212D00BFB82A /* Preview Content */, 62 | ); 63 | path = ExampleUse; 64 | sourceTree = ""; 65 | }; 66 | 8AE3F6B62882212D00BFB82A /* Preview Content */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 8AE3F6B72882212D00BFB82A /* Preview Assets.xcassets */, 70 | ); 71 | path = "Preview Content"; 72 | sourceTree = ""; 73 | }; 74 | 8AE3F6BE2882213C00BFB82A /* Packages */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 8ACDB4F92882D0A60029C153 /* SwiftFormatPlugin */, 78 | ); 79 | name = Packages; 80 | sourceTree = ""; 81 | }; 82 | /* End PBXGroup section */ 83 | 84 | /* Begin PBXNativeTarget section */ 85 | 8AE3F6AB2882212C00BFB82A /* ExampleUse */ = { 86 | isa = PBXNativeTarget; 87 | buildConfigurationList = 8AE3F6BB2882212D00BFB82A /* Build configuration list for PBXNativeTarget "ExampleUse" */; 88 | buildPhases = ( 89 | 8AE3F6A82882212C00BFB82A /* Sources */, 90 | 8AE3F6A92882212C00BFB82A /* Frameworks */, 91 | 8AE3F6AA2882212C00BFB82A /* Resources */, 92 | ); 93 | buildRules = ( 94 | ); 95 | dependencies = ( 96 | ); 97 | name = ExampleUse; 98 | productName = ExampleUse; 99 | productReference = 8AE3F6AC2882212C00BFB82A /* ExampleUse.app */; 100 | productType = "com.apple.product-type.application"; 101 | }; 102 | /* End PBXNativeTarget section */ 103 | 104 | /* Begin PBXProject section */ 105 | 8AE3F6A42882212C00BFB82A /* Project object */ = { 106 | isa = PBXProject; 107 | attributes = { 108 | BuildIndependentTargetsInParallel = 1; 109 | LastSwiftUpdateCheck = 1400; 110 | LastUpgradeCheck = 1400; 111 | TargetAttributes = { 112 | 8AE3F6AB2882212C00BFB82A = { 113 | CreatedOnToolsVersion = 14.0; 114 | }; 115 | }; 116 | }; 117 | buildConfigurationList = 8AE3F6A72882212C00BFB82A /* Build configuration list for PBXProject "ExampleUse" */; 118 | compatibilityVersion = "Xcode 14.0"; 119 | developmentRegion = en; 120 | hasScannedForEncodings = 0; 121 | knownRegions = ( 122 | en, 123 | Base, 124 | ); 125 | mainGroup = 8AE3F6A32882212C00BFB82A; 126 | productRefGroup = 8AE3F6AD2882212C00BFB82A /* Products */; 127 | projectDirPath = ""; 128 | projectRoot = ""; 129 | targets = ( 130 | 8AE3F6AB2882212C00BFB82A /* ExampleUse */, 131 | ); 132 | }; 133 | /* End PBXProject section */ 134 | 135 | /* Begin PBXResourcesBuildPhase section */ 136 | 8AE3F6AA2882212C00BFB82A /* Resources */ = { 137 | isa = PBXResourcesBuildPhase; 138 | buildActionMask = 2147483647; 139 | files = ( 140 | 8AE3F6B82882212D00BFB82A /* Preview Assets.xcassets in Resources */, 141 | 8AE3F6B42882212D00BFB82A /* Assets.xcassets in Resources */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | /* End PBXResourcesBuildPhase section */ 146 | 147 | /* Begin PBXSourcesBuildPhase section */ 148 | 8AE3F6A82882212C00BFB82A /* Sources */ = { 149 | isa = PBXSourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | 8AE3F6B22882212C00BFB82A /* ContentView.swift in Sources */, 153 | 8AE3F6B02882212C00BFB82A /* ExampleUseApp.swift in Sources */, 154 | ); 155 | runOnlyForDeploymentPostprocessing = 0; 156 | }; 157 | /* End PBXSourcesBuildPhase section */ 158 | 159 | /* Begin XCBuildConfiguration section */ 160 | 8AE3F6B92882212D00BFB82A /* Debug */ = { 161 | isa = XCBuildConfiguration; 162 | buildSettings = { 163 | ALWAYS_SEARCH_USER_PATHS = NO; 164 | CLANG_ANALYZER_NONNULL = YES; 165 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 166 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 167 | CLANG_ENABLE_MODULES = YES; 168 | CLANG_ENABLE_OBJC_ARC = YES; 169 | CLANG_ENABLE_OBJC_WEAK = YES; 170 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 171 | CLANG_WARN_BOOL_CONVERSION = YES; 172 | CLANG_WARN_COMMA = YES; 173 | CLANG_WARN_CONSTANT_CONVERSION = YES; 174 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 175 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 176 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 177 | CLANG_WARN_EMPTY_BODY = YES; 178 | CLANG_WARN_ENUM_CONVERSION = YES; 179 | CLANG_WARN_INFINITE_RECURSION = YES; 180 | CLANG_WARN_INT_CONVERSION = YES; 181 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 182 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 183 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 184 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 185 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 186 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 187 | CLANG_WARN_STRICT_PROTOTYPES = YES; 188 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 189 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 190 | CLANG_WARN_UNREACHABLE_CODE = YES; 191 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 192 | COPY_PHASE_STRIP = NO; 193 | DEBUG_INFORMATION_FORMAT = dwarf; 194 | ENABLE_STRICT_OBJC_MSGSEND = YES; 195 | ENABLE_TESTABILITY = YES; 196 | GCC_C_LANGUAGE_STANDARD = gnu11; 197 | GCC_DYNAMIC_NO_PIC = NO; 198 | GCC_NO_COMMON_BLOCKS = YES; 199 | GCC_OPTIMIZATION_LEVEL = 0; 200 | GCC_PREPROCESSOR_DEFINITIONS = ( 201 | "DEBUG=1", 202 | "$(inherited)", 203 | ); 204 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 205 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 206 | GCC_WARN_UNDECLARED_SELECTOR = YES; 207 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 208 | GCC_WARN_UNUSED_FUNCTION = YES; 209 | GCC_WARN_UNUSED_VARIABLE = YES; 210 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 211 | MTL_FAST_MATH = YES; 212 | ONLY_ACTIVE_ARCH = YES; 213 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 214 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 215 | }; 216 | name = Debug; 217 | }; 218 | 8AE3F6BA2882212D00BFB82A /* Release */ = { 219 | isa = XCBuildConfiguration; 220 | buildSettings = { 221 | ALWAYS_SEARCH_USER_PATHS = NO; 222 | CLANG_ANALYZER_NONNULL = YES; 223 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 224 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 225 | CLANG_ENABLE_MODULES = YES; 226 | CLANG_ENABLE_OBJC_ARC = YES; 227 | CLANG_ENABLE_OBJC_WEAK = YES; 228 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 229 | CLANG_WARN_BOOL_CONVERSION = YES; 230 | CLANG_WARN_COMMA = YES; 231 | CLANG_WARN_CONSTANT_CONVERSION = YES; 232 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 233 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 234 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 235 | CLANG_WARN_EMPTY_BODY = YES; 236 | CLANG_WARN_ENUM_CONVERSION = YES; 237 | CLANG_WARN_INFINITE_RECURSION = YES; 238 | CLANG_WARN_INT_CONVERSION = YES; 239 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 240 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 241 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 242 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 243 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 244 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 245 | CLANG_WARN_STRICT_PROTOTYPES = YES; 246 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 247 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 248 | CLANG_WARN_UNREACHABLE_CODE = YES; 249 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 250 | COPY_PHASE_STRIP = NO; 251 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 252 | ENABLE_NS_ASSERTIONS = NO; 253 | ENABLE_STRICT_OBJC_MSGSEND = YES; 254 | GCC_C_LANGUAGE_STANDARD = gnu11; 255 | GCC_NO_COMMON_BLOCKS = YES; 256 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 257 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 258 | GCC_WARN_UNDECLARED_SELECTOR = YES; 259 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 260 | GCC_WARN_UNUSED_FUNCTION = YES; 261 | GCC_WARN_UNUSED_VARIABLE = YES; 262 | MTL_ENABLE_DEBUG_INFO = NO; 263 | MTL_FAST_MATH = YES; 264 | SWIFT_COMPILATION_MODE = wholemodule; 265 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 266 | }; 267 | name = Release; 268 | }; 269 | 8AE3F6BC2882212D00BFB82A /* Debug */ = { 270 | isa = XCBuildConfiguration; 271 | buildSettings = { 272 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 273 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 274 | CODE_SIGN_ENTITLEMENTS = ExampleUse/ExampleUse.entitlements; 275 | CODE_SIGN_STYLE = Automatic; 276 | CURRENT_PROJECT_VERSION = 1; 277 | DEVELOPMENT_ASSET_PATHS = "\"ExampleUse/Preview Content\""; 278 | DEVELOPMENT_TEAM = 6V66CC3AN6; 279 | ENABLE_HARDENED_RUNTIME = YES; 280 | ENABLE_PREVIEWS = YES; 281 | GENERATE_INFOPLIST_FILE = YES; 282 | "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; 283 | "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; 284 | "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; 285 | "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; 286 | "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; 287 | "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; 288 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 289 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 290 | IPHONEOS_DEPLOYMENT_TARGET = 16.0; 291 | LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; 292 | "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; 293 | MACOSX_DEPLOYMENT_TARGET = 12.4; 294 | MARKETING_VERSION = 1.0; 295 | PRODUCT_BUNDLE_IDENTIFIER = us.eidinger.ExampleUse; 296 | PRODUCT_NAME = "$(TARGET_NAME)"; 297 | SDKROOT = auto; 298 | SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; 299 | SWIFT_EMIT_LOC_STRINGS = YES; 300 | SWIFT_VERSION = 5.0; 301 | TARGETED_DEVICE_FAMILY = "1,2"; 302 | }; 303 | name = Debug; 304 | }; 305 | 8AE3F6BD2882212D00BFB82A /* Release */ = { 306 | isa = XCBuildConfiguration; 307 | buildSettings = { 308 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 309 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 310 | CODE_SIGN_ENTITLEMENTS = ExampleUse/ExampleUse.entitlements; 311 | CODE_SIGN_STYLE = Automatic; 312 | CURRENT_PROJECT_VERSION = 1; 313 | DEVELOPMENT_ASSET_PATHS = "\"ExampleUse/Preview Content\""; 314 | DEVELOPMENT_TEAM = 6V66CC3AN6; 315 | ENABLE_HARDENED_RUNTIME = YES; 316 | ENABLE_PREVIEWS = YES; 317 | GENERATE_INFOPLIST_FILE = YES; 318 | "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; 319 | "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; 320 | "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; 321 | "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; 322 | "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; 323 | "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; 324 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 325 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 326 | IPHONEOS_DEPLOYMENT_TARGET = 16.0; 327 | LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; 328 | "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; 329 | MACOSX_DEPLOYMENT_TARGET = 12.4; 330 | MARKETING_VERSION = 1.0; 331 | PRODUCT_BUNDLE_IDENTIFIER = us.eidinger.ExampleUse; 332 | PRODUCT_NAME = "$(TARGET_NAME)"; 333 | SDKROOT = auto; 334 | SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; 335 | SWIFT_EMIT_LOC_STRINGS = YES; 336 | SWIFT_VERSION = 5.0; 337 | TARGETED_DEVICE_FAMILY = "1,2"; 338 | }; 339 | name = Release; 340 | }; 341 | /* End XCBuildConfiguration section */ 342 | 343 | /* Begin XCConfigurationList section */ 344 | 8AE3F6A72882212C00BFB82A /* Build configuration list for PBXProject "ExampleUse" */ = { 345 | isa = XCConfigurationList; 346 | buildConfigurations = ( 347 | 8AE3F6B92882212D00BFB82A /* Debug */, 348 | 8AE3F6BA2882212D00BFB82A /* Release */, 349 | ); 350 | defaultConfigurationIsVisible = 0; 351 | defaultConfigurationName = Release; 352 | }; 353 | 8AE3F6BB2882212D00BFB82A /* Build configuration list for PBXNativeTarget "ExampleUse" */ = { 354 | isa = XCConfigurationList; 355 | buildConfigurations = ( 356 | 8AE3F6BC2882212D00BFB82A /* Debug */, 357 | 8AE3F6BD2882212D00BFB82A /* Release */, 358 | ); 359 | defaultConfigurationIsVisible = 0; 360 | defaultConfigurationName = Release; 361 | }; 362 | /* End XCConfigurationList section */ 363 | }; 364 | rootObject = 8AE3F6A42882212C00BFB82A /* Project object */; 365 | } 366 | -------------------------------------------------------------------------------- /.DemoXcodeProject/ExampleUse.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.DemoXcodeProject/ExampleUse.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.DemoXcodeProject/ExampleUse/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 | -------------------------------------------------------------------------------- /.DemoXcodeProject/ExampleUse/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "platform" : "ios", 6 | "size" : "1024x1024" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "scale" : "1x", 11 | "size" : "16x16" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "scale" : "2x", 16 | "size" : "16x16" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "scale" : "1x", 21 | "size" : "32x32" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "scale" : "2x", 26 | "size" : "32x32" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "scale" : "1x", 31 | "size" : "128x128" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "scale" : "2x", 36 | "size" : "128x128" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "scale" : "1x", 41 | "size" : "256x256" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "scale" : "2x", 46 | "size" : "256x256" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "scale" : "1x", 51 | "size" : "512x512" 52 | }, 53 | { 54 | "idiom" : "mac", 55 | "scale" : "2x", 56 | "size" : "512x512" 57 | } 58 | ], 59 | "info" : { 60 | "author" : "xcode", 61 | "version" : 1 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /.DemoXcodeProject/ExampleUse/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /.DemoXcodeProject/ExampleUse/ContentView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | struct ContentView: View { 4 | private var text:String="Hello, World!" 5 | var body: some View { 6 | VStack { 7 | Image(systemName: "globe") 8 | .imageScale(.large) 9 | .foregroundColor(.accentColor) 10 | Text("Hello, world!") 11 | } 12 | } 13 | } 14 | 15 | struct ContentView_Previews: PreviewProvider { 16 | static var previews: some View { 17 | ContentView() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.DemoXcodeProject/ExampleUse/ExampleUse.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.DemoXcodeProject/ExampleUse/ExampleUseApp.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | @main 4 | struct ExampleUseApp: App { 5 | var body: some Scene { 6 | WindowGroup { 7 | ContentView() 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.DemoXcodeProject/ExampleUse/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 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 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 5.6 -------------------------------------------------------------------------------- /.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Marco Eidinger 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 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 5.6 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "SwiftFormatPlugin", 7 | products: [ 8 | .plugin(name: "SwiftFormat", targets: ["SwiftFormat"]), 9 | ], 10 | dependencies: [], 11 | targets: [ 12 | .binaryTarget( 13 | name: "swiftformat", 14 | url: "https://github.com/nicklockwood/SwiftFormat/releases/download/0.50.3/swiftformat.artifactbundle.zip", 15 | checksum: "a3221d54c2ac00f5c0ce0a2ebc6906ee371d527814174a9c65983f3a3a395321" 16 | ), 17 | .plugin(name: "SwiftFormat", 18 | capability: .command( 19 | intent: .sourceCodeFormatting(), 20 | permissions: [ 21 | .writeToPackageDirectory(reason: "This command reformats source files"), 22 | ] 23 | ), 24 | dependencies: [.target(name: "swiftformat")]), 25 | ] 26 | ) 27 | -------------------------------------------------------------------------------- /Plugins/SwiftFormat/Shared/CommandPlugin+Extension.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import PackagePlugin 3 | 4 | extension CommandPlugin { 5 | func formatCode(in directory: PackagePlugin.Path, context: PluginToolProviding, arguments: [String]) throws { 6 | let tool = try context.tool(named: "swiftformat") 7 | let toolURL = URL(fileURLWithPath: tool.path.string) 8 | 9 | var processArguments = [directory.string] 10 | processArguments.append(contentsOf: arguments) 11 | 12 | let process = Process() 13 | process.executableURL = toolURL 14 | process.arguments = processArguments 15 | 16 | try process.run() 17 | process.waitUntilExit() 18 | 19 | if process.terminationReason == .exit, process.terminationStatus == 0 { 20 | print("Formatted the source code in \(directory.string).") 21 | } else { 22 | let problem = "\(process.terminationReason):\(process.terminationStatus)" 23 | Diagnostics.error("swiftformat invocation failed: \(problem)") 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Plugins/SwiftFormat/Shared/PluginToolProviding.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import PackagePlugin 3 | 4 | protocol PluginToolProviding { 5 | func tool(named name: String) throws -> PackagePlugin.PluginContext.Tool 6 | } 7 | 8 | extension PluginContext: PluginToolProviding {} 9 | 10 | #if canImport(XcodeProjectPlugin) 11 | import XcodeProjectPlugin 12 | 13 | extension XcodePluginContext: PluginToolProviding {} 14 | #endif 15 | -------------------------------------------------------------------------------- /Plugins/SwiftFormat/SwiftFormatPlugin.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import PackagePlugin 3 | 4 | @main 5 | struct SwiftFormatPlugin: CommandPlugin { 6 | /// This entry point is called when operating on a Swift package. 7 | func performCommand(context: PluginContext, arguments: [String]) throws { 8 | if arguments.contains("--verbose") { 9 | print("Command plugin execution with arguments \(arguments.description) for Swift package \(context.package.displayName). All target information: \(context.package.targets.description)") 10 | } 11 | 12 | var targetsToProcess: [Target] = context.package.targets 13 | 14 | var argExtractor = ArgumentExtractor(arguments) 15 | 16 | let selectedTargets = argExtractor.extractOption(named: "target") 17 | 18 | if selectedTargets.isEmpty == false { 19 | targetsToProcess = context.package.targets.filter { selectedTargets.contains($0.name) }.map { $0 } 20 | } 21 | 22 | for target in targetsToProcess { 23 | guard let target = target as? SourceModuleTarget else { continue } 24 | 25 | try formatCode(in: target.directory, context: context, arguments: argExtractor.remainingArguments) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Plugins/SwiftFormat/SwiftFormatPluginXcode.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import PackagePlugin 3 | 4 | #if canImport(XcodeProjectPlugin) 5 | import XcodeProjectPlugin 6 | 7 | extension SwiftFormatPlugin: XcodeCommandPlugin { 8 | /// This entry point is called when operating on an Xcode project. 9 | func performCommand(context: XcodePluginContext, arguments: [String]) throws { 10 | if arguments.contains("--verbose") { 11 | print("Command plugin execution with arguments \(arguments.description) for Swift package \(context.xcodeProject.displayName). All target information: \(context.xcodeProject.targets.description)") 12 | print("Plugin will run for directory: \(context.xcodeProject.directory.description)") 13 | } 14 | 15 | var argExtractor = ArgumentExtractor(arguments) 16 | _ = argExtractor.extractOption(named: "target") 17 | 18 | try formatCode(in: context.xcodeProject.directory, context: context, arguments: argExtractor.remainingArguments) 19 | } 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SwiftFormatPlugin 2 | 3 | 📣 **I contributed the plugin implementation to [nicklockwood/SwiftFormat](https://github.com/nicklockwood/SwiftFormat#swift-package-manager-plugin) which is available with [0.50.4](https://github.com/nicklockwood/SwiftFormat/releases/tag/0.50.4)** 🚨 4 | 5 | [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FMarcoEidinger%2FSwiftFormatPlugin%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/MarcoEidinger/SwiftFormatPlugin) 6 | [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FMarcoEidinger%2FSwiftFormatPlugin%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/MarcoEidinger/SwiftFormatPlugin) 7 | 8 | A Swift Package Plugin to format source code with [SwiftFormat](https://github.com/nicklockwood/SwiftFormat). 9 | 10 | ## Add to Package 11 | 12 | Add the package to your dependencies. 13 | 14 | ```swift 15 | dependencies: [ 16 | // ... 17 | .package(url: "https://github.com/MarcoEidinger/SwiftFormatPlugin", from: "0.50.3"), 18 | ] 19 | ``` 20 | 21 | Note: the version matches a [SwiftFormat release](https://github.com/nicklockwood/SwiftFormat/releases). 22 | 23 | ## Run Plugin 24 | 25 | ### SPM 26 | 27 | ```bash 28 | swift package plugin --allow-writing-to-package-directory format-source-code 29 | ``` 30 | 31 | You can limit the formatting to a particular target with `--target` option. 32 | 33 | You can also specify SwiftFormat arguments such as `--swiftversion`. 34 | 35 | Example 36 | 37 | ```bash 38 | swift package plugin --allow-writing-to-package-directory format-source-code --target MyLibrary --swiftversion 5.6 --verbose 39 | ``` 40 | 41 | ### Xcode 42 | 43 | In Xcode 14 you can trigger the command plugin execution for a Swift package or an Xcode project. 44 | 45 | For an Xcode project the project's main directory will be processed and the `--target` option will be ignored. 46 | 47 | You can also specify SwiftFormat arguments such as `--swiftversion`. 48 | 49 | ![Run plugin in Xcode 14](https://user-images.githubusercontent.com/4176826/179352584-db7f7f42-452c-4a42-a329-01b115a237a7.gif) 50 | --------------------------------------------------------------------------------