:curly_loop: A CoreGraphics library that identifies points where two CGPaths intersect.
Logos for most major world airlines & a downloader script
🐦 An educational game that teaches basic reading skills and word recognition. Published by Augusta University.
:droplet: An iOS image editor that lets you create square images with blurry backgrounds
:smile: An iOS app that reveals the unicode names of emoji
:watch: Sudoku app for watchOS and iOS
:arrow_up: A Modal Presentation Controller that adapts to content size, keyboard visibility, and touch input.
Add support for Encoding and Decoding nested objects with dot notation (Prototype implementation for the Swift Standard Library)
calda/DeclarativeTableViewController 3
🏗 A simple, declarative approach to building Table Views in Swift. Define your cells and go.
👨🏼💻 My personal website / blog / portfolio
startedcalda/CGPathIntersection
started time in 3 hours
Pull request review commentairbnb/swift
Add rule to prefer shorthand form for Optional, Array, and Dictionary
_You can enable the following settings in Xcode by running [this script](resourc </details> + * <a id='standard-library-type-shorthand'></a>(<a href='#standard-library-type-sugar'>link</a>) **For standard library types with a canonical shorthand form (`Optional`, `Array`, `Dictionary`), prefer using the shorthand form over the full generic form. [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#typeSugar)++ <details>++ ```swift+ // WRONG+ let optional: Optional<String> = nil+ let array: Array<String> = []+ let dictionary: Dictionary<String, Any> = [:]++ // RIGHT+ let optional: String? = nil+ let array: [String] = []+ let dictionary: [String: Any] = [:]
Yes, I was mistaken.
comment created time in 15 hours
Pull request review commentairbnb/swift
Add rule to prefer shorthand form for Optional, Array, and Dictionary
_You can enable the following settings in Xcode by running [this script](resourc </details> + * <a id='standard-library-type-shorthand'></a>(<a href='#standard-library-type-sugar'>link</a>) **For standard library types with a canonical shorthand form (`Optional`, `Array`, `Dictionary`), prefer using the shorthand form over the full generic form. [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#typeSugar)
I think the format is off here too 😉
comment created time in 19 hours
Pull request review commentairbnb/swift
Add rule to prefer shorthand form for Optional, Array, and Dictionary
_You can enable the following settings in Xcode by running [this script](resourc </details> + * <a id='standard-library-type-shorthand'></a>(<a href='#standard-library-type-sugar'>link</a>) **For standard library types with a canonical shorthand form (`Optional`, `Array`, `Dictionary`), prefer using the shorthand form over the full generic form. [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#typeSugar)++ <details>++ ```swift+ // WRONG+ let optional: Optional<String> = nil+ let array: Array<String> = []+ let dictionary: Dictionary<String, Any> = [:]++ // RIGHT+ let optional: String? = nil+ let array: [String] = []+ let dictionary: [String: Any] = [:]
I'm not sure I agree. These types cannot be inferred from the right hand side. I'd agree if the examples were using let array: [String] = Array<String>() but as is they need the explicit types.
comment created time in 19 hours
Pull request review commentairbnb/swift
Add rule to prefer shorthand form for Optional, Array, and Dictionary
_You can enable the following settings in Xcode by running [this script](resourc </details> + * <a id='standard-library-type-shorthand'></a>(<a href='#standard-library-type-sugar'>link</a>) **For standard library types with a canonical shorthand form (`Optional`, `Array`, `Dictionary`), prefer using the shorthand form over the full generic form. [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#typeSugar)++ <details>++ ```swift+ // WRONG+ let optional: Optional<String> = nil+ let array: Array<String> = []+ let dictionary: Dictionary<String, Any> = [:]++ // RIGHT+ let optional: String? = nil+ let array: [String] = []+ let dictionary: [String: Any] = [:]
These examples violate this rule. Maybe we can use a different example?
comment created time in 19 hours
Pull request review commentairbnb/swift
Add rule to prefer shorthand form for Optional, Array, and Dictionary
--swiftversion 5.1 # rules---rules anyObjectProtocol,redundantParens,redundantReturn,redundantSelf,sortedImports,strongifiedSelf,trailingCommas,trailingSpace,wrapArguments,wrapMultilineStatementBraces,indent,wrapAttributes,organizeDeclarations,markTypes,extensionAccessControl,duplicateImports,redundantType+--rules anyObjectProtocol,redundantParens,redundantReturn,redundantSelf,sortedImports,strongifiedSelf,trailingCommas,trailingSpace,wrapArguments,wrapMultilineStatementBraces,indent,wrapAttributes,organizeDeclarations,markTypes,extensionAccessControl,duplicateImports,redundantType,typeSugar
Do you think it would be good to always specify the values to SwiftFormat (e.g. --short-optionals always) to avoid relying on SwiftFormat defaults which may change? I'm of mixed minds.
comment created time in 19 hours
Pull request review commentairbnb/swift
Add rule to always inline let keyword when destructuring enum cases and tuples
_You can enable the following settings in Xcode by running [this script](resourc </details> +* <a id='destructure-inline-let'></a> (<a href='#destructure-inline-let'>link</a>) **When destructuring an enum case or a tuple, place the `let` keyword inline, adjacent to each individual property assignment.** [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#hoistPatternLet)
Putting here so we have a thread:
- This makes it more clear which identifiers are part of the conditional (if / case) check and which identifiers are binding new variables.
I am open to this idea though it would be easier to visualize. What do you think about adding a code example where we bind new variables to show how the proposed style is superior?
comment created time in 19 hours
Pull request review commentairbnb/swift
Add rule to always inline let keyword when destructuring enum cases and tuples
_You can enable the following settings in Xcode by running [this script](resourc </details> +* <a id='destructure-inline-let'></a> (<a href='#destructure-inline-let'>link</a>) **When destructuring an enum case or a tuple, place the `let` keyword inline, adjacent to each individual property assignment.** [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#hoistPatternLet)
Putting here so we have a thread:
- For consistency, we should prefer either always inlining the
letkeywords, or never inlining the keywords. Since enum payloads with a small number of associated values are much more common than enum payloads with a large number of associated values, we should prefer always inlining theletkeywords.
For an enum with one associated value, the number of characters is the same in either style. For an enum with multiple associated values, the proposed style is more verbose. I don't follow how this proposed style prioritizes enum cases with fewer associated values.
comment created time in 19 hours
pull request commentairbnb/swift
Add rule to always inline let keyword when destructuring enum cases and tuples
I am having trouble following 3) in the reasoning. Can you make it more clear to me?
comment created time in 19 hours
Pull request review commentairbnb/swift
_You can enable the following settings in Xcode by running [this script](resourc </details> -* <a id='limit-vertical-whitespace'></a>(<a href='#limit-vertical-whitespace'>link</a>) **Limit empty vertical whitespace to one line.** Favor the following formatting guidelines over whitespace of varying heights to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace)+* <a id='limit-consecutive-whitespace'></a>(<a href='#limit-consecutive-whitespace'>link</a>) **Limit consecutive whitespace to one blank line or space (excluding indentation).** Favor the following formatting guidelines over whitespace of varying heights of widths to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace) [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#consecutiveSpaces)
* <a id='limit-consecutive-whitespace'></a>(<a href='#limit-consecutive-whitespace'>link</a>) **Limit consecutive whitespace to one blank line or space (excluding indentation).** Favor the following formatting guidelines over whitespace of varying heights or widths. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace) [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#consecutiveSpaces)
comment created time in 20 hours
Pull request review commentairbnb/swift
_You can enable the following settings in Xcode by running [this script](resourc </details> -* <a id='limit-vertical-whitespace'></a>(<a href='#limit-vertical-whitespace'>link</a>) **Limit empty vertical whitespace to one line.** Favor the following formatting guidelines over whitespace of varying heights to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace)+* <a id='limit-consecutive-whitespace'></a>(<a href='#limit-consecutive-whitespace'>link</a>) **Limit consecutive whitespace to one blank line or space (excluding indentation).** Favor the following formatting guidelines over whitespace of varying heights of widths to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace) [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#consecutiveSpaces)
Dividing files seems less relevant now.
comment created time in 20 hours
Pull request review commentairbnb/swift
_You can enable the following settings in Xcode by running [this script](resourc </details> -* <a id='limit-vertical-whitespace'></a>(<a href='#limit-vertical-whitespace'>link</a>) **Limit empty vertical whitespace to one line.** Favor the following formatting guidelines over whitespace of varying heights to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace)+* <a id='limit-consecutive-whitespace'></a>(<a href='#limit-consecutive-whitespace'>link</a>) **Limit consecutive whitespace to one blank line or space (excluding indentation).** Favor the following formatting guidelines over whitespace of varying heights to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace) [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#consecutiveSpaces)++ <details>++ ```swift+ // WRONG+ struct Planet {++ let mass: Double+ let satellites: [Planet]
let nearestNeighbor: Planet
?
comment created time in 20 hours
Pull request review commentairbnb/swift
_You can enable the following settings in Xcode by running [this script](resourc </details> -* <a id='limit-vertical-whitespace'></a>(<a href='#limit-vertical-whitespace'>link</a>) **Limit empty vertical whitespace to one line.** Favor the following formatting guidelines over whitespace of varying heights to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace)
One of the reasons we've named these links is so that each rule has a permalink. When we created the style guide we were told this was a good idea by the folk working on the JS style guide. With this PR, the https://github.com/airbnb/swift#limit-vertical-whitespace permalink breaks. Is there any way to continue to have https://github.com/airbnb/swift#limit-vertical-whitespace bring us to this rule?
comment created time in 20 hours
Pull request review commentairbnb/swift
Add rule to always inline let keyword when destructuring enum cases and tuples
_You can enable the following settings in Xcode by running [this script](resourc </details> +* <a id='destructure-inline-let'></a> (<a href='#destructure-inline-let'>link</a>) **When destructuring an enum case or a tuple, place the `let` keyword inline, adjacent to each individual property assignment.** [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#hoistPatternLet)++ <details>
Let's add the reasoning to the rule itself too 🙏
comment created time in 21 hours
Pull request review commentairbnb/swift
Add rule to always inline let keyword when destructuring enum cases and tuples
_You can enable the following settings in Xcode by running [this script](resourc </details> +* <a id='destructure-inline-let'></a> (<a href='#* <a id='destructure-inline-let'></a> (<a href='#unnecessary-enum-arguments'>link</a>) **When destructuring an enum case or a tuple, place the `let` keyword inline, adjacent to each individual property assignment.** [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#hoistPatternLet)
the format of the links at the beginning is off :P
comment created time in 21 hours
Pull request review commentairbnb/swift
_You can enable the following settings in Xcode by running [this script](resourc </details> -* <a id='limit-vertical-whitespace'></a>(<a href='#limit-vertical-whitespace'>link</a>) **Limit empty vertical whitespace to one line.** Favor the following formatting guidelines over whitespace of varying heights to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace)+* <a id='limit-consecutive-whitespace'></a>(<a href='#limit-consecutive-whitespace'>link</a>) **Limit consecutive whitespace to one blank line or space (excluding indentation).** Favor the following formatting guidelines over whitespace of varying heights to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace) [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#consecutiveSpaces)++ <details>++ ```swift+ // WRONG+ struct Planet {++ let mass: Double+ let satellites: [Planet]
The nerd in me wants to point out that satellites are actually not planets. But I won't do it.
comment created time in 21 hours
Pull request review commentairbnb/swift
_You can enable the following settings in Xcode by running [this script](resourc </details> -* <a id='limit-vertical-whitespace'></a>(<a href='#limit-vertical-whitespace'>link</a>) **Limit empty vertical whitespace to one line.** Favor the following formatting guidelines over whitespace of varying heights to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace)+* <a id='limit-consecutive-whitespace'></a>(<a href='#limit-consecutive-whitespace'>link</a>) **Limit consecutive whitespace to one blank line or space (excluding indentation).** Favor the following formatting guidelines over whitespace of varying heights to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace) [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#consecutiveSpaces)
* <a id='limit-consecutive-whitespace'></a>(<a href='#limit-consecutive-whitespace'>link</a>) **Limit consecutive whitespace to one blank line or space (excluding indentation).** Favor the following formatting guidelines over whitespace of varying heights or widths to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace) [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#consecutiveSpaces)
comment created time in 21 hours
Pull request review commentairbnb/swift
_You can enable the following settings in Xcode by running [this script](resourc </details> -* <a id='limit-vertical-whitespace'></a>(<a href='#limit-vertical-whitespace'>link</a>) **Limit empty vertical whitespace to one line.** Favor the following formatting guidelines over whitespace of varying heights to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace)+* <a id='limit-consecutive-whitespace'></a>(<a href='#limit-consecutive-whitespace'>link</a>) **Limit consecutive whitespace to one blank line or space (excluding indentation).** Favor the following formatting guidelines over whitespace of varying heights to divide files into logical groupings. [](https://github.com/realm/SwiftLint/blob/master/Rules.md#vertical-whitespace) [](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#consecutiveSpaces)++ <details>++ ```swift+ // WRONG+ struct Planet {++ let mass: Double+ let satellites: [Planet]+++ func travelTo() { }
nit: from the name of this method I would expect it to take a parameter. Could we a different name/signature?
func distance(to: Planet) -> Double { }
comment created time in 21 hours
startedsegmentio/ksuid
started time in 3 days
startedmitchtabian/Food2Fork-KMM
started time in 4 days
startedvogon/everycolor
started time in 4 days
issue commentairbnb/swift
Please Add SwiftUI style guide for Swift World 🚀
Hi @keshavvishwkarma! Thanks for participating in our style guide repo discussions 😉
I personally like the idea of having style recommendations on SwiftUI usage so we can move towards having best practices in the community, but given that:
- SwiftUI is still a very early technology
- We (Airbnb) don't currently use SwiftUI in production
I think we won't move in this direction for the time being.
When / if we start using SwiftUI in production for a while and we've seen how both the Airbnb iOS community and the larger iOS community think of style in SwiftUI I think we should definitively start adding recommendations in that direction.
In the short term we've been quite happy with using Epoxy for our declarative UI, so I don't expect changes on this in the short-term.
comment created time in 7 days
issue openedairbnb/swift
Please Add SwiftUI style guide for Swift World 🚀
A style guide for the SwiftUI domain-specific language would be a nice addition to Airbnb's Swift style guide for the Swift World 🚀
created time in 7 days
startedandymatuschak/orbit
started time in 8 days
pull request commentairbnb/swift
Add "prefer immutable statics" rule
Thank you Eric! I'm merging this since overall folks seem to approve of it.
comment created time in 10 days
pull request commentairbnb/swift
Add "No direct standard out" rule
Thank you Eric! I'm merging this since overall folks seem to approve of it.
comment created time in 10 days
push eventairbnb/swift
commit sha 175c074a5bd57e72146876a014b12cd7be8c1003
Add "prefer immutable statics" rule (#120) * Add "prefer immutable statics" rule ## Summary **Prefer immutable or computed static variables over mutable ones whenever possible.** Use stored `static let` properties or computed `static var` properties over stored `static var`s properties whenever possible, as stored `static var` properties are global mutable state. ### Why? Global mutable state increases complexity and makes it harder to reason about the behavior of applications. It should be avoided when possible. ```swift // WRONG enum Fonts { static var title = UIFont(…) } // RIGHT enum Fonts { static let title = UIFont(…) } ``` ```swift // WRONG struct FeatureState { var count = 1 static var initial = FeatureState() } // Right struct FeatureState { var count = 1 static var initial: FeatureState { // Vend static properties that are cheap to compute FeatureState() } } ``` * Update state example * Improve formatting, fix wording
push time in 10 days