I use swiftlint
in my project. The project name is ABC xx
and it works fine with swiftlint. Now I decided to include Unitest
in my application and I have to import @testable import ABC_xx
into the swift test file which is class ABC_xxTests: XCTestCase {
not I get an error with Swiftlinter which says Type Name Violation: Type name should only contain alphanumeric characters: 'ABC_xxTests' (type_name)
how do I sort this error
A tool to enforce Swift style and conventions, loosely based on the now archived GitHub Swift Style Guide. SwiftLint enforces the style guide rules that are generally accepted by the Swift community.
A tool to enforce Swift style and conventions, loosely based on the now archived GitHub Swift Style Guide. SwiftLint enforces the style guide rules that are generally accepted by the Swift community. These rules are well described in popular style guides like Ray Wenderlich's Swift Style Guide.
Here the general .swiftlint.yml file, which I recommend you to use in your project. Now, Save configuration file and build, you will see that the number of warnings and errors are now so much lower. I recommend you to go to the Swiftlint rules file in their repository and see all of them. Or you can run swiftlint rules command to see all the rules.
Yes of course there is! SwiftLint is a swift code style analysis tool that helps you flag stylistic errors in your code. It can help you enforce these styles by marking build as failures or with warnings when the style is not followed. In this tutorial I will show you how to setup SwiftLint, configure it and use it within Xcode build process.
The following swiftlint rule enable the use of underscore in your Swift class names:
type_name:
allowed_symbols: "_"
EDIT: If you want to enable the use of underscore also for variable names use:
identifier_name:
allowed_symbols: "_"
In addition to @carmine's answer, keep the below two things in mind while adding attributes to any rule in .swiftlint.yml
:
In my case I overlooked the white space before allowed_symbols
. So the linting was not working. When I added white space, it was successful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With