You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The update to Swift 4 is mostly fairly straight forward - only a few changes necessary. However, there's 1 thing that I'm not able to update myself, in CGPathBridge CGPath file:
typealias MyPathApplier = @convention(block) (UnsafePointer<CGPathElement>) -> Void
// Note: You must declare MyPathApplier as @convention(block), because
// if you don't, you get "fatal error: can't unsafeBitCast between
// types of different sizes" at runtime, on Mac OS X at least.
private func myPathApply(_ path: CGPath!, block: MyPathApplier) {
let callback: @convention(c) (UnsafeMutableRawPointer, UnsafePointer<CGPathElement>) -> Void = { (info, element) in
let block = unsafeBitCast(info, to: MyPathApplier.self)
block(element)
}
path.apply(info: unsafeBitCast(block, to: UnsafeMutableRawPointer.self), function: unsafeBitCast(callback, to: CGPathApplierFunction.self))
}
Xcode 10 throws an error on the last line, highlighting unsafeBitCast: Converting non-escaping value to 'T' may allow it to escape
Even with the Swift version set to 3.2, or updating it to 4.0 and then setting it to 4.0, it still won't let me build with this line existing. Perhaps an Xcode 10 issue, worth understanding.
The text was updated successfully, but these errors were encountered:
In short, now by default blocks are non-escaping, so we just have to add the @escaping tag in front of the MyPathApplier type in the function definition: private func myPathApply(_ path: CGPath!, block: @escaping MyPathApplier)
In this same file, there's also another function called apply, you have to do the same for the parameter in that: func apply(_ fn: @escaping (PathElement) -> Void)
The update to Swift 4 is mostly fairly straight forward - only a few changes necessary. However, there's 1 thing that I'm not able to update myself, in CGPathBridge CGPath file:
Xcode 10 throws an error on the last line, highlighting
unsafeBitCast
:Converting non-escaping value to 'T' may allow it to escape
Even with the Swift version set to 3.2, or updating it to 4.0 and then setting it to 4.0, it still won't let me build with this line existing. Perhaps an Xcode 10 issue, worth understanding.
The text was updated successfully, but these errors were encountered: