1

I am learning SwiftUI, from scratch and trying to show a Image from a URL, I am using the built in AsyncImage method, yet I get this error with no context. Cannot call value of non-function type 'module<AsyncImage>', Googling didn't help and I am following the exact same code line-by-line from a article I am following.enter image description here.

Here's some more details from the diagnostics popup, I received.

cannot call value of non-function type 'module'


SchemeBuildError: Failed to build the scheme "AsyncImage"

cannot call value of non-function type 'module'

Compile ContentView.swift (x86_64): /Users/fayaz/Learn/AsyncImage/AsyncImage/ContentView.swift:14:9: error: cannot call value of non-function type 'module' AsyncImage(url: URL(string: imageUrl)) ^

Here's my setup.

  1. Macos BigSur v11.0.1
  2. Xcode Version 12.5

1 Answer 1

3

Your project seems to be called AsyncImage, so without knowing all the other objects in your project its hard to know whether there would be some naming conflict.

However, your main issue is that AsyncImage is iOS 15+. That means currently, your version of Xcode (you said 12.5) doesn't support it. You would need to install Xcode 13 for the latest API. That would however require an Apple Developer account (can't remember whether the free version allows access to beta software though).

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you, didn't knew this method is an ios 15 feature, surprisingly didn't see this anywhere, or I missed it.
No worries, it honestly happens more often than you'd think, especially if you're new in the community and started with the latest and nicest features :)
The real issue is that the project is called AsyncImage, which creates a module with the same name that the compiler tries to use, that's why the error says cannot call value of non-function type 'module'. Solution is to rename the project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.