I found a lot of tutorials for SwiftUI where the modifier .resizable() is used on an Image. It doesn't seem to be available anymore on Xcode 13.3.1 with Swift 5.
SwiftUI is imported. If you type the whole modifier myself is says
CodePudding user response:
It definitely is...
Have you definitely imported SwiftUI in that file?
If you type the whole thing out does it build or does it cause an error?
From the auto completion drop down it looks like Xcode thinks you’re referring to an imageURL
perhaps there is a change that Xcode hasn’t caught up with yet.
CodePudding user response:
It looks like the Image
you are getting is from some other module (not SwiftUI).
If you are 100% sure you don't have another import -- then I recommend exiting Xcode and deleting derived data.
rm -rf ~/Library/Developer/Xcode/DerivedData/
CodePudding user response:
Local module defines have a preference over system. Taking into account context menu proposals it is your case.
The fix is to use module explicitly, like
SwiftUI.Image("myImage").resizable()
CodePudding user response:
You are using a different Image
, it's not from SwiftUI. See the color of Image is lite green(ies). You might be using an Image extension or something. Make sure while typing Image..., you select Image from SwiftUI.