Attempting to use XCTVapor package with xcodeproj

So in an effort to make the workflow better for my small team, reducing the need for editing the scheme for each machine's unique repo URL, and since we are all currently doing iOS development, it made sense to try and stick with using an xcodeproj for our vapor project instead of just using it in the package.swift only methodology. That being said, we have managed to work out many of the nuances with making that work for us, with one exception, we cannot seem to get the testing package to work properly. When we have the XCTVapor package added into the xcode project, it fails to build with the following gibberish-esque errors:

Screenshot 2022-12-07 at 3.48.38 PM

It appears that it is having issues with some of the symbology within that package. I removed my tests and just added a sample hello_world test to see how it would perform:

@testable import App
import XCTVapor

final class AppTests: XCTestCase {
    func testHelloWorld() throws {
        let app = Application(.testing)
        defer { app.shutdown() }
        try configure(app)

        try app.test(.GET, "hello", afterResponse: { res in
            XCTAssertEqual(res.status, .ok)
            XCTAssertEqual(res.body.string, "Hello, world!")

... to no avail.

Is there anyone on here who might have some insight into where I should be looking to fix this issue?

Thank you in advance!

Are you building for testing? That normally is the culprit.

I strongly suggest you avoid using an Xcode project since that's a) deprecated and b) completely unsupported by Vapor since it's not available on Linux. You should use Xcode's SwiftPM integration

1 Like

Oh good to know about the xcode project being deprecated. We mainly had issues with using the SwiftPM integration with having to define custom working directories every time we pulled code from VCS and saw the xcodeproj as a workaround.

I wasn't building for testing and the problem might be fixed by not using an xcodeproj, however we will need to come up with a routine to automatically switch the custom working directory in xcode when pulling from vcs so we can remove it.

The main problem is when I import XCTVapor using the xcode Frameworks and Libraries pane.

You should only need to define your custom working directory once when you first set up the package. Unless you're checking in your .swiftpm directory (which you shouldn't be) a Git Pull shouldn't affect it.

Yeah importing the library like that for a non-test target will cause it to fail

1 Like

That might be my issue. Maybe I should double check that my .gitignore includes the swiftpm dir.