S. Gissel
S. Gissel

Reputation: 2650

SwiftUI modifier .resizable() not available for Image

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.

enter image description here

SwiftUI is imported. If you type the whole modifier myself is says

enter image description here

enter image description here

Upvotes: 3

Views: 571

Answers (4)

Neck
Neck

Reputation: 620

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.

Upvotes: 2

Asperi
Asperi

Reputation: 257711

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()

Upvotes: 1

Lou Franco
Lou Franco

Reputation: 89172

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/

Upvotes: 1

Fogmeister
Fogmeister

Reputation: 77641

It definitely is...

enter image description here

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.

Upvotes: 1

Related Questions