Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot `swift build` Quick on OS X #492

Closed
modocache opened this issue Feb 24, 2016 · 10 comments
Closed

Cannot `swift build` Quick on OS X #492

modocache opened this issue Feb 24, 2016 · 10 comments

Comments

@modocache
Copy link
Member

@modocache modocache commented Feb 24, 2016

This site indicates that Quick does not build using the swift-package-manager on OS X. Using DEVELOPMENT-SNAPSHOT-2016-02-08-a, building Quick using swift build -v -v results in the following: https://gist.github.com/modocache/84a3cfd512d064de4ae0

In a nutshell, the error is:

/Users/USER/Developer/swiftweb/Clones/Quick/Packages/Nimble-3.3.1/Sources/Nimble/Adapters/NimbleXCTestHandler.swift:2:8: error: cannot load underlying module for 'XCTest'
import XCTest
       ^

I'm not quite sure what's going on, but @briancroom might! 😉 My open questions:

  1. Why is swift build for Quick building Nimble as well? Shouldn't that only happen for swift test? (Forgive my ignorance here! Still learning about SwiftPM).
  2. Why isn't swift build able to link XCTest?
@modocache modocache added the bug label Feb 24, 2016
@modocache
Copy link
Member Author

@modocache modocache commented Feb 24, 2016

Also, I hadn't realized that swift build on OS X was "a thing". We should add this case to the CI matrix if it's something we care about.

@briancroom
Copy link
Member

@briancroom briancroom commented Feb 24, 2016

Thanks for bringing this up @modocache! I was actually looking at this exact thing just last night in hopes of making additional progress towards complete SwiftPM support. As to your questions:

  1. Why is swift build for Quick building Nimble as well? Shouldn't that only happen for swift test? (Forgive my ignorance here! Still learning about SwiftPM).

This is because Quick and Nimble both currently target the version of SwiftPM included in the DEVELOPMENT-SNAPSHOT-2016-02-08-a release which does not yet include swift test. Because of that, the only way for the Quick and Nimble test suites to be built is to treat them as first-class products of the packages, which in turn requires Nimble to be a dependency of the Quick package. (See also https://github.com/Quick/Quick/blob/master/Package.swift#L10)

Why isn't swift build able to link XCTest?

The XCTest framework on Darwin isn't a proper SDK framework, and is located at a different location within the Platform directory structure than frameworks like Foundation. This particular issue can be worked around by adding search paths as follows:

swift build \
-Xcc -F -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks \
-Xlinker -F -Xlinker /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks

...although there are a couple of other issues beyond that that still prevent the build from succeeding.

I've started work on branches (just here for now) which depend on building SwiftPM from master to gain access to swift test and should eventually fix up these issues. I'll open PRs in due time once the next round of snapshots are released and I get things cleaned up a little. I would also definitely be in favor of adding a SwiftPM OSX job to CI as well.

@modocache
Copy link
Member Author

@modocache modocache commented Feb 24, 2016

Awesome, thanks for all the info! I'm hoping to get more familiar with swiftpm soon. In the meantime, glad to see our swiftpm integration in such capable hands. 💯

@briancroom
Copy link
Member

@briancroom briancroom commented Feb 29, 2016

Just a quick update on this:

Nimble master now fully supports swift test on both OS X and Linux, and is tested on CI using swift test on both platforms 🎉 I'm really excited about this, and since swift test is so bleeding edge, I believe we are among the first libraries to integrate with it this thoroughly. Note though that we'll still have to cut a release for SwiftPM to do the right thing when other packages depend on it.

I have begun hacking on a branch for Quick, but with much less progress. On the OS X side, I believe we are blocked until this proposal gets implemented within SwiftPM, because hooking into Xcode's XCTest like QuickSpec needs to requires the use of NSInvocation which is unavailable from Swift. On Linux I'm running into a compiler crasher that I haven't had time to dig into yet.

Another challenge to address for Quick will be the fact that it has two test suites (QuickTests and QuickFocusedTests) which need to be built and run independently because of the way that global state is used in them. swift test doesn't currently support the concept of multiple independent test suites, however, so some sort of workaround will be needed.

I"m looking forward to making more progress here soon. Stay tuned!

@non-binary
Copy link

@non-binary non-binary commented Aug 10, 2016

@briancroom: How is this coming?

@modocache
Copy link
Member Author

@modocache modocache commented Aug 10, 2016

@briancroom mentioned in an email to Quick contributors a while back that he won't be able to contribute to the project for the foreseeable future. 💡

@non-binary
Copy link

@non-binary non-binary commented Aug 10, 2016

Ah okay! I wasn't around for that. My bad. I'll see what I can do with these later down the road.

@briancroom
Copy link
Member

@briancroom briancroom commented Aug 11, 2016

I've got a few more days where I'm happy to share knowledge here 😄

To be honest, I didn't take the time to work much further on this since my previous comment, however I do know that SwiftPM does now support building Objective-C modules, so it should be feasible to arrange the code such that SwiftPM builds a framework including the code required to integrate with Apple XCTest.

I'm not sure about the state of multiple test suites within a single SwiftPM package. Perhaps @aciidb0mb3r @ddunbar or @czechboy0 would have something to share on that point?

@aciidb0mb3r
Copy link

@aciidb0mb3r aciidb0mb3r commented Aug 11, 2016

multiple test modules with objc and swift should be ok as long as there is no c language sources mixed with swift sources.
I get errored out on this because Nimble(3.1.1) doesn't seem to be arranged for SwiftPM right now.

@ikesyo
Copy link
Member

@ikesyo ikesyo commented Jul 21, 2017

Resolved by #687.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Prioritization
Inbox / Needs Info / Waiting
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.