PureSwift / SwiftFoundation

Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. (Pure Swift, Supports Linux)
MIT License
625 stars 52 forks source link

Building on OS X with SPM fails #23

Open ky1ejs opened 8 years ago

ky1ejs commented 8 years ago

This is because the JSONParse.swift uses the JSON module on OS X:

https://github.com/PureSwift/SwiftFoundation/blob/develop/Sources/SwiftFoundation/JSONParse.swift#L9

but in the Package.swift the CJSONC module is defined as a dependancy instead:

https://github.com/PureSwift/SwiftFoundation/blob/develop/Package.swift#L8

Is there a reason for no using CJSONC on OS X or vice versa for JSON on Linux?

ky1ejs commented 8 years ago
/Users/kylejm/Developer/Loot/OSS/bitrise-slack/Packages/SwiftFoundation-1.1.1/Sources/SwiftFoundation/JSONParse.swift:10:12: error: no such module 'JSON'
    import JSON
           ^
colemancda commented 8 years ago

SPM is for Linux only. Use Carthage for Darwin platforms.

ky1ejs commented 8 years ago

Sorry, I must be missing something. Where is SPM documented as only being for Linux platforms? Or do PureSwift projects specifically only support SPM for Linux?

colemancda commented 8 years ago

PureSwift only supports SPM for Linux.

Danappelxx commented 8 years ago

Why is this, again? There's nothing stopping you from supporting both...

colemancda commented 8 years ago

There isn't, im just not committed to always maintaining it since I see little benefit from it. Also you should always use dynamic frameworks on OS X, even for server applications. See http://colemancda.github.io/programming/2015/02/12/embedded-swift-frameworks-osx-command-line-tools/

Danappelxx commented 8 years ago

There's no maintenance involved and it's actually very important for a lot of people. People don't develop SPM applications on Linux, they do it on OSX. Building on OSX is not always done through Xcode, especially if you're not making a framework.

I think this is worthy of more discussion so I'm going to go ahead and reopen this.

colemancda commented 8 years ago

Ok then.

ky1ejs commented 8 years ago

I totally agree with @Danappelxx. A great deal, if not the majority, of Swift developers creating apps for Linux will be developing them on Mac OS. Having to use two different dependancy managers on each platform just seems absurd, especially when the idea is that SPM is made agnostically of the platform.

It's kind of ironic that Carthage, the dependancy manager you suggest, statically links Swift. Dynamically linking against CLI applications, which a lot of server apps will be, isn't straight forward. There is discussion all over the place about it:

I like what neonichu said about this in the last link in that list back in June 2015 when SPM was not public:

I don't think it is entirely solvable by us, considering that there is no "standard" way to distribute frameworks alongside a command line tool.

I'm sure Apple intend for SPM to be the "standard".

colemancda commented 8 years ago

There is no support for SPM for iOS, WatchOS or tvOS. Also the link you mentioned regarding Carthage statically linking Swift, does not apply if you follow the my method. If you use a App Bundle Structure, it will dynamically link it. Getting down to business, I am open to supporting this since users may want it, but I personally will not make the changes to support this. If you want to open a PR, I am open to that.

On OS X the only dependency would be JSON-C which you can get from Homebrew. I cannot name the JSON-C dynamic framework CJSONC, because the generated module map expects "JSON" to be the name of the module. That has been my issue so far.

ky1ejs commented 8 years ago

Cool, I'll open a PR as soon as I can get around to it, but hopefully Foundation gets to implementing NSURLSession etc. first. The side project I was working on with SeeURL has taken a lower priority for a while.

Blackjacx commented 8 years ago

What about this issue???

foldericon commented 7 years ago

The solution for this issue would be to install JSON-C using homebrew and remove the "import JSON" statement, right?