Open ky1ejs opened 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
^
SPM is for Linux only. Use Carthage for Darwin platforms.
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?
PureSwift only supports SPM for Linux.
Why is this, again? There's nothing stopping you from supporting both...
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/
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.
Ok then.
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".
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.
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.
What about this issue???
The solution for this issue would be to install JSON-C using homebrew and remove the "import JSON" statement, right?
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?