Swiftpack.co - Swift Packages by realm

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

Packages published by realm

realm/SwiftLint 0.50.1
A tool to enforce Swift style and conventions.
⭐️ 16,815
🕓 1 week ago
🔖 Release Notes

Releases

The markdown parsing is broken/disabled for release notes. Sorry about that, I'm chasing the source of a crash that's been bringing this website down for the last couple of days.
0.50.1: Artisanal Clothes Pegs Fixup Edition
1 week ago
#### Breaking * None. #### Experimental * None. #### Enhancements * Moved the validation of doc comments in local scopes out of `orphaned_doc_comment` and into a new opt-in `local_doc_comment` rule. [JP Simard](https://github.com/jpsim) [#4573](https://github.com/realm/SwiftLint/issues/4573) * SwiftLint's Swift Package Build Tool Plugin will now only scan files in the target being built. [Tony Arnold](https://github.com/tonyarnold) [#4406](https://github.com/realm/SwiftLint/pull/4406) #### Bug Fixes * Fix building with `swift build -c release`. [JP Simard](https://github.com/jpsim) [#4559](https://github.com/realm/SwiftLint/issues/4559) [#4560](https://github.com/realm/SwiftLint/issues/4560) * Fix false positives in `lower_acl_than_parent` when the nominal parent is an extension. [Steffen Matthischke](https://github.com/heeaad) [#4564](https://github.com/realm/SwiftLint/issues/4564) * Fix `minimum_fraction_length` handling in `number_separator`. [JP Simard](https://github.com/jpsim) [#4576](https://github.com/realm/SwiftLint/issues/4576) * Fix false positives in `closure_spacing`. [JP Simard](https://github.com/jpsim) [#4565](https://github.com/realm/SwiftLint/issues/4565) [#4582](https://github.com/realm/SwiftLint/issues/4582) * Fix line count calculation for multiline string literals. [JP Simard](https://github.com/jpsim) [#4585](https://github.com/realm/SwiftLint/issues/4585) * Fix false positives in `unused_closure_parameter` when using identifiers with backticks. [JP Simard](https://github.com/jpsim) [#4588](https://github.com/realm/SwiftLint/issues/4588) * Fix `type_name` regression where names with backticks would trigger violations. [JP Simard](https://github.com/jpsim) [#4571](https://github.com/realm/SwiftLint/issues/4571)
0.50.0: Artisanal Clothes Pegs
2 weeks ago
#### Breaking * SwiftLint now requires Swift 5.7 or higher to build. [JP Simard](https://github.com/jpsim) * Exclude `weak_delegate` rule from autocorrection due to behavioral changes leading to potential undefined behavior or bugs. [SimplyDanny](https://github.com/SimplyDanny) [#3577](https://github.com/realm/SwiftLint/issues/3577) * The `anyobject_protocol` rule is now deprecated and will be completely removed in a future release because it is now handled by the Swift compiler. [JP Simard](https://github.com/jpsim) * Built-in SwiftLint rules are no longer marked as `public` in SwiftLintFramework. This only impacts the programmatic API for the SwiftLintFramework module. [JP Simard](https://github.com/jpsim) #### Experimental * None. #### Enhancements * SwiftSyntax libraries have been updated from the previous 5.6 release and now use the new parser written in Swift. Swift 5.7+ features should now be parsed more accurately. We've also measured an improvement in lint times of up to 15%. This should also fix some deployment issues where the exact version of the internal SwiftSyntax parser needed to be available. If you notice any unexpected changes to lint results, please file an issue on the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax parser regression we can re-file it upstream. [JP Simard](https://github.com/jpsim) [#4031](https://github.com/realm/SwiftLint/issues/4031) * Rewrite some rules with SwiftSyntax, fixing some false positives and catching more violations: - `anonymous_argument_in_multiline_closure` - `array_init` - `attributes` - `balanced_xctest_lifecycle` - `block_based_kvo` - `class_delegate_protocol` - `closing_brace` - `closure_body_length` - `closure_parameter_position` - `collection_alignment` - `comment_spacing` - `computed_accessors_order` - `conditional_returns_on_newline` - `contains_over_filter_count` - `contains_over_filter_is_empty` - `contains_over_first_not_nil` - `contains_over_range_nil_comparison` - `convenience_type` - `deployment_target` - `discarded_notification_center_observer` - `discouraged_assert` - `discouraged_direct_init` - `discouraged_none_name` - `discouraged_object_literal` - `discouraged_optional_boolean` - `duplicate_enum_cases` - `duplicated_key_in_dictionary_literal` - `dynamic_inline` - `empty_collection_literal` - `empty_count` - `empty_enum_arguments` - `empty_parameters` - `empty_parentheses_with_trailing_closure` - `empty_string` - `enum_case_associated_values_count` - `explicit_enum_raw_value` - `explicit_init` - `explicit_top_level_acl` - `fallthrough` - `file_name` - `first_where` - `flatmap_over_map_reduce` - `for_where` - `force_try` - `force_unwrapping` - `function_body_length` - `function_default_parameter_at_end` - `function_parameter_count` - `generic_type_name` - `ibinspectable_in_extension` - `identical_operands` - `implicit_getter` - `implicitly_unwrapped_optional` - `inclusive_language` - `inert_defer` - `is_disjoint` - `joined_default_parameter` - `large_tuple` - `last_where` - `legacy_cggeometry_functions` - `legacy_constant` - `legacy_constructor` - `legacy_hashing` - `legacy_multiple` - `legacy_nsgeometry_functions` - `legacy_objc_type` - `legacy_random` - `lower_acl_than_parent` - `multiline_arguments_brackets` - `multiline_parameters` - `multiple_closures_with_trailing_closure` - `no_extension_access_modifier` - `no_fallthrough_only` - `no_space_in_method_call` - `notification_center_detachment` - `nslocalizedstring_key` - `nslocalizedstring_require_bundle` - `nsobject_prefer_isequal` - `number_separator` - `object_literal` - `operator_whitespace` - `optional_enum_case_matching` - `orphaned_doc_comment` - `overridden_super_call` - `override_in_extension` - `pattern_matching_keywords` - `prefer_nimble` - `prefer_self_in_static_references` - `prefer_self_type_over_type_of_self` - `prefer_zero_over_explicit_init` - `prefixed_toplevel_constant` - `private_action` - `private_outlet` - `private_over_fileprivate` - `private_subject` - `private_unit_test` - `prohibited_interface_builder` - `prohibited_super_call` - `protocol_property_accessors_order` - `quick_discouraged_focused_test` - `quick_discouraged_pending_test` - `raw_value_for_camel_cased_codable_enum` - `reduce_boolean` - `reduce_into` - `redundant_discardable_let` - `redundant_nil_coalescing` - `redundant_objc_attribute` - `redundant_optional_initialization` - `redundant_set_access_control` - `redundant_string_enum_value` - `required_deinit` - `required_enum_case` - `return_arrow_whitespace` - `self_in_property_initialization` - `shorthand_operator` - `single_test_class` - `sorted_first_last` - `static_operator` - `strict_fileprivate` - `strong_iboutlet` - `switch_case_alignment` - `switch_case_on_newline` - `test_case_accessibility` - `toggle_bool` - `trailing_comma` - `trailing_semicolon` - `type_body_length` - `type_name` - `unneeded_break_in_switch` - `unneeded_parentheses_in_closure_argument` - `unowned_variable_capture` - `untyped_error_in_catch` - `unused_capture_list` - `unused_closure_parameter` - `unused_control_flow_label` - `unused_enumerated` - `unused_optional_binding` - `unused_setter_value` - `valid_ibinspectable` - `vertical_parameter_alignment` - `weak_delegate` - `xct_specific_matcher` - `xctfail_message` [Marcelo Fabri](https://github.com/marcelofabri) [SimplyDanny](https://github.com/SimplyDanny) [JP Simard](https://github.com/jpsim) [#2915](https://github.com/realm/SwiftLint/issues/2915) * The "body length" family of rules have changed how they calculate body line count to be significantly more correct and intuitive. However, this is likely to require adjustments to your configuration or disable commands to account for the changes. [JP Simard](https://github.com/jpsim) * Add ability to filter rules for `generate-docs` subcommand. [kattouf](https://github.com/kattouf) * Add new `excludes_trivial_init` configuration for `missing_docs` rule to exclude initializers without any parameters. [Marcelo Fabri](https://github.com/marcelofabri) [#4107](https://github.com/realm/SwiftLint/issues/4107) * Add new `ns_number_init_as_function_reference` rule to catch `NSNumber.init` and `NSDecimalNumber.init` being used as function references since it can cause the wrong initializer to be used, causing crashes. See https://github.com/apple/swift/issues/51036 for more info. [Marcelo Fabri](https://github.com/marcelofabri) * Add `accessibility_trait_for_button` rule to warn if a SwiftUI View has a tap gesture added to it without having the button or link accessibility trait. [Ryan Cole](https://github.com/rcole34) * Add methods from SE-0348 to `UnusedDeclarationRule`. [JP Simard](https://github.com/jpsim) * Include the configured `bind_identifier` in `self_binding` violation messages. [JP Simard](https://github.com/jpsim) * The `self_binding` rule now catches shorthand optional bindings (for example `if let self {}`) when using a `bind_identifier` different than `self`. [Marcelo Fabri](https://github.com/marcelofabri) * Add `library_content_provider` file type to `file_types_order` rule to allow `LibraryContentProvider` to be ordered independent from `main_type`. [dahlborn](https://github.com/dahlborn) * Add `test_parent_classes` option to `test_case_accessibility` rule, which allows detection in subclasses of XCTestCase. [Martin Redington](https://github.com/mildm8nnered) [#4200](https://github.com/realm/SwiftLint/issues/4200) * Add a new `shorthand_optional_binding` opt-in rule that triggers in Swift 5.7 when a shadowing optional binding is created in an `if` or `guard` statement. [SimplyDanny](https://github.com/SimplyDanny) [#4202](https://github.com/realm/SwiftLint/issues/4202) * Use SwiftSyntax instead of SourceKit to determine if a file has parser errors before applying corrections. This speeds up corrections significantly when none of the rules use SourceKit. [JP Simard](https://github.com/jpsim) * Add Swift Package Build Tool Plugin with support for Swift Packages and Xcode projects. [Johannes Ebeling](https://github.com/technocidal) [#3679](https://github.com/realm/SwiftLint/issues/3679) [#3840](https://github.com/realm/SwiftLint/issues/3840) * Make `private_unit_test` rule correctable. [SimplyDanny](https://github.com/SimplyDanny) * Disregard whitespace differences in `identical_operands` rule. That is, the rule now also triggers if the left-hand side and the right-hand side of an operation only differ in trivia. [SimplyDanny](https://github.com/SimplyDanny) * Print violations in realtime if `--progress` and `--output` are both set. [JP Simard](https://github.com/jpsim) * Trigger `prefer_self_in_static_references` rule on more type references like: * Key paths (e.g. `\MyType.myVar` -> `\Self.myVar`) * Computed properties (e.g. `var i: Int { MyType.myVar )` -> `var i: Int { Self.myVar }`) * Constructor calls (e.g. `MyType()` -> `Self()`) [SimplyDanny](https://github.com/SimplyDanny) * Update `for_where` rule, adding a new configuration `allow_for_as_filter` to allow using `for in` with a single `if` inside when there's a `return` statement inside the `if`'s body. [Marcelo Fabri](https://github.com/marcelofabri) [#4040](https://github.com/realm/SwiftLint/issues/4040) * `quick_discouraged_call`, `quick_discouraged_focused_test` and `quick_discouraged_pending_test` rules now trigger on subclasses of `QuickSpec`. [Marcelo Fabri](https://github.com/marcelofabri) [#4420](https://github.com/realm/SwiftLint/issues/4420) * The `type_name` rule now validates protocol declarations by default. You can opt-out by using the `validate_protocols` key in your configuration: ```yml type_name: validate_protocols: false ``` [Marcelo Fabri](https://github.com/marcelofabri) [#4430](https://github.com/realm/SwiftLint/issues/4430) * Report how much memory was used when `--benchmark` is specified. [JP Simard](https://github.com/jpsim) * Adds `NSError` to the list of types in `discouraged_direct_init`. [jszumski](https://github.com/jszumski) [#4508](https://github.com/realm/SwiftLint/issues/4508) * Fix SwiftLint support on Xcode Cloud. [JagCesar](https://github.com/JagCesar) [westerlund](https://github.com/westerlund) [#4484](https://github.com/realm/SwiftLint/issues/4484) * Add `no_magic_numbers` rule to avoid "Magic Numbers". [Henrik Storch](https://github.com/thisisthefoxe) [#4031](https://github.com/realm/SwiftLint/issues/4024) * Add new option `only_enforce_before_trivial_lines` to `vertical_whitespace_closing_braces` rule. It restricts the rule to apply only before trivial lines (containing only closing braces, brackets and parentheses). This allows empty lines before non-trivial lines of code (e.g. if-else-statements). [benjamin-kramer](https://github.com/benjamin-kramer) [#3940](https://github.com/realm/SwiftLint/issues/3940) #### Bug Fixes * Respect `validates_start_with_lowercase` option when linting function names. [Chris Brakebill](https://github.com/braker1nine) [#2708](https://github.com/realm/SwiftLint/issues/2708) * Do not report variables annotated with `@NSApplicationDelegateAdaptor` and `@WKExtensionDelegateAdaptor` in `weak_delegate` rule. [Till Hainbach](https://github.com/tillhainbach) [#3598](https://github.com/realm/SwiftLint/issues/3456) [#3611](https://github.com/realm/SwiftLint/issues/3611) * Fix false-positives related to the `willMove` lifecycle method in `type_contents_order` rule. [SimplyDanny](https://github.com/SimplyDanny) [#3478](https://github.com/realm/SwiftLint/issues/3478) * Do no longer autocorrect usage of `NSIntersectionRect` in `legacy_nsgeometry_functions` rule. [SimplyDanny](https://github.com/SimplyDanny) [#3703](https://github.com/realm/SwiftLint/issues/3703) * Fix Analyzer rules in Xcode 14. [SimplyDanny](https://github.com/SimplyDanny) [#4208](https://github.com/realm/SwiftLint/issues/4208) * Add column for SourceKit usage to `rules` command. [JP Simard](https://github.com/jpsim) * Make `nsobject_prefer_isequal` rule work for nested `@objc` classes. Also consider the `@objcMembers` annotation. [SimplyDanny](https://github.com/SimplyDanny) * Print fixed content at most once to STDOUT. [SimplyDanny](https://github.com/SimplyDanny) [#4211](https://github.com/realm/SwiftLint/issues/4211) * Fix fatal error when content given via STDIN is corrected in the `trailing_newline` rule. [SimplyDanny](https://github.com/SimplyDanny) [#4234](https://github.com/realm/SwiftLint/issues/4234) * Fix false-positives from `multiline_arguments_brackets` when a function call has a single line trailing closure. [CraigSiemens](https://github.com/CraigSiemens) [#4510](https://github.com/realm/SwiftLint/issues/4510) --- ### Using Bazel Put this in your `WORKSPACE`: <details> <summary>WORKSPACE</summary> ```python load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "build_bazel_rules_apple", sha256 = "f94e6dddf74739ef5cb30f000e13a2a613f6ebfa5e63588305a71fce8a8a9911", url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.3/rules_apple.1.1.3.tar.gz", ) load( "@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies", ) apple_rules_dependencies() load( "@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies", ) swift_rules_dependencies() load( "@build_bazel_rules_swift//swift:extras.bzl", "swift_rules_extra_dependencies", ) swift_rules_extra_dependencies() http_archive( name = "SwiftLint", sha256 = "c99be76ea5efd6ff7e60b6df8a11b709d50c75dfdbd6fb429de9bbe9e45cdb1f", url = "https://github.com/realm/SwiftLint/releases/download/0.50.0/bazel.tar.gz", ) load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos") swiftlint_repos() load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps") swiftlint_deps() ``` </details> Then you can run SwiftLint in the current directory with this command: ```console bazel run @SwiftLint//:swiftlint -- --help ```
0.50.0-rc.4: Artisanal Clothes Pegs
4 weeks ago
This is a prerelease version. It won't be published to Homebrew or CocoaPods. But there are many other ways to install: * Downloading the attached `SwiftLint.pkg` installer and launching it * Downloading the attached `portable_swiftlint.zip` archive, extracting it and moving the binary from `portable_swiftlint/swiftlint` to `/usr/local/bin` or elsewhere in your `PATH` * Using [Mint](https://github.com/yonaskolb/Mint): `mint install realm/[email protected]` * Cloning and building from source: `git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.50.0-rc.4 && make install` * Docker: ```docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.4``` * Bazel: See instructions at the bottom Changes from 0.49.1: https://github.com/realm/SwiftLint/compare/0.49.1...0.50.0-rc.4 Changes from 0.50.0-rc.3: https://github.com/realm/SwiftLint/compare/0.50.0-rc.3...0.50.0-rc.4 --- #### Breaking * SwiftLint now requires Swift 5.7 or higher to build. [JP Simard](https://github.com/jpsim) * Exclude `weak_delegate` rule from autocorrection due to behavioral changes leading to potential undefined behavior or bugs. [SimplyDanny](https://github.com/SimplyDanny) [#3577](https://github.com/realm/SwiftLint/issues/3577) * The `anyobject_protocol` rule is now deprecated and will be completely removed in a future release because it is now handled by the Swift compiler. [JP Simard](https://github.com/jpsim) #### Experimental * None. #### Enhancements * Adds `NSError` to the list of types in `discouraged_direct_init`. [jszumski](https://github.com/jszumski) [#4508](https://github.com/realm/SwiftLint/issues/4508) * Fix SwiftLint support on Xcode Cloud. [JagCesar](https://github.com/JagCesar) [westerlund](https://github.com/westerlund) [#4484](https://github.com/realm/SwiftLint/issues/4484) * Add `no_magic_numbers` rule to avoid "Magic Numbers". [Henrik Storch](https://github.com/thisisthefoxe) [#4031](https://github.com/realm/SwiftLint/issues/4024) * SwiftSyntax libraries have been updated from the previous 5.6 release and now use the new parser written in Swift. Swift 5.7+ features should now be parsed more accurately. We've also measured an improvement in lint times of up to 15%. This should also fix some deployment issues where the exact version of the internal SwiftSyntax parser needed to be available. If you notice any unexpected changes to lint results, please file an issue on the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax parser regression we can re-file it upstream. [JP Simard](https://github.com/jpsim) [#4031](https://github.com/realm/SwiftLint/issues/4031) * Add ability to filter rules for `generate-docs` subcommand. [kattouf](https://github.com/kattouf) * Add new `excludes_trivial_init` configuration for `missing_docs` rule to exclude initializers without any parameters. [Marcelo Fabri](https://github.com/marcelofabri) [#4107](https://github.com/realm/SwiftLint/issues/4107) * Add new `ns_number_init_as_function_reference` rule to catch `NSNumber.init` and `NSDecimalNumber.init` being used as function references since it can cause the wrong initializer to be used, causing crashes. See https://github.com/apple/swift/issues/51036 for more info. [Marcelo Fabri](https://github.com/marcelofabri) * Rewrite some rules with SwiftSyntax, fixing some false positives and catching more violations: - `anonymous_argument_in_multiline_closure` - `array_init` - `attributes` - `block_based_kvo` - `class_delegate_protocol` - `closing_brace` - `closure_body_length` - `closure_parameter_position` - `collection_alignment` - `comment_spacing` - `computed_accessors_order` - `conditional_returns_on_newline` - `contains_over_filter_count` - `contains_over_filter_is_empty` - `contains_over_first_not_nil` - `contains_over_range_nil_comparison` - `convenience_type` - `deployment_target` - `discarded_notification_center_observer` - `discouraged_assert` - `discouraged_direct_init` - `discouraged_none_name` - `discouraged_object_literal` - `discouraged_optional_boolean` - `duplicate_enum_cases` - `duplicated_key_in_dictionary_literal` - `dynamic_inline` - `empty_collection_literal` - `empty_count` - `empty_enum_arguments` - `empty_parameters` - `empty_parentheses_with_trailing_closure` - `empty_string` - `enum_case_associated_values_count` - `explicit_enum_raw_value` - `explicit_init` - `explicit_top_level_acl` - `fallthrough` - `file_name` - `first_where` - `flatmap_over_map_reduce` - `for_where` - `force_try` - `force_unwrapping` - `function_body_length` - `function_default_parameter_at_end` - `function_parameter_count` - `generic_type_name` - `ibinspectable_in_extension` - `identical_operands` - `implicit_getter` - `implicitly_unwrapped_optional` - `inclusive_language` - `inert_defer` - `is_disjoint` - `joined_default_parameter` - `large_tuple` - `last_where` - `legacy_cggeometry_functions` - `legacy_constant` - `legacy_constructor` - `legacy_hashing` - `legacy_multiple` - `legacy_nsgeometry_functions` - `legacy_objc_type` - `legacy_random` - `lower_acl_than_parent` - `multiline_arguments_brackets` - `multiline_parameters` - `multiple_closures_with_trailing_closure` - `no_extension_access_modifier` - `no_fallthrough_only` - `no_space_in_method_call` - `notification_center_detachment` - `nslocalizedstring_require_bundle` - `nsobject_prefer_isequal` - `number_separator` - `operator_whitespace` - `optional_enum_case_matching` - `orphaned_doc_comment` - `overridden_super_call` - `override_in_extension` - `prefer_nimble` - `prefer_self_type_over_type_of_self` - `prefer_zero_over_explicit_init` - `prefixed_toplevel_constant` - `private_action` - `private_outlet` - `private_over_fileprivate` - `private_subject` - `private_unit_test` - `prohibited_interface_builder` - `prohibited_super_call` - `protocol_property_accessors_order` - `quick_discouraged_focused_test` - `quick_discouraged_pending_test` - `raw_value_for_camel_cased_codable_enum` - `reduce_boolean` - `reduce_into` - `redundant_discardable_let` - `redundant_nil_coalescing` - `redundant_objc_attribute` - `redundant_optional_initialization` - `redundant_set_access_control` - `redundant_string_enum_value` - `required_deinit` - `return_arrow_whitespace` - `self_in_property_initialization` - `shorthand_operator` - `single_test_class` - `sorted_first_last` - `static_operator` - `strict_fileprivate` - `strong_iboutlet` - `switch_case_alignment` - `switch_case_on_newline` - `test_case_accessibility` - `toggle_bool` - `trailing_comma` - `trailing_semicolon` - `type_body_length` - `type_name` - `unneeded_break_in_switch` - `unneeded_parentheses_in_closure_argument` - `unowned_variable_capture` - `untyped_error_in_catch` - `unused_capture_list` - `unused_closure_parameter` - `unused_control_flow_label` - `unused_enumerated` - `unused_optional_binding` - `unused_setter_value` - `valid_ibinspectable` - `vertical_parameter_alignment` - `weak_delegate` - `xct_specific_matcher` - `xctfail_message` [Marcelo Fabri](https://github.com/marcelofabri) [SimplyDanny](https://github.com/SimplyDanny) [JP Simard](https://github.com/jpsim) [#2915](https://github.com/realm/SwiftLint/issues/2915) * The "body length" family of rules have changed how they calculate body line count to be significantly more correct and intuitive. However, this is likely to require adjustments to your configuration or disable commands to account for the changes. [JP Simard](https://github.com/jpsim) * Add `accessibility_trait_for_button` rule to warn if a SwiftUI View has a tap gesture added to it without having the button or link accessibility trait. [Ryan Cole](https://github.com/rcole34) * Add methods from SE-0348 to `UnusedDeclarationRule`. [JP Simard](https://github.com/jpsim) * Include the configured `bind_identifier` in `self_binding` violation messages. [JP Simard](https://github.com/jpsim) * Add `library_content_provider` file type to `file_types_order` rule to allow `LibraryContentProvider` to be ordered independent from `main_type`. [dahlborn](https://github.com/dahlborn) * Add `test_parent_classes` option to `test_case_accessibility` rule, which allows detection in subclasses of XCTestCase. [Martin Redington](https://github.com/mildm8nnered) [#4200](https://github.com/realm/SwiftLint/issues/4200) * Add a new `shorthand_optional_binding` opt-in rule that triggers in Swift 5.7 when a shadowing optional binding is created in an `if` or `guard` statement. [SimplyDanny](https://github.com/SimplyDanny) [#4202](https://github.com/realm/SwiftLint/issues/4202) * Use SwiftSyntax instead of SourceKit to determine if a file has parser errors before applying corrections. This speeds up corrections significantly when none of the rules use SourceKit. [JP Simard](https://github.com/jpsim) * Add Swift Package Build Tool Plugin with support for Swift Packages and Xcode projects. [Johannes Ebeling](https://github.com/technocidal) [#3679](https://github.com/realm/SwiftLint/issues/3679) [#3840](https://github.com/realm/SwiftLint/issues/3840) * Make `private_unit_test` rule correctable. [SimplyDanny](https://github.com/SimplyDanny) * Disregard whitespace differences in `identical_operands` rule. That is, the rule now also triggers if the left-hand side and the right-hand side of an operation only differ in trivia. [SimplyDanny](https://github.com/SimplyDanny) * Print violations in realtime if `--progress` and `--output` are both set. [JP Simard](https://github.com/jpsim) * Update `for_where` rule, adding a new configuration `allow_for_as_filter` to allow using `for in` with a single `if` inside when there's a `return` statement inside the `if`'s body. [Marcelo Fabri](https://github.com/marcelofabri) [#4040](https://github.com/realm/SwiftLint/issues/4040) * `quick_discouraged_call`, `quick_discouraged_focused_test` and `quick_discouraged_pending_test` rules now trigger on subclasses of `QuickSpec`. [Marcelo Fabri](https://github.com/marcelofabri) [#4420](https://github.com/realm/SwiftLint/issues/4420) * The `type_name` rule now validates protocol declarations by default. You can opt-out by using the `validate_protocols` key in your configuration: ```yml type_name: validate_protocols: false ``` [Marcelo Fabri](https://github.com/marcelofabri) [#4430](https://github.com/realm/SwiftLint/issues/4430) * Report how much memory was used when `--benchmark` is specified. [JP Simard](https://github.com/jpsim) #### Bug Fixes * Respect `validates_start_with_lowercase` option when linting function names. [Chris Brakebill](https://github.com/braker1nine) [#2708](https://github.com/realm/SwiftLint/issues/2708) * Do not report variables annotated with `@NSApplicationDelegateAdaptor` and `@WKExtensionDelegateAdaptor` in `weak_delegate` rule. [Till Hainbach](https://github.com/tillhainbach) [#3598](https://github.com/realm/SwiftLint/issues/3456) [#3611](https://github.com/realm/SwiftLint/issues/3611) * Fix false-positives related to the `willMove` lifecycle method in `type_contents_order` rule. [SimplyDanny](https://github.com/SimplyDanny) [#3478](https://github.com/realm/SwiftLint/issues/3478) * Do no longer autocorrect usage of `NSIntersectionRect` in `legacy_nsgeometry_functions` rule. [SimplyDanny](https://github.com/SimplyDanny) [#3703](https://github.com/realm/SwiftLint/issues/3703) * Fix Analyzer rules in Xcode 14. [SimplyDanny](https://github.com/SimplyDanny) [#4208](https://github.com/realm/SwiftLint/issues/4208) * Add column for SourceKit usage to `rules` command. [JP Simard](https://github.com/jpsim) * Make `nsobject_prefer_isequal` rule work for nested `@objc` classes. Also consider the `@objcMembers` annotation. [SimplyDanny](https://github.com/SimplyDanny) * Print fixed content at most once to STDOUT. [SimplyDanny](https://github.com/SimplyDanny) [#4211](https://github.com/realm/SwiftLint/issues/4211) * Fix fatal error when content given via STDIN is corrected in the `trailing_newline` rule. [SimplyDanny](https://github.com/SimplyDanny) [#4234](https://github.com/realm/SwiftLint/issues/4234) * Fix false-positives from `multiline_arguments_brackets` when a function call has a single line trailing closure. [CraigSiemens](https://github.com/CraigSiemens) [#4510](https://github.com/realm/SwiftLint/issues/4510) --- ### Using Bazel Put this in your `WORKSPACE`: <details> <summary>WORKSPACE</summary> ```python load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "build_bazel_rules_apple", sha256 = "90e3b5e8ff942be134e64a83499974203ea64797fd620eddeb71b3a8e1bff681", url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.2/rules_apple.1.1.2.tar.gz", ) load( "@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies", ) apple_rules_dependencies() load( "@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies", ) swift_rules_dependencies() load( "@build_bazel_rules_swift//swift:extras.bzl", "swift_rules_extra_dependencies", ) swift_rules_extra_dependencies() http_archive( name = "SwiftLint", sha256 = "ef49a8c0dcb70fb5befe549b016735deef72e1ac9f68562b288f23e496c164af", url = "https://github.com/realm/SwiftLint/releases/download/0.50.0-rc.4/bazel.tar.gz", ) load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos") swiftlint_repos() load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps") swiftlint_deps() ``` </details> Then you can run SwiftLint in the current directory with this command: ```console bazel run @SwiftLint//:swiftlint -- --help ```
0.50.0-rc.3: Artisanal Clothes Pegs
5 weeks ago
This is a prerelease version. It won't be published to Homebrew or CocoaPods. But there are many other ways to install: * Downloading the attached `SwiftLint.pkg` installer and launching it * Downloading the attached `portable_swiftlint.zip` archive, extracting it and moving the binary from `portable_swiftlint/swiftlint` to `/usr/local/bin` or elsewhere in your `PATH` * Using [Mint](https://github.com/yonaskolb/Mint): `mint install realm/[email protected]` * Cloning and building from source: `git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.50.0-rc.3 && make install` * Docker: ```docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.3``` * Bazel: See instructions at the bottom Changes from 0.49.1: https://github.com/realm/SwiftLint/compare/0.49.1...0.50.0-rc.3 Changes from 0.50.0-rc.2: https://github.com/realm/SwiftLint/compare/0.50.0-rc.2...0.50.0-rc.3 --- #### Breaking * SwiftLint now requires Swift 5.7 or higher to build. [JP Simard](https://github.com/jpsim) * Exclude `weak_delegate` rule from autocorrection due to behavioral changes leading to potential undefined behavior or bugs. [SimplyDanny](https://github.com/SimplyDanny) [#3577](https://github.com/realm/SwiftLint/issues/3577) * The `anyobject_protocol` rule is now deprecated and will be completely removed in a future release because it is now handled by the Swift compiler. [JP Simard](https://github.com/jpsim) #### Experimental * None. #### Enhancements * SwiftSyntax libraries have been updated from the previous 5.6 release and now use the new parser written in Swift. Swift 5.7+ features should now be parsed more accurately. We've also measured an improvement in lint times of up to 15%. This should also fix some deployment issues where the exact version of the internal SwiftSyntax parser needed to be available. If you notice any unexpected changes to lint results, please file an issue on the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax parser regression we can re-file it upstream. [JP Simard](https://github.com/jpsim) [#4031](https://github.com/realm/SwiftLint/issues/4031) * Add ability to filter rules for `generate-docs` subcommand. [kattouf](https://github.com/kattouf) * Add new `excludes_trivial_init` configuration for `missing_docs` rule to exclude initializers without any parameters. [Marcelo Fabri](https://github.com/marcelofabri) [#4107](https://github.com/realm/SwiftLint/issues/4107) * Add new `ns_number_init_as_function_reference` rule to catch `NSNumber.init` and `NSDecimalNumber.init` being used as function references since it can cause the wrong initializer to be used, causing crashes. See https://github.com/apple/swift/issues/51036 for more info. [Marcelo Fabri](https://github.com/marcelofabri) * Rewrite some rules with SwiftSyntax, fixing some false positives and catching more violations: - `anonymous_argument_in_multiline_closure` - `array_init` - `attributes` - `block_based_kvo` - `class_delegate_protocol` - `closing_brace` - `closure_body_length` - `closure_parameter_position` - `collection_alignment` - `comment_spacing` - `computed_accessors_order` - `conditional_returns_on_newline` - `contains_over_filter_count` - `contains_over_filter_is_empty` - `contains_over_first_not_nil` - `contains_over_range_nil_comparison` - `convenience_type` - `deployment_target` - `discarded_notification_center_observer` - `discouraged_assert` - `discouraged_direct_init` - `discouraged_none_name` - `discouraged_object_literal` - `discouraged_optional_boolean` - `duplicate_enum_cases` - `duplicated_key_in_dictionary_literal` - `dynamic_inline` - `empty_collection_literal` - `empty_count` - `empty_enum_arguments` - `empty_parameters` - `empty_parentheses_with_trailing_closure` - `empty_string` - `enum_case_associated_values_count` - `explicit_enum_raw_value` - `explicit_init` - `explicit_top_level_acl` - `fallthrough` - `file_name` - `first_where` - `flatmap_over_map_reduce` - `for_where` - `force_try` - `force_unwrapping` - `function_body_length` - `function_default_parameter_at_end` - `function_parameter_count` - `generic_type_name` - `ibinspectable_in_extension` - `identical_operands` - `implicit_getter` - `implicitly_unwrapped_optional` - `inclusive_language` - `inert_defer` - `is_disjoint` - `joined_default_parameter` - `large_tuple` - `last_where` - `legacy_cggeometry_functions` - `legacy_constant` - `legacy_constructor` - `legacy_hashing` - `legacy_multiple` - `legacy_nsgeometry_functions` - `legacy_objc_type` - `legacy_random` - `lower_acl_than_parent` - `multiple_closures_with_trailing_closure` - `multiline_parameters` - `no_extension_access_modifier` - `no_fallthrough_only` - `no_space_in_method_call` - `notification_center_detachment` - `nslocalizedstring_require_bundle` - `nsobject_prefer_isequal` - `number_separator` - `operator_whitespace` - `override_in_extension` - `nsobject_prefer_isequal` - `prefer_nimble` - `prefer_self_type_over_type_of_self` - `prefer_zero_over_explicit_init` - `prefixed_toplevel_constant` - `private_action` - `private_over_fileprivate` - `private_outlet` - `private_unit_test` - `prohibited_interface_builder` - `protocol_property_accessors_order` - `quick_discouraged_focused_test` - `quick_discouraged_pending_test` - `raw_value_for_camel_cased_codable_enum` - `reduce_boolean` - `reduce_into` - `redundant_discardable_let` - `redundant_nil_coalescing` - `redundant_objc_attribute` - `redundant_set_access_control` - `redundant_optional_initialization` - `redundant_string_enum_value` - `required_deinit` - `return_arrow_whitespace` - `self_in_property_initialization` - `shorthand_operator` - `single_test_class` - `sorted_first_last` - `static_operator` - `strict_fileprivate` - `strong_iboutlet` - `switch_case_alignment` - `switch_case_on_newline` - `test_case_accessibility` - `toggle_bool` - `trailing_comma` - `trailing_semicolon` - `type_body_length` - `type_name` - `unneeded_break_in_switch` - `unneeded_parentheses_in_closure_argument` - `unowned_variable_capture` - `untyped_error_in_catch` - `unused_capture_list` - `unused_closure_parameter` - `unused_control_flow_label` - `unused_enumerated` - `unused_optional_binding` - `unused_setter_value` - `valid_ibinspectable` - `vertical_parameter_alignment` - `weak_delegate` - `xct_specific_matcher` - `xctfail_message` [Marcelo Fabri](https://github.com/marcelofabri) [SimplyDanny](https://github.com/SimplyDanny) [JP Simard](https://github.com/jpsim) [#2915](https://github.com/realm/SwiftLint/issues/2915) * The "body length" family of rules have changed how they calculate body line count to be significantly more correct and intuitive. However, this is likely to require adjustments to your configuration or disable commands to account for the changes. [JP Simard](https://github.com/jpsim) * Add `accessibility_trait_for_button` rule to warn if a SwiftUI View has a tap gesture added to it without having the button or link accessibility trait. [Ryan Cole](https://github.com/rcole34) * Add methods from SE-0348 to `UnusedDeclarationRule`. [JP Simard](https://github.com/jpsim) * Include the configured `bind_identifier` in `self_binding` violation messages. [JP Simard](https://github.com/jpsim) * Add `library_content_provider` file type to `file_types_order` rule to allow `LibraryContentProvider` to be ordered independent from `main_type`. [dahlborn](https://github.com/dahlborn) * Add `test_parent_classes` option to `test_case_accessibility` rule, which allows detection in subclasses of XCTestCase. [Martin Redington](https://github.com/mildm8nnered) [#4200](https://github.com/realm/SwiftLint/issues/4200) * Add a new `shorthand_optional_binding` opt-in rule that triggers in Swift 5.7 when a shadowing optional binding is created in an `if` or `guard` statement. [SimplyDanny](https://github.com/SimplyDanny) [#4202](https://github.com/realm/SwiftLint/issues/4202) * Use SwiftSyntax instead of SourceKit to determine if a file has parser errors before applying corrections. This speeds up corrections significantly when none of the rules use SourceKit. [JP Simard](https://github.com/jpsim) * Add Swift Package Build Tool Plugin with support for Swift Packages and Xcode projects. [Johannes Ebeling](https://github.com/technocidal) [#3679](https://github.com/realm/SwiftLint/issues/3679) [#3840](https://github.com/realm/SwiftLint/issues/3840) * Make `private_unit_test` rule correctable. [SimplyDanny](https://github.com/SimplyDanny) * Disregard whitespace differences in `identical_operands` rule. That is, the rule now also triggers if the left-hand side and the right-hand side of an operation only differ in trivia. [SimplyDanny](https://github.com/SimplyDanny) * Print violations in realtime if `--progress` and `--output` are both set. [JP Simard](https://github.com/jpsim) * Update `for_where` rule, adding a new configuration `allow_for_as_filter` to allow using `for in` with a single `if` inside when there's a `return` statement inside the `if`'s body. [Marcelo Fabri](https://github.com/marcelofabri) [#4040](https://github.com/realm/SwiftLint/issues/4040) * `quick_discouraged_call`, `quick_discouraged_focused_test` and `quick_discouraged_pending_test` rules now trigger on subclasses of `QuickSpec`. [Marcelo Fabri](https://github.com/marcelofabri) [#4420](https://github.com/realm/SwiftLint/issues/4420) * The `type_name` rule now validates protocol declarations by default. You can opt-out by using the `validate_protocols` key in your configuration: ```yml type_name: validate_protocols: false ``` [Marcelo Fabri](https://github.com/marcelofabri) [#4430](https://github.com/realm/SwiftLint/issues/4430) * Report how much memory was used when `--benchmark` is specified. [JP Simard](https://github.com/jpsim) #### Bug Fixes * Respect `validates_start_with_lowercase` option when linting function names. [Chris Brakebill](https://github.com/braker1nine) [#2708](https://github.com/realm/SwiftLint/issues/2708) * Do not report variables annotated with `@NSApplicationDelegateAdaptor` and `@WKExtensionDelegateAdaptor` in `weak_delegate` rule. [Till Hainbach](https://github.com/tillhainbach) [#3598](https://github.com/realm/SwiftLint/issues/3456) [#3611](https://github.com/realm/SwiftLint/issues/3611) * Fix false-positives related to the `willMove` lifecycle method in `type_contents_order` rule. [SimplyDanny](https://github.com/SimplyDanny) [#3478](https://github.com/realm/SwiftLint/issues/3478) * Do no longer autocorrect usage of `NSIntersectionRect` in `legacy_nsgeometry_functions` rule. [SimplyDanny](https://github.com/SimplyDanny) [#3703](https://github.com/realm/SwiftLint/issues/3703) * Fix Analyzer rules in Xcode 14. [SimplyDanny](https://github.com/SimplyDanny) [#4208](https://github.com/realm/SwiftLint/issues/4208) * Add column for SourceKit usage to `rules` command. [JP Simard](https://github.com/jpsim) * Make `nsobject_prefer_isequal` rule work for nested `@objc` classes. Also consider the `@objcMembers` annotation. [SimplyDanny](https://github.com/SimplyDanny) * Print fixed content at most once to STDOUT. [SimplyDanny](https://github.com/SimplyDanny) [#4211](https://github.com/realm/SwiftLint/issues/4211) * Fix fatal error when content given via STDIN is corrected in the `trailing_newline` rule. [SimplyDanny](https://github.com/SimplyDanny) [#4234](https://github.com/realm/SwiftLint/issues/4234) --- ### Using Bazel Put this in your `WORKSPACE`: <details> <summary>WORKSPACE</summary> ```python load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "build_bazel_rules_apple", sha256 = "90e3b5e8ff942be134e64a83499974203ea64797fd620eddeb71b3a8e1bff681", url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.2/rules_apple.1.1.2.tar.gz", ) load( "@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies", ) apple_rules_dependencies() load( "@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies", ) swift_rules_dependencies() load( "@build_bazel_rules_swift//swift:extras.bzl", "swift_rules_extra_dependencies", ) swift_rules_extra_dependencies() http_archive( name = "SwiftLint", sha256 = "0cc64b76c801242ba440f83a85d4d54aa11303f1f48094555ddc3a818fbc9858", url = "https://github.com/realm/SwiftLint/releases/download/0.50.0-rc.3/bazel.tar.gz", ) load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos") swiftlint_repos() load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps") swiftlint_deps() ``` </details> Then you can run SwiftLint in the current directory with this command: ```console bazel run @SwiftLint//:swiftlint -- --help ```
0.50.0-rc.2: Artisanal Clothes Pegs
7 weeks ago
This is a prerelease version. It won't be published to Homebrew or CocoaPods. But there are many other ways to install: * Downloading the attached `SwiftLint.pkg` installer and launching it * Downloading the attached `portable_swiftlint.zip` archive, extracting it and moving the binary from `portable_swiftlint/swiftlint` to `/usr/local/bin` or elsewhere in your `PATH` * Using [Mint](https://github.com/yonaskolb/Mint): `mint install realm/[email protected]` * Cloning and building from source: `git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.50.0-rc.2 && make install` * Docker: ```docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.2``` * Bazel: See instructions at the bottom Changes from 0.49.1: https://github.com/realm/SwiftLint/compare/0.49.1...0.50.0-rc.2 Changes from 0.50.0-rc.1: https://github.com/realm/SwiftLint/compare/0.50.0-rc.1...0.50.0-rc.2 --- #### Breaking * SwiftLint now requires Swift 5.7 or higher to build. [JP Simard](https://github.com/jpsim) * Exclude `weak_delegate` rule from autocorrection due to behavioral changes leading to potential undefined behavior or bugs. [SimplyDanny](https://github.com/SimplyDanny) [#3577](https://github.com/realm/SwiftLint/issues/3577) * The `anyobject_protocol` rule is now deprecated and will be completely removed in a future release because it is now handled by the Swift compiler. [JP Simard](https://github.com/jpsim) #### Experimental * None. #### Enhancements * SwiftSyntax libraries have been updated from the previous 5.6 release and now use the new parser written in Swift. Swift 5.7+ features should now be parsed more accurately. We've also measured an improvement in lint times of up to 15%. This should also fix some deployment issues where the exact version of the internal SwiftSyntax parser needed to be available. If you notice any unexpected changes to lint results, please file an issue on the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax parser regression we can re-file it upstream. [JP Simard](https://github.com/jpsim) [#4031](https://github.com/realm/SwiftLint/issues/4031) * Add ability to filter rules for `generate-docs` subcommand. [kattouf](https://github.com/kattouf) * Add new `excludes_trivial_init` configuration for `missing_docs` rule to exclude initializers without any parameters. [Marcelo Fabri](https://github.com/marcelofabri) [#4107](https://github.com/realm/SwiftLint/issues/4107) * Rewrite some rules with SwiftSyntax, fixing some false positives and catching more violations: - `anonymous_argument_in_multiline_closure` - `array_init` - `attributes` - `block_based_kvo` - `class_delegate_protocol` - `closing_brace` - `closure_body_length` - `closure_parameter_position` - `computed_accessors_order` - `conditional_returns_on_newline` - `contains_over_filter_count` - `contains_over_filter_is_empty` - `contains_over_first_not_nil` - `contains_over_range_nil_comparison` - `deployment_target` - `discouraged_assert` - `discouraged_direct_init` - `discouraged_none_name` - `discouraged_object_literal` - `discouraged_optional_boolean` - `duplicate_enum_cases` - `dynamic_inline` - `empty_collection_literal` - `empty_enum_arguments` - `empty_parameters` - `empty_parentheses_with_trailing_closure` - `empty_string` - `enum_case_associated_values_count` - `explicit_enum_raw_value` - `explicit_init` - `fallthrough` - `first_where` - `flatmap_over_map_reduce` - `force_try` - `force_unwrapping` - `function_body_length` - `function_default_parameter_at_end` - `function_parameter_count` - `generic_type_name` - `ibinspectable_in_extension` - `identical_operands` - `implicit_getter` - `implicitly_unwrapped_optional` - `inert_defer` - `is_disjoint` - `large_tuple` - `last_where` - `legacy_cggeometry_functions` - `legacy_constant` - `legacy_constructor` - `legacy_hashing` - `legacy_multiple` - `legacy_nsgeometry_functions` - `legacy_random` - `multiple_closures_with_trailing_closure` - `no_extension_access_modifier` - `no_fallthrough_only` - `no_space_in_method_call` - `nslocalizedstring_require_bundle` - `nsobject_prefer_isequal` - `number_separator` - `operator_whitespace` - `nsobject_prefer_isequal` - `private_action` - `private_over_fileprivate` - `private_outlet` - `private_unit_test` - `prohibited_interface_builder` - `protocol_property_accessors_order` - `quick_discouraged_focused_test` - `quick_discouraged_pending_test` - `reduce_boolean` - `redundant_discardable_let` - `redundant_nil_coalescing` - `redundant_string_enum_value` - `self_in_property_initialization` - `shorthand_operator` - `sorted_first_last` - `static_operator` - `strict_fileprivate` - `strong_iboutlet` - `switch_case_alignment` - `switch_case_on_newline` - `toggle_bool` - `trailing_comma` - `trailing_semicolon` - `type_body_length` - `unneeded_break_in_switch` - `unneeded_parentheses_in_closure_argument` - `unowned_variable_capture` - `untyped_error_in_catch` - `unused_closure_parameter` - `unused_control_flow_label` - `unused_enumerated` - `unused_setter_value` - `valid_ibinspectable` - `weak_delegate` - `xctfail_message` [Marcelo Fabri](https://github.com/marcelofabri) [SimplyDanny](https://github.com/SimplyDanny) [JP Simard](https://github.com/jpsim) [#2915](https://github.com/realm/SwiftLint/issues/2915) * The "body length" family of rules have changed how they calculate body line count to be significantly more correct and intuitive. However, this is likely to require adjustments to your configuration or disable commands to account for the changes. [JP Simard](https://github.com/jpsim) * Add `accessibility_trait_for_button` rule to warn if a SwiftUI View has a tap gesture added to it without having the button or link accessibility trait. [Ryan Cole](https://github.com/rcole34) * Add methods from SE-0348 to `UnusedDeclarationRule`. [JP Simard](https://github.com/jpsim) * Include the configured `bind_identifier` in `self_binding` violation messages. [JP Simard](https://github.com/jpsim) * Add `library_content_provider` file type to `file_types_order` rule to allow `LibraryContentProvider` to be ordered independent from `main_type`. [dahlborn](https://github.com/dahlborn) * Add `test_parent_classes` option to `test_case_accessibility` rule, which allows detection in subclasses of XCTestCase. [Martin Redington](https://github.com/mildm8nnered) [#4200](https://github.com/realm/SwiftLint/issues/4200) * Add a new `shorthand_optional_binding` opt-in rule that triggers in Swift 5.7 when a shadowing optional binding is created in an `if` or `guard` statement. [SimplyDanny](https://github.com/SimplyDanny) [#4202](https://github.com/realm/SwiftLint/issues/4202) * Use SwiftSyntax instead of SourceKit to determine if a file has parser errors before applying corrections. This speeds up corrections significantly when none of the rules use SourceKit. [JP Simard](https://github.com/jpsim) * Add Swift Package Build Tool Plugin with support for Swift Packages and Xcode projects. [Johannes Ebeling](https://github.com/technocidal) [#3679](https://github.com/realm/SwiftLint/issues/3679) [#3840](https://github.com/realm/SwiftLint/issues/3840) * Make `private_unit_test` rule correctable. [SimplyDanny](https://github.com/SimplyDanny) * Disregard whitespace differences in `identical_operands` rule. That is, the rule now also triggers if the left-hand side and the right-hand side of an operation only differ in trivia. [SimplyDanny](https://github.com/SimplyDanny) * Print violations in realtime if `--progress` and `--output` are both set. [JP Simard](https://github.com/jpsim) #### Bug Fixes * Respect `validates_start_with_lowercase` option when linting function names. [Chris Brakebill](https://github.com/braker1nine) [#2708](https://github.com/realm/SwiftLint/issues/2708) * Do not report variables annotated with `@NSApplicationDelegateAdaptor` and `@WKExtensionDelegateAdaptor` in `weak_delegate` rule. [Till Hainbach](https://github.com/tillhainbach) [#3598](https://github.com/realm/SwiftLint/issues/3456) [#3611](https://github.com/realm/SwiftLint/issues/3611) * Fix false-positives related to the `willMove` lifecycle method in `type_contents_order` rule. [SimplyDanny](https://github.com/SimplyDanny) [#3478](https://github.com/realm/SwiftLint/issues/3478) * Do no longer autocorrect usage of `NSIntersectionRect` in `legacy_nsgeometry_functions` rule. [SimplyDanny](https://github.com/SimplyDanny) [#3703](https://github.com/realm/SwiftLint/issues/3703) * Fix Analyzer rules in Xcode 14. [SimplyDanny](https://github.com/SimplyDanny) [#4208](https://github.com/realm/SwiftLint/issues/4208) * Add column for SourceKit usage to `rules` command. [JP Simard](https://github.com/jpsim) * Make `nsobject_prefer_isequal` rule work for nested `@objc` classes. Also consider the `@objcMembers` annotation. [SimplyDanny](https://github.com/SimplyDanny) * Print fixed content at most once to STDOUT. [SimplyDanny](https://github.com/SimplyDanny) [#4211](https://github.com/realm/SwiftLint/issues/4211) * Fix fatal error when content given via STDIN is corrected in the `trailing_newline` rule. [SimplyDanny](https://github.com/SimplyDanny) [#4234](https://github.com/realm/SwiftLint/issues/4234) --- ### Using Bazel Put this in your `WORKSPACE`: <details> <summary>WORKSPACE</summary> ```python load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "build_bazel_rules_apple", sha256 = "90e3b5e8ff942be134e64a83499974203ea64797fd620eddeb71b3a8e1bff681", url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.2/rules_apple.1.1.2.tar.gz", ) load( "@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies", ) apple_rules_dependencies() load( "@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies", ) swift_rules_dependencies() load( "@build_bazel_rules_swift//swift:extras.bzl", "swift_rules_extra_dependencies", ) swift_rules_extra_dependencies() http_archive( name = "SwiftLint", sha256 = "973587995aab45ac56b963c1768a830a6a66580ccea4d5bf81617106b22bfa3f", url = "https://github.com/realm/SwiftLint/releases/download/0.50.0-rc.2/bazel.tar.gz", ) load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos") swiftlint_repos() load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps") swiftlint_deps() ``` </details> Then you can run SwiftLint in the current directory with this command: ```console bazel run @SwiftLint//:swiftlint -- --help ```
0.50.0-rc.1: Artisanal Clothes Pegs
8 weeks ago
This is a prerelease version. It won't be published to Homebrew or CocoaPods. But there are many other ways to install: * Downloading the attached `SwiftLint.pkg` installer and launching it * Downloading the attached `portable_swiftlint.zip` archive, extracting it and moving the binary from `portable_swiftlint/swiftlint` to `/usr/local/bin` or elsewhere in your `PATH` * Using [Mint](https://github.com/yonaskolb/Mint): `mint install realm/[email protected]` * Cloning and building from source: `git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.50.0-rc.1 && make install` * Docker: ```docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.50.0-rc.1``` * Bazel: See instructions at the bottom Changes from 0.49.1: https://github.com/realm/SwiftLint/compare/0.49.1...0.50.0-rc.1 --- #### Breaking * SwiftLint now requires Swift 5.7 or higher to build. [JP Simard](https://github.com/jpsim) * Exclude `weak_delegate` rule from autocorrection due to behavioral changes leading to potential undefined behavior or bugs. [SimplyDanny](https://github.com/SimplyDanny) [#3577](https://github.com/realm/SwiftLint/issues/3577) * The `anyobject_protocol` rule is now deprecated and will be completely removed in a future release because it is now handled by the Swift compiler. [JP Simard](https://github.com/jpsim) #### Experimental * None. #### Enhancements * SwiftSyntax libraries have been updated from the previous 5.6 release and now use the new parser written in Swift. Swift 5.7+ features should now be parsed more accurately. We've also measured an improvement in lint times of up to 15%. This should also fix some deployment issues where the exact version of the internal SwiftSyntax parser needed to be available. If you notice any unexpected changes to lint results, please file an issue on the SwiftLint issue tracker. We can look into it and if it's a SwiftSyntax parser regression we can re-file it upstream. [JP Simard](https://github.com/jpsim) [#4031](https://github.com/realm/SwiftLint/issues/4031) * Add ability to filter rules for `generate-docs` subcommand. [kattouf](https://github.com/kattouf) * Add new `excludes_trivial_init` configuration for `missing_docs` rule to exclude initializers without any parameters. [Marcelo Fabri](https://github.com/marcelofabri) [#4107](https://github.com/realm/SwiftLint/issues/4107) * Rewrite some rules with SwiftSyntax, fixing some false positives and catching more violations: - `anonymous_argument_in_multiline_closure` - `array_init` - `block_based_kvo` - `class_delegate_protocol` - `closing_brace` - `closure_parameter_position` - `computed_accessors_order` - `contains_over_filter_count` - `contains_over_range_nil_comparison` - `deployment_target` - `discouraged_object_literal` - `discouraged_optional_boolean` - `duplicate_enum_cases` - `dynamic_inline` - `empty_collection_literal` - `empty_enum_arguments` - `empty_parameters` - `empty_parentheses_with_trailing_closure` - `empty_string` - `explicit_init` - `fallthrough` - `flatmap_over_map_reduce` - `force_try` - `force_unwrapping` - `generic_type_name` - `ibinspectable_in_extension` - `implicit_getter` - `inert_defer` - `large_tuple` - `legacy_cggeometry_functions` - `legacy_constant` - `legacy_nsgeometry_functions` - `multiple_closures_with_trailing_closure` - `no_extension_access_modifier` - `no_fallthrough_only` - `no_space_in_method_call` - `nsobject_prefer_isequal` - `private_action` - `private_outlet` - `private_unit_test` - `protocol_property_accessors_order` - `redundant_nil_coalescing` - `redundant_string_enum_value` - `strong_iboutlet` - `switch_case_on_newline` - `toggle_bool` - `trailing_semicolon` - `unneeded_break_in_switch` - `unneeded_parentheses_in_closure_argument` - `unowned_variable_capture` - `untyped_error_in_catch` - `xctfail_message` [Marcelo Fabri](https://github.com/marcelofabri) [SimplyDanny](https://github.com/SimplyDanny) [JP Simard](https://github.com/jpsim) [#2915](https://github.com/realm/SwiftLint/issues/2915) * Add `accessibility_trait_for_button` rule to warn if a SwiftUI View has a tap gesture added to it without having the button or link accessibility trait. [Ryan Cole](https://github.com/rcole34) * Add methods from SE-0348 to `UnusedDeclarationRule`. [JP Simard](https://github.com/jpsim) * Include the configured `bind_identifier` in `self_binding` violation messages. [JP Simard](https://github.com/jpsim) * Add `library_content_provider` file type to `file_types_order` rule to allow `LibraryContentProvider` to be ordered independent from `main_type`. [dahlborn](https://github.com/dahlborn) * Add `test_parent_classes` option to `test_case_accessibility` rule, which allows detection in subclasses of XCTestCase. [Martin Redington](https://github.com/mildm8nnered) [#4200](https://github.com/realm/SwiftLint/issues/4200) * Add a new `if_let_shadowing` opt-in rule that triggers in Swift 5.7 when a shadowing optional binding is created in an if- or guard-statement. [SimplyDanny](https://github.com/SimplyDanny) [#4202](https://github.com/realm/SwiftLint/issues/4202) * Use SwiftSyntax instead of SourceKit to determine if a file has parser errors before applying corrections. This speeds up corrections significantly when none of the rules use SourceKit. [JP Simard](https://github.com/jpsim) * Add Swift Package Build Tool Plugin with support for Swift Packages and Xcode projects. [Johannes Ebeling](https://github.com/technocidal) [#3679](https://github.com/realm/SwiftLint/issues/3679) [#3840](https://github.com/realm/SwiftLint/issues/3840) * Make `private_unit_test` rule correctable. [SimplyDanny](https://github.com/SimplyDanny) #### Bug Fixes * Respect `validates_start_with_lowercase` option when linting function names. [Chris Brakebill](https://github.com/braker1nine) [#2708](https://github.com/realm/SwiftLint/issues/2708) * Do not report variables annotated with `@NSApplicationDelegateAdaptor` and `@WKExtensionDelegateAdaptor` in `weak_delegate` rule. [Till Hainbach](https://github.com/tillhainbach) [#3598](https://github.com/realm/SwiftLint/issues/3456) [#3611](https://github.com/realm/SwiftLint/issues/3611) * Fix false-positives related to the `willMove` lifecycle method in `type_contents_order` rule. [SimplyDanny](https://github.com/SimplyDanny) [#3478](https://github.com/realm/SwiftLint/issues/3478) * Do no longer autocorrect usage of `NSIntersectionRect` in `legacy_nsgeometry_functions` rule. [SimplyDanny](https://github.com/SimplyDanny) [#3703](https://github.com/realm/SwiftLint/issues/3703) * Fix Analyzer rules in Xcode 14. [SimplyDanny](https://github.com/SimplyDanny) [#4208](https://github.com/realm/SwiftLint/issues/4208) * Add column for SourceKit usage to `rules` command. [JP Simard](https://github.com/jpsim) --- ### Using Bazel Put this in your `WORKSPACE`: <details> <summary>WORKSPACE</summary> ```python load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "build_bazel_rules_apple", sha256 = "90e3b5e8ff942be134e64a83499974203ea64797fd620eddeb71b3a8e1bff681", url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.2/rules_apple.1.1.2.tar.gz", ) load( "@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies", ) apple_rules_dependencies() load( "@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies", ) swift_rules_dependencies() load( "@build_bazel_rules_swift//swift:extras.bzl", "swift_rules_extra_dependencies", ) swift_rules_extra_dependencies() http_archive( name = "SwiftLint", sha256 = "ee13554c48ca7845513ae307863525afbb5b8f22d4c3b34b5b2e87311c3d5e26", url = "https://github.com/realm/SwiftLint/releases/download/0.50.0-rc.1/bazel.tar.gz", ) load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos") swiftlint_repos() load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps") swiftlint_deps() ``` </details> Then you can run SwiftLint in the current directory with this command: ```console bazel run @SwiftLint//:swiftlint -- --help ```
0.49.1: Buanderie Principale
13 weeks ago
_Note: The default branch for the SwiftLint git repository was renamed from `master` to `main` on September 1st. Please update any code or automation accordingly._ #### Breaking * None. #### Experimental * None. #### Enhancements * Add new `self_binding` opt-in rule to enforce that `self` identifiers are consistently re-bound to a common identifier name. Configure `bind_identifier` to the name you want to use. Defaults to `self`. [JP Simard](https://github.com/jpsim) [#2495](https://github.com/realm/SwiftLint/issues/2495) * Add `--output` option to lint and analyze commands to write to a file instead of to stdout. [JP Simard](https://github.com/jpsim) [#4048](https://github.com/realm/SwiftLint/issues/4048) * Add `--progress` flag to lint and analyze commands to show a live-updating progress bar instead of each file being processed. [JP Simard](https://github.com/jpsim) * `--fix` now works with `--use-stdin`, printing the output to to STDOUT instead of crashing. [SimplyDanny](https://github.com/SimplyDanny) [#4127](https://github.com/realm/SwiftLint/issues/4127) #### Bug Fixes * Migrate `empty_xctest_method` rule to SwiftSyntax fixing some false positives. [SimplyDanny](https://github.com/SimplyDanny) [#3647](https://github.com/realm/SwiftLint/issues/3647) [#3691](https://github.com/realm/SwiftLint/issues/3691) * Fix false positives in `redundant_discardable_let` when using `async let`. [Martin Hosna](https://github.com/mhosna) [#4142](https://github.com/realm/SwiftLint/issues/4142) * Consistently print error/info messages to stderr instead of stdout, which wasn't being done for errors regarding remote configurations. [JP Simard](https://github.com/jpsim) --- ### Using Bazel Put this in your `WORKSPACE`: <details> <summary>WORKSPACE</summary> ```python load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "build_bazel_rules_apple", sha256 = "f003875c248544009c8e8ae03906bbdacb970bc3e5931b40cd76cadeded99632", url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.0/rules_apple.1.1.0.tar.gz", ) load( "@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies", ) apple_rules_dependencies() load( "@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies", ) swift_rules_dependencies() load( "@build_bazel_rules_swift//swift:extras.bzl", "swift_rules_extra_dependencies", ) swift_rules_extra_dependencies() http_archive( name = "SwiftLint", sha256 = "7c454ff4abeeecdd9513f6293238a6d9f803b587eb93de147f9aa1be0d8337c4", url = "https://github.com/realm/SwiftLint/releases/download/0.49.1/bazel.tar.gz", ) load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos") swiftlint_repos() load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps") swiftlint_deps() ``` </details> Then you can run SwiftLint in the current directory with this command: ```console bazel run @SwiftLint//:swiftlint -- --help ```
0.49.0: Asynchronous Defuzzer
14 weeks ago
_Note: The default branch for the SwiftLint git repository will be renamed from `master` to `main` on September 1st. Please update any code or automation accordingly._ #### Breaking * SwiftLint now requires Swift 5.6 or higher to build, and macOS 12 or higher to run. [JP Simard](https://github.com/jpsim) * Code Climate reports now use SHA256 strings as the issue fingerprint values. [JP Simard](https://github.com/jpsim) * Make `comma_inheritance` an opt-in rule. [Steve Madsen](https://github.com/sjmadsen) [#4027](https://github.com/realm/SwiftLint/issues/4027) * The `autocorrect` command that was deprecated in 0.43.0 has now been completely removed. Use `--fix` instead. [JP Simard](https://github.com/jpsim) * Remove the `AutomaticTestableRule` protocol. All examples listed in rules are now tested automatically to make sure they are correct. [SimplyDanny](https://github.com/SimplyDanny) * Deprecate the `--in-process-sourcekit` command line flag. SwiftLint now always uses an in-process SourceKit. [JP Simard](https://github.com/jpsim) #### Experimental * None. #### Enhancements * Make `duplicate_imports` rule correctable. Fix `duplicate_imports` rule reporting redundant violations when more than one duplicate is present. [Timofey Solonin](https://github.com/abdulowork) * Support for building SwiftLint with bazel. [JP Simard](https://github.com/jpsim) * Support for writing custom private native rules when building with bazel. [JP Simard](https://github.com/jpsim) [Keith Smiley](https://github.com/keith) [#3516](https://github.com/realm/SwiftLint/issues/3516) * Make `comma` rule about 10x faster, finding some previously missed cases and fixing some previously wrong corrections. [JP Simard](https://github.com/jpsim) * Make `colon` rule about 7x faster, finding some previously missed cases. [JP Simard](https://github.com/jpsim) * Make `closure_spacing` rule about 9x faster, finding some previously missed cases and fixing some previously wrong corrections. [JP Simard](https://github.com/jpsim) [SimplyDanny](https://github.com/SimplyDanny) [#4090](https://github.com/realm/SwiftLint/issues/4090) * Introduce new configuration option `include_compiler_directives` (`true` by default) for the `indentation_width` rule that allows to ignore compiler directives in the indentation analysis. This is especially useful if one (or a formatter) prefers to have compiler directives always at the very beginning of a line. [SimplyDanny](https://github.com/SimplyDanny) [#4030](https://github.com/realm/SwiftLint/issues/4030) * Enable (recursive) globs in `included` file paths. [sarastro-nl](https://github.com/sarastro-nl) * Custom rules are now broken down per rule instead of in aggregate in `--benchmark`. [JP Simard](https://github.com/jpsim) * The `version` command now has an optional `--verbose` flag that prints out the full version info, notably the build ID, which can be used to determine if two `swiftlint` executables are identical. [JP Simard](https://github.com/jpsim) * Update documentation for `multiline_arguments_brackets` and `multiline_literal_brackets` to make it immediately obvious that common examples will trigger. [chrisjf](https://github.com/chrisjf) [#4060](https://github.com/realm/SwiftLint/issues/4060) * The `--compile-commands` argument can now parse SwiftPM yaml files produced when running `swift build` at `.build/{debug,release}.yaml`. [JP Simard](https://github.com/jpsim) * Add new configuration option `allowed_no_space_operators` to `operator_usage_whitespace` rule. It allows to specify custom operators which shall not be considered by the rule. [imben123](https://github.com/imben123) * Add new protocols to remove some boilerplate involved in writing SwiftSyntax-based rules. [JP Simard](https://github.com/jpsim) #### Bug Fixes * Fix false positive in `self_in_property_initialization` rule when using closures inside `didSet` and other accessors. [Marcelo Fabri](https://github.com/marcelofabri) [#4041](https://github.com/realm/SwiftLint/issues/4041) * Fix false positive in `Duplicated Key in Dictionary Literal Violation` rule when using keys that are generated at runtime with the same source code. [OrEliyahu](https://github.com/OrEliyahu) [#4012](https://github.com/realm/SwiftLint/issues/4012) * Fix false positive in `yoda_condition` rule by basing it on SwiftSyntax. [SimplyDanny](https://github.com/SimplyDanny) [#4081](https://github.com/realm/SwiftLint/issues/4081) * Fix false negatives in `first_where` rule when filtering array of dictionaries with String keys. [KS1019](https://github.com/KS1019) * Fix broken correction for `explicit_init` rule. [KS1019](https://github.com/KS1019) --- ### Using Bazel Put this in your `WORKSPACE`: <details> <summary>WORKSPACE</summary> ```python load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "build_bazel_rules_apple", sha256 = "f003875c248544009c8e8ae03906bbdacb970bc3e5931b40cd76cadeded99632", url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.0/rules_apple.1.1.0.tar.gz", ) load( "@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies", ) apple_rules_dependencies() load( "@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies", ) swift_rules_dependencies() load( "@build_bazel_rules_swift//swift:extras.bzl", "swift_rules_extra_dependencies", ) swift_rules_extra_dependencies() http_archive( name = "SwiftLint", sha256 = "ec566314e9220ff681ddb639d3a0532834f66f7e733f5a59c7390469dcb5bd3e", url = "https://github.com/realm/SwiftLint/releases/download/0.49.0/bazel.tar.gz", ) load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos") swiftlint_repos() load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps") swiftlint_deps() ``` </details> Then you can run SwiftLint in the current directory with this command: ```console bazel run @SwiftLint//:swiftlint -- --help ```
0.49.0-rc.2: Asynchronous Defuzzer
15 weeks ago
This is a prerelease version. It won't be published to Homebrew or CocoaPods. But there are many other ways to install: * Downloading the attached `SwiftLint.pkg` installer and launching it * Downloading the attached `portable_swiftlint.zip` archive, extracting it and moving the binary from `portable_swiftlint/swiftlint` to `/usr/local/bin` or elsewhere in your `PATH` * Using [Mint](https://github.com/yonaskolb/Mint): `mint install realm/[email protected]` * Cloning and building from source: `git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.49.0-rc.2 && make install` * Docker: ```docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.49.0-rc.2``` * Bazel: See instructions at the bottom Changes from 0.48.0: https://github.com/realm/SwiftLint/compare/0.48.0...0.49.0-rc.2 Changes from 0.49.0-rc.1: https://github.com/realm/SwiftLint/compare/0.49.0-rc.1...0.49.0-rc.2 --- _Note: The default branch for the SwiftLint git repository will be renamed from `master` to `main` on September 1st. Please update any code or automation accordingly._ #### Breaking * SwiftLint now requires Swift 5.6 or higher to build, and macOS 12 or higher to run. [JP Simard](https://github.com/jpsim) * Code Climate reports now use SHA256 strings as the issue fingerprint values. [JP Simard](https://github.com/jpsim) * Make `comma_inheritance` an opt-in rule. [Steve Madsen](https://github.com/sjmadsen) [#4027](https://github.com/realm/SwiftLint/issues/4027) * The `autocorrect` command that was deprecated in 0.43.0 has now been completely removed. Use `--fix` instead. [JP Simard](https://github.com/jpsim) * Remove the `AutomaticTestableRule` protocol. All examples listed in rules are now tested automatically to make sure they are correct. [SimplyDanny](https://github.com/SimplyDanny) * Deprecate the `--in-process-sourcekit` command line flag. SwiftLint now always uses an in-process SourceKit. [JP Simard](https://github.com/jpsim) #### Experimental * None. #### Enhancements * Make `duplicate_imports` rule correctable. Fix `duplicate_imports` rule reporting redundant violations when more than one duplicate is present. [Timofey Solonin](https://github.com/abdulowork) * Support for building SwiftLint with bazel. [JP Simard](https://github.com/jpsim) * Support for writing custom private native rules when building with bazel. [JP Simard](https://github.com/jpsim) [Keith Smiley](https://github.com/keith) [#3516](https://github.com/realm/SwiftLint/issues/3516) * Make `comma` rule about 10x faster, finding some previously missed cases and fixing some previously wrong corrections. [JP Simard](https://github.com/jpsim) * Make `colon` rule about 7x faster, finding some previously missed cases. [JP Simard](https://github.com/jpsim) * Make `closure_spacing` rule about 9x faster, finding some previously missed cases and fixing some previously wrong corrections. [JP Simard](https://github.com/jpsim) [SimplyDanny](https://github.com/SimplyDanny) [#4090](https://github.com/realm/SwiftLint/issues/4090) * Introduce new configuration option `include_compiler_directives` (`true` by default) for the `indentation_width` rule that allows to ignore compiler directives in the indentation analysis. This is especially useful if one (or a formatter) prefers to have compiler directives always at the very beginning of a line. [SimplyDanny](https://github.com/SimplyDanny) [#4030](https://github.com/realm/SwiftLint/issues/4030) * Enable (recursive) globs in `included` file paths. [sarastro-nl](https://github.com/sarastro-nl) * Custom rules are now broken down per rule instead of in aggregate in `--benchmark`. [JP Simard](https://github.com/jpsim) * The `version` command now has an optional `--verbose` flag that prints out the full version info, notably the build ID, which can be used to determine if two `swiftlint` executables are identical. [JP Simard](https://github.com/jpsim) * Update documentation for `multiline_arguments_brackets` and `multiline_literal_brackets` to make it immediately obvious that common examples will trigger. [chrisjf](https://github.com/chrisjf) [#4060](https://github.com/realm/SwiftLint/issues/4060) #### Bug Fixes * Fix false positive in `self_in_property_initialization` rule when using closures inside `didSet` and other accessors. [Marcelo Fabri](https://github.com/marcelofabri) [#4041](https://github.com/realm/SwiftLint/issues/4041) * Fix false positive in `Duplicated Key in Dictionary Literal Violation` rule when using keys that are generated at runtime with the same source code. [OrEliyahu](https://github.com/OrEliyahu) [#4012](https://github.com/realm/SwiftLint/issues/4012) * Fix false positive in `yoda_condition` rule by basing it on SwiftSyntax. [SimplyDanny](https://github.com/SimplyDanny) [#4081](https://github.com/realm/SwiftLint/issues/4081) * Fix false negatives in `first_where` rule when filtering array of dictionaries with String keys. [KS1019](https://github.com/KS1019) * Fix broken correction for `explicit_init` rule. [KS1019](https://github.com/KS1019) --- ### Using Bazel Put this in your `WORKSPACE`: <details> <summary>WORKSPACE</summary> ```python load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "build_bazel_rules_apple", sha256 = "36072d4f3614d309d6a703da0dfe48684ec4c65a89611aeb9590b45af7a3e592", url = "https://github.com/bazelbuild/rules_apple/releases/download/1.0.1/rules_apple.1.0.1.tar.gz", ) load( "@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies", ) apple_rules_dependencies() load( "@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies", ) swift_rules_dependencies() load( "@build_bazel_rules_swift//swift:extras.bzl", "swift_rules_extra_dependencies", ) swift_rules_extra_dependencies() http_archive( name = "SwiftLint", sha256 = "d34bf123e6380a7527ee78c5f6ec7ede5e00e8c39a9c3b394f590374f566c57d", url = "https://github.com/realm/SwiftLint/releases/download/0.49.0-rc.2/bazel.tar.gz", ) load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos") swiftlint_repos() load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps") swiftlint_deps() ``` </details> Then you can run SwiftLint in the current directory with this command: ```console bazel run @SwiftLint//:swiftlint -- --help ```
0.49.0-rc.1: Asynchronous Defuzzer
16 weeks ago
This is a prerelease version. It won't be published to Homebrew or CocoaPods. But there are many other ways to install: * Downloading the attached `SwiftLint.pkg` installer and launching it * Downloading the attached `portable_swiftlint.zip` archive, extracting it and moving the binary from `portable_swiftlint/swiftlint` to `/usr/local/bin` or elsewhere in your `PATH` * Using [Mint](https://github.com/yonaskolb/Mint): `mint install realm/[email protected]` * Cloning and building from source: `git clone https://github.com/realm/SwiftLint.git && cd SwiftLint && git checkout 0.49.0-rc.1 && make install` * Docker: ```docker run -it -v `pwd`:`pwd` -w `pwd` ghcr.io/realm/swiftlint:0.49.0-rc.1``` * Bazel: See instructions at the bottom Changes from 0.48.0: https://github.com/realm/SwiftLint/compare/0.48.0...0.49.0-rc.1 --- _Note: The default branch for the SwiftLint git repository will be renamed from `master` to `main` on September 1st. Please update any code or automation accordingly._ #### Breaking * SwiftLint now requires Swift 5.6 or higher to build, and macOS 12 or higher to run. [JP Simard](https://github.com/jpsim) * Code Climate reports now use SHA256 strings as the issue fingerprint values. [JP Simard](https://github.com/jpsim) * Make `comma_inheritance` an opt-in rule. [Steve Madsen](https://github.com/sjmadsen) [#4027](https://github.com/realm/SwiftLint/issues/4027) * The `autocorrect` command that was deprecated in 0.43.0 has now been completely removed. Use `--fix` instead. [JP Simard](https://github.com/jpsim) * Remove the `AutomaticTestableRule` protocol. All examples listed in rules are now tested automatically to make sure they are correct. [SimplyDanny](https://github.com/SimplyDanny) * Deprecate the `--in-process-sourcekit` command line flag. SwiftLint now always uses an in-process SourceKit. [JP Simard](https://github.com/jpsim) #### Experimental * None. #### Enhancements * Make `duplicate_imports` rule correctable. Fix `duplicate_imports` rule reporting redundant violations when more than one duplicate is present. [Timofey Solonin](https://github.com/abdulowork) * Support for building SwiftLint with bazel. [JP Simard](https://github.com/jpsim) * Support for writing custom private native rules when building with bazel. [JP Simard](https://github.com/jpsim) [Keith Smiley](https://github.com/keith) [#3516](https://github.com/realm/SwiftLint/issues/3516) * Make `comma` rule about 10x faster, finding some previously missed cases and fixing some previously wrong corrections. [JP Simard](https://github.com/jpsim) * Make `colon` rule about 7x faster, finding some previously missed cases. [JP Simard](https://github.com/jpsim) * Introduce new configuration option `include_compiler_directives` (`true` by default) for the `indentation_width` rule that allows to ignore compiler directives in the indentation analysis. This is especially useful if one (or a formatter) prefers to have compiler directives always at the very beginning of a line. [SimplyDanny](https://github.com/SimplyDanny) [#4030](https://github.com/realm/SwiftLint/issues/4030) #### Bug Fixes * Fix false positive in `self_in_property_initialization` rule when using closures inside `didSet` and other accessors. [Marcelo Fabri](https://github.com/marcelofabri) [#4041](https://github.com/realm/SwiftLint/issues/4041) * Fix false positive in `Duplicated Key in Dictionary Literal Violation` rule when using keys that are generated at runtime with the same source code. [OrEliyahu](https://github.com/OrEliyahu) [#4012](https://github.com/realm/SwiftLint/issues/4012) --- ### Using Bazel Put this in your `WORKSPACE`: <details> <summary>WORKSPACE</summary> ```python load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "build_bazel_rules_apple", sha256 = "36072d4f3614d309d6a703da0dfe48684ec4c65a89611aeb9590b45af7a3e592", url = "https://github.com/bazelbuild/rules_apple/releases/download/1.0.1/rules_apple.1.0.1.tar.gz", ) load( "@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies", ) apple_rules_dependencies() load( "@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies", ) swift_rules_dependencies() load( "@build_bazel_rules_swift//swift:extras.bzl", "swift_rules_extra_dependencies", ) swift_rules_extra_dependencies() http_archive( name = "SwiftLint", sha256 = "e954f4483f7f4cf523896693ee3505585f6beb0f791e362b42d9bdbb615f051a", url = "https://github.com/realm/SwiftLint/releases/download/0.49.0-rc.1/bazel.tar.gz", ) load("@SwiftLint//bazel:repos.bzl", "swiftlint_repos") swiftlint_repos() load("@SwiftLint//bazel:deps.bzl", "swiftlint_deps") swiftlint_deps() ``` </details> Then you can run SwiftLint in the current directory with this command: ```console bazel run @SwiftLint//:swiftlint -- --help ```
macOS
realm/realm-swift vv5.0.0-beta.1
Realm is a mobile database: a replacement for Core Data & SQLite
⭐️ 15,655
🕓 14 weeks ago
🔖 Release Notes

Releases

The markdown parsing is broken/disabled for release notes. Sorry about that, I'm chasing the source of a crash that's been bringing this website down for the last couple of days.
v10.33.0
4 days ago
### Enhancements * Flexible sync subscription state will change to `SyncSubscriptionState.pending` (`RLMSyncSubscriptionStatePending`) while waiting for the server to have sent all pending history after a bootstrap and before marking a subscription as Complete. ([#5795](https://github.com/realm/realm-core/pull/5795)) * Add custom column names API, which allows to set a different column name in the realm from the one used in your object declaration. ```swift class Person: Object { @Persisted var firstName: String @Persisted var birthDate: Date @Persisted var age: Int override class public func propertiesMapping() -> [String: String] { ["firstName": "first_name", "birthDate": "birth_date"] } } ``` This is very helpful in cases where you want to name a property differently from your `Device Sync` JSON schema. This API is only available for old and modern object declaration syntax on the `RealmSwift` SDK. * Flexible sync bootstraps now apply 1MB of changesets per write transaction rather than applying all of them in a single write transaction. ([Core PR #5999](https://github.com/realm/realm-core/pull/5999)). ### Fixed * Fix a race condition which could result in "operation cancelled" errors being delivered to async open callbacks rather than the actual sync error which caused things to fail ([Core PR #5968](https://github.com/realm/realm-core/pull/5968), since the introduction of async open). * Fix database corruption issues which could happen if an application was terminated at a certain point in the process of comitting a write transaciton. ([Core PR #5993](https://github.com/realm/realm-core/pull/5993), since v10.21.1) * `@AsyncOpen` and `@AutoOpen` would begin and then cancel a second async open operation ([PR #8038](https://github.com/realm/realm-swift/pull/8038), since v10.12.0). * Changing the search text when using the searchable SwiftUI extension would trigger multiple updates on the View for each change ([PR #8038](https://github.com/realm/realm-swift/pull/8038), since v10.19.0). * Changing the filter or search properties of an `@ObservedResults` or `@ObservedSectionedResults` would trigger up to three updates on the View ([PR #8038](https://github.com/realm/realm-swift/pull/8038), since v10.6.0). * Fetching a user's profile while the user logs out would result in an assertion failure. ([Core PR #6017](https://github.com/realm/realm-core/issues/5571), since v10.8.0) ### Compatibility * Realm Studio: 11.0.0 or later. * APIs are backwards compatible with all previous releases in the 10.x.y series. * Carthage release for Swift is built with Xcode 14.1. * CocoaPods: 1.10 or later. * Xcode: 13.1-14.1. ### Internal * Upgraded realm-core from 12.11.0 to 12.13.0
v10.32.3
3 weeks ago
### Fixed * Fix name lookup errors when importing Realm Swift built in library evolution mode (([#8014](https://github.com/realm/realm-swift/issues/8014)). * The prebuilt watchOS library in the objective-c release package was missing an arm64 slice. The Swift release package was uneffected ([PR #8016](https://github.com/realm/realm-swift/pull/8016)). * Fix issue where `RLMUserAPIKey.key`/`UserAPIKey.key` incorrectly returned the name of the API key instead of the key itself. ([#8021](https://github.com/realm/realm-swift/issues/8021), since v10.0.0) ### Compatibility * Realm Studio: 11.0.0 or later. * APIs are backwards compatible with all previous releases in the 10.x.y series. * Carthage release for Swift is built with Xcode 14.1. * CocoaPods: 1.10 or later. * Xcode: 13.1-14.1.
v10.32.2
4 weeks ago
Switch to building the Carthage release with Xcode 14.1. ### Fixed * Fix linker errors when building a release build with Xcode 14.1 when installing via SPM ([#7995](https://github.com/realm/realm-swift/issues/7995)). ### Compatibility * Realm Studio: 11.0.0 or later. * APIs are backwards compatible with all previous releases in the 10.x.y series. * Carthage release for Swift is built with Xcode 14.1. * CocoaPods: 1.10 or later. * Xcode: 13.1-14.1.
v10.32.1
5 weeks ago
### Enhancements * Improve performance of client reset with automatic recovery and converting top-level tables into embedded tables ([Core #5897](https://github.com/realm/realm-core/pull/5897)). * `Realm.Error` is now a typealias for `RLMError` rather than a manually-defined version of what the automatic bridging produces. This should have no effect on existing working code, but the manual definition was missing a few things supplied by the automatic bridging. * Some sync errors sent by the server include a link to the server-side logs associated with that error. This link is now exposed in the `serverLogURL` property on `SyncError` (or `RLMServerLogURLKey` userInfo field when using NSError). ### Fixed * Many sync and app errors were reported using undocumented internal error codes and/or domains and could not be programmatically handled. Some notable things which now have public error codes instead of unstable internal ones: - `Realm.Error.subscriptionFailed`: The server rejected a flexible sync subscription. - `AppError.invalidPassword`: A login attempt failed due to a bad password. - `AppError.accountNameInUse`: A registration attempt failed due to the account name being in use. - `AppError.httpRequestFailed`: A HTTP request to Atlas App Services completed with an error HTTP code. The failing code is available in the `httpStatusCode` property. - Many other less common error codes have been added to `AppError`. - All sync errors other than `SyncError.clientResetError` reported incorrect error codes. (since v10.0.0). * `UserAPIKey.objectId` was incorrectly bridged to Swift as `RLMObjectId` to `ObjectId`. This may produce warnings about an unneccesary cast if you were previously casting it to the correct type (since v10.0.0). * Fixed an assertion failure when observing change notifications on a sectioned result, if the first modification was to a linked property that did not cause the state of the sections to change. ([Core #5912](https://github.com/realm/realm-core/issues/5912), since the introduction of sectioned results in v10.29.0) * Fix a use-after-free if the last external reference to an encrypted synchronized Realm was closed between when a client reset error was received and when the download of the new Realm began. ([Core #5949](https://github.com/realm/realm-core/pull/5949), since 10.28.4). * Fix an assertion failure during client reset with recovery when recovering a list operation on an embedded object that has a link column in the path prefix to the list from the top level object. ([Core #5957](https://github.com/realm/realm-core/issues/5957), since introduction of automatic recovery in v10.32.0). * Creating a write transaction which is rejected by the server due to it exceeding the maximum transaction size now results in a client reset error instead of synchronization breaking and becoming stuck forever ([Core #5209](https://github.com/realm/realm-core/issues/5209), since v10). * Opening an unencrypted file with an encryption key would sometimes report a misleading error message that indicated that the problem was something other than a decryption failure ([Core #5915](https://github.com/realm/realm-core/pull/5915), since 0.89.0). * Fix a rare deadlock which could occur when closing a synchronized Realm immediately after committing a write transaction when the sync worker thread has also just finished processing a changeset from the server ([Core #5948](https://github.com/realm/realm-core/pull/5948)). ### Compatibility * Realm Studio: 11.0.0 or later. * APIs are backwards compatible with all previous releases in the 10.x.y series. * Carthage release for Swift is built with Xcode 14.0.1. * CocoaPods: 1.10 or later. * Xcode: 13.1-14.1. ### Internal * Upgraded realm-core from 12.9.0 to 12.11.0.
v10.32.0
8 weeks ago
### Enhancements * Add `.recoverUnsyncedChanges` (`RLMClientResetModeRecoverUnsyncedChanges`) and `.recoverOrDiscardUnsyncedChanges` (`RLMClientResetModeRecoverOrDiscardUnsyncedChanges`) behaviors to `ClientResetMode` (`RLMClientResetMode`). - The newly added recover modes function by downloading a realm which reflects the latest state of the server after a client reset. A recovery process is run locally in an attempt to integrate the server state with any local changes from before the client reset occurred. The changes are integrated with the following rules: 1. Objects created locally that were not synced before client reset, will be integrated. 2. If an object has been deleted on the server, but was modified on the client, the delete takes precedence and the update is discarded. 3. If an object was deleted on the client, but not the server, then the client delete instruction is applied. 4. In the case of conflicting updates to the same field, the client update is applied. - The client reset process will fallback to `ClientResetMode.discardUnsyncedChanges` if the recovery process fails in `.recoverOrDiscardUnsyncedChanges`. - The client reset process will fallback to `ClientResetMode.manual` if the recovery process fails in `.recoverUnsyncedChanges`. - The two new swift recovery modes support client reset callbacks: `.recoverUnsyncedChanges(beforeReset: ((Realm) -> Void)? = nil, afterReset: ((Realm, Realm) -> Void)? = nil)`. - The two new Obj-C recovery modes support client reset callbacks in `notifyBeforeReset` and `notifyAfterReset`for both `[RLMUser configurationWithPartitionValue]` and `[RLMUser flexibleSyncConfigurationWithClientResetMode]` For more detail on client reset callbacks, see `ClientResetMode`, `RLMClientResetBeforeBlock`, `RLMClientResetAfterBlock`, and the 10.25.0 changelog entry. * Add two new additional interfaces to define a manual client reset handler: - Add a manual callback handler to `ClientResetMode.manual` -> `ClientResetMode.manual(ErrorReportingBlock? = nil)`. - Add the `RLMSyncConfiguration.manualClientResetHandler` property (type `RLMSyncErrorReportingBlock`). - These error reporting blocks are invoked in the event of a `RLMSyncErrorClientResetError`. - See `ErrorReportingBlock` (`RLMSyncErrorReportingBlock`), and `ClientResetInfo` for more detail. - Previously, manual client resets were handled only through the `SyncManager.ErrorHandler`. You have the option, but not the requirement, to define manual reset handler in these interfaces. Otherwise, the `SyncManager.ErrorHandler` is still invoked during the manual client reset process. - These new interfaces are only invoked during a `RLMSyncErrorClientResetError`. All other sync errors are still handled in the `SyncManager.ErrorHandler`. - See 'Breaking Changes' for information how these interfaces interact with an already existing `SyncManager.ErrorHandler`. ### Breaking Changes * The default `clientResetMode` (`RLMClientResetMode`) is switched from `.manual` (`RLMClientResetModeManual`) to `.recoverUnsyncedChanges` (`RLMClientResetModeRecoverUnsyncedChanges`). - If you are currently using `.manual` and continue to do so, the only change you must explicitly make is designating manual mode in your `Realm.Configuration.SyncConfiguration`s, since they will now default to `.recoverUnsyncedChanges`. - You may choose to define your manual client reset handler in the newly introduced `manual(ErrorReportingBlock? = nil)` or `RLMSyncConfiguration.manualClientResetHandler`, but this is not required. The `SyncManager.errorHandler` will still be invoked during a client reset if no callback is passed into these new interfaces. ### Deprecations * `ClientResetMode.discardLocal` is deprecated in favor of `ClientResetMode.discardUnsyncedChanges`. The reasoning is that the name better reflects the effect of this reset mode. There is no actual difference in behavior. ### Compatibility * Realm Studio: 11.0.0 or later. * APIs are backwards compatible with all previous releases in the 10.x.y series. * Carthage release for Swift is built with Xcode 14.0.1. * CocoaPods: 1.10 or later. * Xcode: 13.1-14.1.
v10.31.0
8 weeks ago
The prebuilt binary for Carthage is now build with Xcode 14.0.1. ### Enhancements * Cut the runtime of aggregate operations on large dictionaries in half ([Core #5864](https://github.com/realm/realm-core/pull/5864)). * Improve performance of aggregate operations on collections of objects by 2x to 10x ([Core #5864](https://github.com/realm/realm-core/pull/5864)). Greatly improve the performance of sorting or distincting a Dictionary's keys or values. The most expensive operation is now performed O(log N) rather than O(N log N) times, and large Dictionaries can see upwards of 99% reduction in time to sort. ([Core #5166](https://github.com/realm/realm-core/pulls/5166)) * Add support for changing the deployment location for Atlas Apps. Previously this was assumed to be immutable ([Core #5648](https://github.com/realm/realm-core/issues/5648)). * The sync client will now yield the write lock to other threads which are waiting to perform a write transaction even if it still has remaining work to do, rather than always applying all changesets received from the server even when other threads are trying to write. ([Core #5844](https://github.com/realm/realm-core/pull/5844)). * The sync client no longer writes an unused temporary copy of the changesets received from the server to the Realm file ([Core #5844](https://github.com/realm/realm-core/pull/5844)). ### Fixed * Setting a `List` property with `Results` no longer throws an unrecognized selector exception (since 10.8.0-beta.2) * `RLMProgressNotificationToken` and `ProgressNotificationToken` now hold a strong reference to the sync session, keeping it alive until the token is deallocated or invalidated, as the other notification tokens do. ([#7831](https://github.com/realm/realm-swift/issues/7831), since v2.3.0). * Results permitted some nonsensical aggregate operations on column types which do not make sense to aggregate, giving garbage results rather than reporting an error ([Core #5876](https://github.com/realm/realm-core/pull/5876), since v5.0.0). * Upserting a document in a Mongo collection would crash if the document's id type was anything other than ObjectId (since v10.0.0). * Fix a use-after-free when a sync session is closed and the app is destroyed at the same time ([Core #5752](https://github.com/realm/realm-core/issues/5752), since v10.19.0). ### Deprecations * `RLMUpdateResult.objectId` has been deprecated in favor of `RLMUpdateResult.documentId` to support reporting document ids which are not object ids. ### Compatibility * Realm Studio: 11.0.0 or later. * APIs are backwards compatible with all previous releases in the 10.x.y series. * Carthage release for Swift is built with Xcode 14.0.1. * CocoaPods: 1.10 or later. * Xcode: 13.1-14.1. ### Internal * Upgraded realm-core from 12.7.0 to 12.9.0
v10.30.0
10 weeks ago
### Fixed * Incoming links from `RealmAny` properties were not handled correctly when migrating an object type from top-level to embedded. `RealmAny` properties currently cannot link to embedded objects. ([Core #5796](https://github.com/realm/realm-core/pull/5796), since 10.8.0). * `Realm.refresh()` sometimes did not actually advance to the latest version. It attempted to be semi-non-blocking in a very confusing way which resulted in it sometimes advancing to a newer version that is not the latest version, and sometimes blocking until notifiers are ready so that it could advance to the latest version. This behavior was undocumented and didn't work correctly, so it now always blocks if needed to advance to the latest version. ([#7625](https://github.com/realm/realm-swift/issues/7625), since v0.98.0). * Fix the most common cause of thread priority inversions when performing writes on the main thread. If beginning the write transaction has to wait for the background notification calculations to complete, that wait is now done in a QoS-aware way. ([#7902](https://github.com/realm/realm-swift/issues/7902)) * Subscribing to link properties in a flexible sync Realm did not work due to a mismatch between what the client sent and what the server needed. ([Core #5409](https://github.com/realm/realm-core/issues/5409)) * Attempting to use `AsymmetricObject` with partition-based sync now reports a sensible error much earlier in the process. Asymmetric sync requires using flexible sync. ([Core #5691](https://github.com/realm/realm-core/issues/5691), since 10.29.0). * Case-insensitive but diacritic-sensitive queries would crash on 4-byte UTF-8 characters ([Core #5825](https://github.com/realm/realm-core/issues/5825), since v2.2.0) * Accented characters are now handled by case-insensitive but diacritic-sensitive queries. ([Core #5825](https://github.com/realm/realm-core/issues/5825), since v2.2.0) ### Breaking Changes * `-[RLMASLoginDelegate authenticationDidCompleteWithError:]` has been renamed to `-[RLMASLoginDelegate authenticationDidFailWithError:]` to comply with new app store requirements. This only effects the obj-c API. ([#7945](https://github.com/realm/realm-swift/issues/7945)) ### Compatibility * Realm Studio: 11.0.0 or later. * APIs are backwards compatible with all previous releases in the 10.x.y series. * Carthage release for Swift is built with Xcode 13.4.1. * CocoaPods: 1.10 or later. * Xcode: 13.1 - 14. ### Internal * Upgraded realm-core from 12.6.0 to 12.7.0
v10.29.0
12 weeks ago
### Enhancements * Add support for asymmetric sync. When a class inherits from `AsymmetricObject`, objects created are synced unidirectionally to the server and cannot be queried or read locally. ```swift class PersonObject: AsymmetricObject { @Persisted(primaryKey: true) var _id: ObjectId @Persisted var name: String @Persisted var age: Int } try realm.write { // This will create the object on the server but not locally. realm.create(PersonObject.self, value: ["_id": ObjectId.generate(), "name": "Dylan", "age": 20]) } ``` * Add ability to section a collection which conforms to `RealmCollection`, `RLMCollection`. Collections can be sectioned by a unique key retrieved from a keyPath or a callback and will return an instance of `SectionedResults`/`RLMSectionedResults`. Each section in the collection will be an instance of `ResultsSection`/`RLMSection` which gives access to the elements corresponding to the section key. `SectionedResults`/`RLMSectionedResults` and `ResultsSection`/`RLMSection` have the ability to be observed. ```swift class DemoObject: Object { @Persisted var title: String @Persisted var date: Date var firstLetter: String { return title.first.map(String.init(_:)) ?? "" } } var sectionedResults: SectionedResults<String, DemoObject> // ... sectionedResults = realm.objects(DemoObject.self) .sectioned(by: \.firstLetter, ascending: true) ``` * Add `@ObservedSectionedResults` for SwiftUI support. This property wrapper type retrieves sectioned results from a Realm using a keyPath or callback to determine the section key. ```swift struct DemoView: View { @ObservedSectionedResults(DemoObject.self, sectionKeyPath: \.firstLetter) var demoObjects var body: some View { VStack { List { ForEach(demoObjects) { section in Section(header: Text(section.key)) { ForEach(section) { object in MyRowView(object: object) } } } } } } } ``` * Add automatic handing for changing top-level objects to embedded objects in migrations. Any objects of the now-embedded type which have zero incoming links are deleted, and objects with multiple incoming links are duplicated. This happens after the migration callback function completes, so there is no functional change if you already have migration logic which correctly handles this. ([Core #5737](https://github.com/realm/realm-core/pull/5737)). * Improve performance when a new Realm file connects to the server for the first time, especially when significant amounts of data has been written while offline. ([Core #5772](https://github.com/realm/realm-core/pull/5772)) * Shift more of the work done on the sync worker thread out of the write transaction used to apply server changes, reducing how long it blocks other threads from writing. ([Core #5772](https://github.com/realm/realm-core/pull/5772)) * Improve the performance of the sync changeset parser, which speeds up applying changesets from the server. ([Core #5772](https://github.com/realm/realm-core/pull/5772)) ### Fixed * Fix all of the UBSan failures hit by our tests. It is unclear if any of these manifested as visible bugs. ([Core #5665](https://github.com/realm/realm-core/pull/5665)) * Upload completion callbacks were sometimes called before the final step of interally marking the upload as complete, which could result in calling `Realm.writeCopy()` from the completion callback failing due to there being unuploaded changes. ([Core #4865](https://github.com/realm/realm-core/issues/4865)). * Writing to a Realm stored on an exFAT drive threw the exception "fcntl() with F_BARRIERFSYNC failed: Inappropriate ioctl for device" when a write transaction needed to expand the file. ([Core #5789](https://github.com/realm/realm-core/issues/5789), since 10.27.0) * Syncing a Decimal128 with big significand could result in a crash. ([Core #5728](https://github.com/realm/realm-core/issues/5728)) ### Compatibility * Realm Studio: 11.0.0 or later. * APIs are backwards compatible with all previous releases in the 10.x.y series. * Carthage release for Swift is built with Xcode 13.4.1. * CocoaPods: 1.10 or later. * Xcode: 13.1-14 RC. ### Internal * Upgraded realm-core from 12.5.1 to 12.6.0
v10.28.7
13 weeks ago
### Enhancements * Add prebuilt binaries for Xcode 14 to the release package. ### Fixed * Fix archiving watchOS release builds with Xcode 14. ### Compatibility * Realm Studio: 11.0.0 or later. * APIs are backwards compatible with all previous releases in the 10.x.y series. * Carthage release for Swift is built with Xcode 13.4.1. * CocoaPods: 1.10 or later. * Xcode: 13.1-14 beta 6.
v10.28.6
15 weeks ago
### Fixed * Fixed an issue where having realm-swift as SPM sub-target dependency leads to missing symbols error during iOS archiving ([Core #7645](https://github.com/realm/realm-core/pull/7645)). ### Compatibility * Realm Studio: 11.0.0 or later. * APIs are backwards compatible with all previous releases in the 10.x.y series. * Carthage release for Swift is built with Xcode 13.4.1. * CocoaPods: 1.10 or later. * Xcode: 13.1-14 beta 5. ### Internal * Upgraded realm-core from 12.5.0 to 12.5.1
iOS macOS watchOS tvOS
realm/realm-core worked-for-java
Core database component for the Realm Mobile Database SDKs
⭐️ 938
🕓 9 hours ago
iOS macOS watchOS tvOS

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics