Reputation: 214
Recently I have started working on backend projects for the company, being an iOS developer I opted for Vapor.
I have read through the majority of the Hacking With Swift Book and felt confident enough to start dabbling in my own projects. I was in the process of creating a model for some information to pass into the Vapor API, but when I attempted to initialize the model object it doesn't autocomplete; so I looked around and realized that it was probably due to the target membership not being selected, so I began looking around for that.
However, there is no target membership section in my inspection pane. I have checked in my regular UIKit/SwiftUI apps, and it is in those, but when I go back into my Vapor projects it is absent.
I have also noticed that when I am making a new Swift file inside of my Vapor project it isn't giving me the option to select there either. When I press the CMD+N shortcut, I get this screen:
but when I choose "Swift File", it just generates the file without asking me which target to assign it to.
Am I missing something that was updated with Vapor 4 (All of my resources have been in reference to Vapor 3), or is there something else that I am overlooking?
Upvotes: 2
Views: 1722
Reputation: 5585
The difference you're seeing is that Vapor projects (or any SwiftPM project opened using the Package.swift manifest) is entirely different to an iOS project. There are no targets to select because the target the file belongs to is decided on the directory you put the file in and the targets declared in your Package.swift.
You'll get the same behaviour with any Swift Package Manager package
Basically, put everything inside Sources/App and that makes it part of the App module available to anything else in that module
Upvotes: 3