I have an app that is mainly built using UIKit, but I've just added my first SwiftUI view but it's not building. There are two different schemes within my Xcode project: MyApp and MyApp_Staging. I am working in the MyApp_Staging scheme and wanting to see what my SwiftUI preview looks like. However, it won't build and gives me the error:
no such module 'MyApp'
----------------------------------------
CompileDylibError: Failed to build ImagePickerView.swift
Compiling failed: no such module 'MyApp'
/Users/Me/Library/Developer/Xcode/DerivedData/MyApp-czotsuriazmotwgvkpfocaqlgfpz/Build/Intermediates.noindex/Previews/MyApp (Staging)/Intermediates.noindex/MyApp.build/Debug (Staging)-iphonesimulator/MyApp.build/Objects-normal/x86_64/ImagePickerView.2.preview-thunk.swift:1:55: error: no such module 'MyApp'
@_private(sourceFile: "ImagePickerView.swift") import MyApp
I know the schemes are set up correctly as the app usually works normally.
In my Product Module Name, it correctly lists multiple values: MyApp and MyApp_staging for the different build types. Technically, the value is set as $(PRODUCT_NAME:c99extidentifier) but this fills in the correct name.
What is causing this issue?