orlandos-nl / BSON

Native Swift library for BSON (http://bsonspec.org)
https://orlandos.nl/docs/mongokitten/articles/bson
MIT License
109 stars 35 forks source link

Specific Build Instructions? #16

Closed perlmunger closed 8 years ago

perlmunger commented 8 years ago

The README says to use the Swift package manager, but it's unclear as to how to do so. Running the command swift build from the command line finishes without an error, but now what? What can I do with the build product. If it's just importing the frameworks, that's fine, but next steps are unclear. Where do I get the .framework file?

Can I simply add the sources to my project and build that way? That would be my preference. I've tried that, but I get the error:

BSON/Sources/ValueConvertible.swift:89:11: Use of undeclared type 'RegularExpression'

Thanks in advance.

Joannis commented 8 years ago

How did you create your project? And what kind of project is it?

perlmunger commented 8 years ago

It's just a Swift project for iOS I created from scratch in Xcode 8.0 (8A218a). When I say I ran swift build, I meant inside the BSON root directory--not my project directory.

Joannis commented 8 years ago

I guessed so. BSON supports SPM because it's almost entirely meant for Server Side Swift. You can use it for macOS and iOS projects but it'll require you to create an xcodeproj using swift package generate-xcodeproj and then modifying the xcode project to output a .framework or link the xcode project to your own project.

perlmunger commented 8 years ago

Ok. I tried the swift package generate-xcodeproj and the resulting Xcode project will generate a .framework file, however, it doesn't work when I switch the build target to an iOS device--again giving me the same warning about RegularExpression being an undeclared type. Is that because RegularExpression is only available on macOS? Is it a Foundation class?

Joannis commented 8 years ago

RegularExpression is Foundation. Isn't that available on iOS? I can add a compiler flag that'll not compile that code on iOS of you'd prefer that

Joannis commented 8 years ago

I went ahead and added iOS regardless. Try to fetch BSON 3.8.2

perlmunger commented 8 years ago

Perfect! Thanks for doing that.