nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.77k stars 630 forks source link

Inconsistent white space for template XCode SwiftUI project straight out of the box #767

Closed gigecogary closed 3 years ago

gigecogary commented 3 years ago

The following gives the error inconsistent white space, at line 19 This is a file that is generated by xcode for a brand new SwiftUI project

//
//  ContentView.swift
//  Test SwiftUI
//
//

import SwiftUI

struct ContentView: View {
    var body: some View {
        Text("Hello, world!")
            .padding()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
bencochran commented 3 years ago

It looks like there’s a form feed character (U+000C) after ContentView(). Are you sure this wasn’t modified by mistake after being generated? I just made a new SwiftUI app with Xcode 12.0 (12A7209) and got no unexpected character in that same location.

gigecogary commented 3 years ago

You are right, closing this issue.

nicklockwood commented 3 years ago

If U+000C is permitted by the Swift compiler, it probably shouldn't cause an error in SwiftFormat. I'll look at fixing that.

nicklockwood commented 3 years ago

@gigecogary fixed in 0.47.0