SwifterSwift v5.3.0 Release Notes

  • ๐Ÿ’ฅ Breaking Change

    • Sequence
      • Remove last(where:) and move last(where:equals:) to BidirectionalCollection, since it only makes semantic sense for ordered sequences. #912 by guykogus
    • UIView
      • Rename shadowColor, shadowOffset, shadowOpacity and shadowRadius to layerShadowColor, layerShadowOffset, layerShadowOpacity and layerShadowRadius to avoid naming collisions with subclasses properties defined in other modules e.g. UIKit. #897 by LucianoPAlmeida
      • Rename borderColor, borderWidth and cornerRadius to layerBorderColor, layerBorderWidth, and layerCornerRadius to avoid naming collisions with subclasses properties defined in other modules e.g. UIKit. #972 by Jayxiang

    โž• Added

    • SCN3Vector
      • Added normalized method, and basic division functions (SCNVector3 / scalar, and SCNVector3 /= scalar. #908 by thisIsTheFoxe
    • Dictionary
      • Added pick(keys:) to pick part of a dictionary with specified keys. #911 by MaratIbragimov
    • UIScrollView
      • Added visibleRect, scrollToTop(animated:), scrollToLeft(animated:), scrollToBottom(animated:), scrollToRight(animated:), scrollUp(animated:), scrollLeft(animated:), scrollDown(animated:), scrollRight(animated:). #888 by guykogus
    • โœ… XCTest
      • Added XCTAssertEqual(_:_:accuracy:_:file:line:) for checking if Color objects are equal within a given level of accuracy. #889 by guykogus
    • BinaryInteger
      • Added bytes and init?(bytes:) to make it easier to work with bytes (as [UInt8]). #987 by thisIsTheFoxe
    • FloatingPoint
      • Moved the square root operator โˆš from Double and Float to make it generic. #880 by guykogus
    • Collection
      • Added fullRange to get the entire range of indices in a collection. #902 by guykogus
      • Moved indices(of:) from RandomAccessCollection to find the indices of an element. #863 by guykogus
    • UIViewController:
      • Added instantiate(from:bundle:identifier:) function to UIViewController to make it easier to instantiate it from storyboard. #860 by VatoKo
    • String:
      • Added fullNSRange, range(from:), nsRange(from:) and subscript for converting between Range<String.Index> and NSRange. #902 by guykogus
      • Overloaded Swift's 'contains' operator (~=) for String to check regex matching. #858 by VatoKo
      • regexEscaped, which returns an escaped string for inclusion in a regex pattern
      • Added matches(regex:options:) and the ~= regex to check directly against NSRegularExpression. Also added replacingOccurrences(regex:template:options:searchRange:) as a more convenient way to replace NSRegularExpressions. #901 by gurgeous
    • DispatchQueue:
      • Added asyncAfter(delay:qos:flags:execute:) method to use it more conveniently without typing unnecessary .now() + delay. #859 by VatoKo
      • Re-added debounce(delay:action:) for only executing a closure once using a throttle delay. #869 by guykogus
    • RangeReplaceableCollection:
      • subscript(offset:) and subscript(range:) to access and replace elements by the index offsets. #826 by guykogus
    • Sequence:
      • Added contains(_:) for Hashable elements for performance improvement. #912 by guykogus
      • Added first(where:equals:) to find the first element of the sequence with having property by given key path equals to given value. #836 by hamtiko
      • Added last(where:equals:) to find the last element of the sequence with having property by given key path equals to given value. #838 by hamtiko
    • SKNode:
      • center, topLeft, topRight, bottomLeft, bottomRight to get anchor position or set position using anchor. #835 by rypyak
    • CGSize:
      • Added new +, +=, - and -= operator extensions for tuple (width: CGFloat, height: CGFloat). #841 by hamtiko
    • WKWebView:
      • Added loadURL(_:) and loadURLString(_:) extensions for WkWebView. #851 by hamtiko
    • HKActivitySummary:
      • Added isStandGoalMet, isExerciseTimeGoalMet, and isEnergyBurnedGoalMet. #875 by lhygilbert
    • UIView:
      • Added masksToBounds (IBInspectable) extension. #877 by hamtiko
      • Added loadFromNib(withClass:), which loads a UIView of a particular type from a nib file. #885 by gurgeous
      • Added findConstraint for finding an existing constraint. #886 by gurgeous
      • Added widthConstraint, heightConstraint, leadingConstraint, trailingConstraint, topConstraint, and bottomConstraint for finding specific constraints. #886 by gurgeous
      • Added UIView.subviews(ofType:) extension which returns all the subviews of a given type recursively in the view hierarchy rooted on the view it its called. #993 by ashercoelho
      • Added UIStackView.swap(_ view1:, _ view2:) extension which exchanges two views that are arranged in the stack. #989 by salahamassi
    • UIImage
      • Added averageColor, which calculates the average UIColor for an entire image. #884 by gurgeous
      • Added withAlwaysOriginalTintColor(_:) returns a new version of the image with a tint color that uses the .alwaysOriginal rendering mode. #886 by [jayxiang][https://github.com/jayxiang]
    • StringProtocol
      • Added replacingOccurrences(ofPattern:withTemplate:options:searchRange:) as a more convenient way to replace patterns. #901 by gurgeous
    • Measurement
      • Added .degrees(_:), arcMinutes(_:), arcSeconds(_:), radians(_:), gradians(_:) and revolutions(_:) to conveniently initialize measurement with corresponding unit. #936 by Shiva Huang
    • UITextField
      • Added addToolbar(items:height:) to add a toolbar to a UITextField. #954 by Randhir Kumar
    • URL
      • Added the (unsafeString: String) initializer for URL as a more conveniently to construct unsafe URLs from String by jevonmao
    • MKMultiPoint
      • Added .coordinates property, to return an array of coordinates for the provided MKMultiPoint. #990 by @rizwankce.
    • NSAttributedString
      • Added Array.joined(separator:) to create a new NSAttributedString by concatenating the elements of the sequence, adding the given separator between each element. #985 by Roman Podymov.
    • UIButton
      • Added setAttributedTitleForAllStates, attributedTitleForDisabled, attributedTitleForHighlighted, attributedTitleForNormal and attributedTitleForSelected for convenient work with attributed strings. #1001 by Roman Podymov.
    • Digest
      • Added hexString to get a hexadecimal representation for all digest typed in CryptoKit (e.g. SHA216Digest, SHA512Digest,MD5Digest, ...). #1026 by Marco Eidinger.

    ๐Ÿ”„ Changed

    • NSAttributedString:
      • bolded maintains font size and works on all platforms except Linux. italicized maintains font size and works on all platforms except Linux and macOS. #900 by guykogus
      • applying(attributes:) changed access modifier from fileprivate to public. #832 by cHaLkdusT
    • Color:
      • Refactored init(light:dark:) to remove deployment target version restrictions. #844 by VincentSit.
      • Use enum to declare namespace instead of using struct. Thus private initializer is no longer needed. #927 by Shiva Huang
      • Add init?(argbHexString:) to support the common ARGB format used in Android. #971 by yonat
    • CAGradientLayer:
      • In init(colors:locations:startPoint:endPoint:type:) added default values to startPoint and endPoint. #864 by guykogus
    • UITextField:
      • Added addPaddingRight,addPaddingRightIconextension,#878 by Jayxiang
    • UIAlertController:
    • UIRefreshControl:
      • Add beginRefreshing(animated:sendAction:) that works inside any UIScrollView and not only UITableView. #949 by yonat
    • SKSpriteNode:
      • Added aspectFill(to:) to size SKSpriteNode with respect to aspect ratio. #490 by erikdrobne.

    ๐Ÿ—„ Deprecated

    • Sequence:
      • Marked map(by:), compactMap(by:), filter(by:) as deprecated in favor use of Key Path expressions as functions feature in Swift 5.3. #862 by Roman Podymov.

    โœ‚ Removed

    • UIDatePicker
      • Disabled textColor when compiling for target macCatalyst as it will crash. #864 by guykogus
    • MKPolyline
      • Removed .coordinates property, in favour of .coordinates property from MKMultiPoint. Since MKPolyline extends from MKMultiPoint it should work fine. #990 by @rizwankce.

    ๐Ÿ›  Fixed

    • Collection
      • indices(where:), forEach(slice:body:) can be used on a collection with any index type. average() can be used on any integer element type. #863 by guykogus
    • CAGradientLayer:
      • CAGradientLayer extensions inaccessible through internal level protection. #856 by Den Andreychuk.
    • StringExtensions.swift:
      • Fixed a bug: When the length of a string is 0, calling truncated method will crash. #866 by phil zhang
      • Fixed String.base64Decoded making it a safe decode by ignore non-base64 characters. #961 by Jayxiang
    • UITextField
      • Fixed a bug:UITextField addPaddingLeftIcon doesn't work on iOS 13#876 by Jayxiang
    • UIImage
      • Fixed a bug:UIImage rotated(by:) lose origin scale, result in image blurred#904 by yanpanpan
    • UIView
      • Fixed rotate(toAngle) to rotate to an angle instead of by an angle, as raised in #935. #1019 by guykogus
    • ColorExtension:
      • Fixed a bug: Color.FlatUI can be initialized. by Shiva Huang
      • Fixed Color.init?(hexString: String, transparency: CGFloat = 1) was not handling uppercase 0X in hex prefix #947 by Zero.D.Saber
    • URLExtension
      • Fixed deletingAllPathComponents() and deleteAllPathComponents to handle empty paths, as raised in #1012. #1018 by guykogus

    ๐Ÿ”’ Security