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

Undefined symbols for architecture x86_64 #202

Closed
truizlop opened this issue Nov 22, 2016 · 6 comments
Closed

Undefined symbols for architecture x86_64 #202

truizlop opened this issue Nov 22, 2016 · 6 comments

Comments

@truizlop
Copy link

Version

0.7.1
git commit hash a687df108322bcd0c54b807dac4771be087e9774

Environment

MacOS X, console application

Description

Creating an extension to support Arbitrary on an enum results on build errors.

Steps To Reproduce

Create in the code target an enum like this:

enum Player : String {
    case one = "Player one", two = "Player two"
    
    var other : Player {
        switch(self) {
        case .one: return .two
        case .two: return .one
        }
    }
}

In the test target, create an extension to support Arbitrary:

import XCTest
import SwiftCheck
@testable import TennisKata

extension Player : Arbitrary {
    public static var arbitrary : Gen<Player> {
        return Gen<Player>.fromElementsOf([Player.one, Player.two])
    }
}

Expected Result

It should compile and build correctly.

Actual Result

Undefined symbols for architecture x86_64:
  "type metadata for TennisKata.Player", referenced from:
      static (extension in TennisKataTest):TennisKata.Player.arbitrary.getter : SwiftCheck.Gen<TennisKata.Player> in PlayerTest.o
      type metadata accessor for [TennisKata.Player] in PlayerTest.o
      protocol witness for static SwiftCheck.Arbitrary.shrink (A) -> [A] in conformance TennisKata.Player : SwiftCheck.Arbitrary in TennisKataTest in PlayerTest.o
      l_protocol_conformances in PlayerTest.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Additional Information

I am wondering why the syntax for Gen<Player>.fromElementsOf([Player.one, Player.two]) is not Swift 3.0, since from what I can see on the repo, it has actually been updated and it should be Gen<Player>.fromElements(of: [Player.one, Player.two]). Apparently my project is configured to use Swift 3.0 though.

@CodaFi
Copy link
Member

CodaFi commented Nov 22, 2016

This smells like a Swift bug. If optimizations are enabled for any of the targets involved, what happens if you turn them off?

@truizlop
Copy link
Author

They were not enabled for Debug and I disabled them for Release; still not working. Are you able to reproduce the bug? Am I using the library correctly? It is the first time I try to use it.

@truizlop
Copy link
Author

I created this sample project where the issue is isolated so that you can take a look at it - hope it helps
SwiftCheck-Issue202.zip

@CodaFi
Copy link
Member

CodaFi commented Nov 22, 2016

Ah, wait, this is a command line tool? You can't import and use that kind of module without a test host like an enclosing application. The test is going to run outside of the context of the running application and so it makes sense it wouldn't have access to its symbols. Try testing a framework target instead.

@CodaFi
Copy link
Member

CodaFi commented Nov 22, 2016

Notice, for example, that command line tools like Carthage keep testable logic in CarthageKit and test that by linking against it but the tool itself has no testing bundle?

@truizlop
Copy link
Author

Ok, adding the files to the Test target as well solved the issue. Thanks for the hint!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants