I'm incorporating SwiftUI into my project for the very first time!
Unfortunately I can't preview my first SwiftUI file I add to the project. The build only fails on the preview. And the failure is in my tests.
Steps to build error:
- Click the "resume" button in the preview area for a newly created SwiftUI view.
- Build fails... I click the 'Diagnostics' button:
Diagnostics screen output:
missing required module 'JGProgressHUD'
SchemeBuildError: Failed to build the scheme "MyApp"
missing required module 'JGProgressHUD'
Compile AppTests.swift (x86_64): /Users/myname/Projects/MyApp/MyAppTests/Entities/AppTests.swift:11:8: error: missing required module 'JGProgressHUD' import MyApp ^
Yes, I have the JGProgressHUD lib imported via SPM.
This is what my test class looks like - it is failing on the import of "MyApp", but only for the preview of SwiftUI... there are no build failures for the app or tests otherwise...
import Foundation
import XCTest
import MyApp
// import app here because of: https://stackoverflow.com/questions/27172481/swift-singleton-init-called-twice-in-xctest
class AppTests: XCTestCase {
// .. tests are here
}
Fails on the "Import MyApp" line.
Here's what I've tried:
- searching everywhere online
- messing with build schemes
- made an example project with JGProgressHUD and tests, no issues with previewing
- Verified that none of my swift files were added to the test target - none of them are, only xib files.
- added "import JGProgressHUD" to the test file, then the preview build fails on this import line for JGProgressHUD.
I can't wait to use SwiftUI, but it seems pretty fickle so far adding to a new project, and I have no idea where else to look. Its such a random problem for what I'm trying to do, I am completely out of ideas for where to look.
Any ideas on what to check or look for?
Thanks for any help XCode sages!