Closed aFernandezEspinosa closed 2 months ago
You can exclude specific files or paths using the --exclude path/to/files
option
Hmmm yeah the problem with SPM is that the path to those files goes into derived data
/Users/myuser/Library/Developer/Xcode/DerivedData/myApp-cemufujozguknefkeaxcvnlcvwje/SourcePackages/checkouts/spmLibrary
SwiftFormat shouldn't be scanning those files at all unless you are running it at the root of your user folder or something. You should normally only run SwiftFormat inside your project folder.
I see let me check what's happening it's a very simple piece of code not sure why the compiler is complaining about it.
public var wrappedValue: DataType {
get {
do {
guard let storedData: Data = try container.value(forKey: key),
let value: DataType = try? JSONDecoder().decode(DataType.self, from: storedData) else {
return fallbackValue
}
fallbackValue = value
} catch let error {
logger.error("Fetch value for '\(key)' from \(container) failed. \(error.localizedDescription)")
}
return fallbackValue
}
set { ... }
Interestingly I have the same package in a different app, and in the other app it works fine, maybe I have some compiler flag configured in a different way 😓
I think the SPM thing is a red herring. My guess is that your logger is using string interpolation so it's not safe to remove self
inside logged strings. Add --selfrequired logger.error
to your .swiftformat configuration and it should solve the problem.
Thank you 🙏
I'm getting:
on an SPM Swift file, I can't update or modify that file for obvious reasons as it's not part of my codebase, I was hoping I could exclude all the SPMs from being formatted, however I realized the SPM files are stored in the derived data path.
Any good option to exclude these files from being analyzed by the swiftFormat tool?