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)

Most upvoted comments

When you open your file (Battle.swift) in Xcode it should belong only to your app in File Inspector:

2016-11-23 10 13 05

Did you also run vapor update (or swift 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.

captura de pantalla 2017-06-24 a las 23 03 10

@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:

  • select the correct target (typically YourAppName or App) in the new file dialog;
  • fix the Target membership manually as described previously;
  • or regenerate the Xcode project after creating a source file in the correct folder.