ℹ The files UIImage+AlamofireImage.swift, UIImageView+AlamofireImage.swift, and UIButton+Alamofireimage.swift each generate several build warnings of this sort:
Forming 'UnsafeRawPointer' to an inout variable of type String exposes the internal representation rather than the string contents.
Further investigation of this issue shows that, while the warning is new with Xcode 15, the behavior of the code, as it's written, was wrong before that. The warning itself says it all.
Swift Evolution has some discussion on the issue, which recommends this as boilerplate for a better approach:
@propertyWrapper
struct UniqueAddress {
var _placeholder: Int8 = 0
var wrappedValue: UnsafeRawPointer {
mutating get {
// This is "ok" only as long as the wrapped property appears
// inside of something with a stable address (a global/static
// variable or class property) and the pointer is never read or
// written through, only used for its unique value
return withUnsafeBytes(of: &self) {
return $0.baseAddress.unsafelyUnwrapped
}
}
}
}
class Container {
@UniqueAddress static var key
func getObject() -> Any? {
return objc_getAssociatedObject(self, Container.key)
}
}
There's additional discussion and another alternative in Swift forums.
Alamofire Environment
Alamofire version:4.2.0Xcode version:15.0beta5Swift version:5.8.1Platform(s) running AlamofireImage:iOSmacOS version running Xcode:13.4.1
What did you do?
ℹ Built AlamofireImage using Xcode 15 beta 5.
What did you expect to happen?
ℹ Nothing special.
What happened instead?
ℹ The files
UIImage+AlamofireImage.swift
,UIImageView+AlamofireImage.swift
, andUIButton+Alamofireimage.swift
each generate several build warnings of this sort:Further investigation of this issue shows that, while the warning is new with Xcode 15, the behavior of the code, as it's written, was wrong before that. The warning itself says it all.
Swift Evolution has some discussion on the issue, which recommends this as boilerplate for a better approach:
There's additional discussion and another alternative in Swift forums.
Alamofire Environment
Alamofire version:4.2.0 Xcode version:15.0beta5 Swift version:5.8.1 Platform(s) running AlamofireImage:iOS macOS version running Xcode:13.4.1