UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: "Cannot load underlying module for 'AVFoundation'" Xcode error

Forums > iOS

Recently, I started coding with Xcode (I used to code with Swift Playgrounds on my iPad), and now I'm attempting to make a SwiftUI app that uses AVFoundation and camera to let the user take pictures of animals. The purpose of the app is to identify the photographed animals, using machine learning.

In Swift Playgrounds, when I wanted to use a framework, the only thing I had to do is to add "import framework name" above my code. However, if I do that in Xcode with the AVFoundation framework, Xcode throws this error: "Cannot load underlying module for 'AVFoundation'". This probably is some sort of rookie mistake, but I'm new to Xcode, so please forgive me. 😉

I already added the framework to the "Link Binary With Libraries" section (Project -> Build Phases -> Link Binary With Libraries), but this doesn't get rid of the error. What else should I do in order to use AVFoundation?

Update: the error was thrown when I tried to run the app on my iPhone 8. (It doesn't run in simulator, because it uses camera)

3      

I think that you have enabled the Show live issues, or it has been enabled for you automatically, if just you have just installed the latest Xcode v14.3.1 I say this because I had the same issue with AVFoundation and AVKit.

Checking if it is an issue with the latest Xcode, or it has been there for sometime if you enable Show live issues, and AVFoundation/ AVKit have a hidden non-error.

Anyway, in my case the audio worked fine in the app, so it was just the error message being displayed that was the issue.

Try this.

In the Xcode menu bar, find Settings\General. After the Appearance and Issues options there should be Show live issues. Deselect it, and see if that helps.

At least it should suppress live error reporting. Check that your app (still) works.

4      

Thank you, @Greenamberred, the error doesn't show up anymore now.

3      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.