Quick/Quick

Quick is failing to compile with server side Swift (Vapor app) using Xcode

alexvbush opened this issue · 3 comments

  • I have read CONTRIBUTING and have done my best to follow them.

What did you do?

I installed Quick & Nimble in my server side Swift Vapor project using the following Swift package manager file:

// swift-tools-version:4.0

import PackageDescription

let package = Package(
    name: "tw-music-app-api-vapor",
    products: [
        .library(name: "App", targets: ["App"]),
        .executable(name: "Run", targets: ["Run"])
    ],
    dependencies: [
        .package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "2.1.0")),
        .package(url: "https://github.com/vapor/fluent-provider.git", .upToNextMajor(from: "1.2.0")),
        .package(url: "https://github.com/Quick/Quick.git", .upToNextMajor(from: "1.2.0")),
        .package(url: "https://github.com/Quick/Nimble.git", .upToNextMajor(from: "7.0.2")),
    ],
    targets: [
        .target(name: "App", dependencies: ["Vapor", "FluentProvider"],
                exclude: [
                    "Config",
                    "Database",
                    "Localization",
                    "Public",
                    "Resources",
                    ]),
        .target(name: "Run", dependencies: ["App"]),
        .testTarget(name: "AppTests", dependencies: ["App", "Testing", "Quick", "Nimble"])
    ]
)

Then I created the following failing spec:

import Testing
import Quick
import Nimble

class TagsControllerSpec: QuickSpec {
    override func spec() {
        describe("something") {
            it("does somehting") {
                expect(true).toNot(beTrue())
            }
        }
    }
}

What did you expect to happen?

Upon building the app in Xcode I expected it to compile, launch the tests, and successfully fail the test.

What actually happened instead?

The app failed building with the following message:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_XCTestCase", referenced from:
      _OBJC_CLASS_$__QuickSpecBase in QuickSpecBase.o
  "_OBJC_METACLASS_$_XCTestCase", referenced from:
      _OBJC_METACLASS_$__QuickSpecBase in QuickSpecBase.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

screen shot 2017-10-06 at 5 03 02 pm

Environment

List the software versions you're using:

  • Quick: 1.2.0
  • Nimble: 7.0.2
  • Xcode Version: Version 9.0 (9A235)
  • Swift Version: Xcode Default

Please also mention which package manager you used and its version. Delete the
other package managers in this list:

  • Swift Package Manager Apple Swift Package Manager - Swift 4.0.0-dev (swiftpm-13126)

Project that demonstrates the issue

https://github.com/alexvbush/tw-music-app-api-vapor

Note:

running swift test successfully compiles and runs the tests, something is wrong with xcode setup.

Looks like that is related to swiftlang/swift-package-manager#955. Without CLANG_ENABLE_MODULES=YES we can't link to XCTest framework. So this would not be our fault unfortunately.

It would be great if you could file an issue on https://bugs.swift.org.

Closing this due to inactivity.

If someone is still experiencing the problem and want to use Quick/Nimble in a SPM-project, I have a tool called spm_utils that fixes that. Just install it and then run:

spm_utils quick