Quick: Compile error with the SwiftPM-generated Xcode project on v3.0.0

Created on 19 Jul 2020  Â·  13Comments  Â·  Source: Quick/Quick

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

What did you do?

Add Quick to SPM Package.swift as a dependency and try to run tests.

What did you expect to happen?

Test target would compile and run.

What actually happened instead?

Test target failed to compile. Got the following error:

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)

Environment

List the software versions you're using:

  • Quick: 3.0.0
  • Xcode Version: 11.5
  • 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: 5.2.0

Project that demonstrates the issue

Just ran swift package init and added Quick as a dependency to the package and test target.

// swift-tools-version:5.2
import PackageDescription

let package = Package(
    name: "DemoSPM",
    products: [
        .library(name: "DemoSPM", targets: ["DemoSPM"]),
    ],
    dependencies: [
        .package(url: "https://github.com/Quick/Quick", from: "3.0.0"),
    ],
    targets: [
        .target(name: "DemoSPM", dependencies: []),
        .testTarget(name: "DemoSPMTests", dependencies: [
            .target(name: "DemoSPM"),
            .product(name: "Quick", package: "Quick"),
        ]),
    ]
)
needs-more-information

Most helpful comment

I have a script to fix that issue. If someone knows how to fix that with the help of SPM – please let me know.
swift package generate-xcodeproj && ruby fix_quick_objc_runtime.rb

https://gist.github.com/chipp/c54ca014ba681f3a2ae20d22cfd0b508

All 13 comments

Same on Xcode 12 Beta 5 and macOS Big Sur 11 Beta 5.

I have a script to fix that issue. If someone knows how to fix that with the help of SPM – please let me know.
swift package generate-xcodeproj && ruby fix_quick_objc_runtime.rb

https://gist.github.com/chipp/c54ca014ba681f3a2ae20d22cfd0b508

Having the same issue, thanks for the CLANG_ENABLE_MODULES note @chipp!

And same on Xcode 11.6, by the way

Just ran swift package init and added Quick as a dependency to the package and test target.

I tried that using Xcode 11.7 but couldn't reproduce, swift test ran successfully. 🤔

I tried that using Xcode 11.7 but couldn't reproduce, swift test ran successfully. 🤔

you need to generate Xcode project first swift package generate-xcodeproj and then run tests in Xcode

https://github.com/Quick/Quick/issues/997#issuecomment-678449200

@chipp Hmm so are the issue you are hitting and the originally reported issue different? The original description in https://github.com/Quick/Quick/issues/997#issue-661020910 doesn't say anything about swift package generate-xcodeproj. I'm confused 😕

Xcode 11.0 or later can directly open a Swift package (Package.swift) so I think you normally don't need to generate an xcodeproj by swift package generate-xcodeproj.

https://developer.apple.com/documentation/xcode-release-notes/xcode-11-release-notes

Xcode now supports creating and working with Swift packages, as well as adding, removing, and managing package dependencies. The package management support in Xcode is built on top of the open source Swift Package Manager project. (22427200)

The automatically synthesized project is usually not too useful for people who have custom build settings etc. so many people would generate the project and add it to their VCS.

There are also people who have mixed projects (SPM & other dependency managers) due to some of SPM's constraints.

ref #984

Could you try #1023?

Just tested this using
.package(name: "Quick", url: "https://github.com/Quick/Quick.git", .branch("quickobjcruntime-umbrella-header"))
I can confirm that this solves the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jtango18 picture Jtango18  Â·  7Comments

lilyball picture lilyball  Â·  4Comments

cliren picture cliren  Â·  3Comments

J-Rojas picture J-Rojas  Â·  4Comments

nandin-borjigin picture nandin-borjigin  Â·  6Comments