vapor: Xcode - no such module Vapor
Hello, when I was trying to set up a small a vapor project I ran into an issue with the xcode project that gets created. I ran vapor new dragons, cd dragons, vapor xcode. When the xcode project opened up, I added a new file “Battles.swift” to the models folder, and edited the main.swift file to code in the image below. When I tried to build the app via xcode, I got this error "No such module ‘Vapor’. " However, I was still able to build and run the vapor project via the command line. Not quite sure what the problem is. It might just be my machine. Any help would be appreciated. Thanks
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 25 (5 by maintainers)
When you open your file (Battle.swift) in Xcode it should belong only to your app in File Inspector:
Did you also run
vapor update(orswift package update) to actually pull in the new dependency? Just regenerating the Xcode project is not enough. And if that’s not enough, try building the project in Xcode, sometimes that’s needed to pick up the new modules.Hi, I’m having the same error after generating the Xcode project with $vapor xcode
The main.swift file is contained in Proyect/Sources/Run/ and the first line has an “import App” statement.
When I try to compile, it says ‘No such module App’, when it belongs only to Run in the File Inspector If I only check the App option in the File Inspector, it says: ‘Could not launch Run’ and if I check both (Run & App) it says the same error: ‘No such module App’,
I just installed Vapor to play around and learn a few thing in vacations by watching the following tutorial: https://www.youtube.com/watch?v=62Tt4u7LNiY&t=776s but I can’t reach minute 4:13 successfully.
@bidiko You missed a required step for Swift 4: you must also list
"PostgreSQLProvider"as a dependency of the App target. (Just like how “Vapor” and “FluentProvider” are added on your screenshot.)I fixed the error by ran ‘vapor upgrade’ and regenerate with ‘vapor xcode’.
@e-jam the issue is caused by Xcode selecting the wrong Target automatically when you create a new source file. You either need to be careful, and do one of the following: