3

I am interested in writing Swift code on Linux. Now I know I can install Swift on Linux, that's great. Does the Linux installation of Swift also include CoreData? That would be terrific.

Also, is it possible to compile C code and link it to Swift code on Linux, as it is possible on MacOS?

I found this description but it is more than three years old at this point; has there been some progress since then?

K7AAY
  • 3,816
  • 4
  • 23
  • 39

1 Answers1

1

Yes, it is possible to put C into a Swift Package. Such C packages can be linked with other Swift Packages. For example, see "Imported C and Objective-C APIs"

However, CoreData is not part of the cross platform Swift Foundation Libraries.

As a crossplatform from persistant data alternative to CoreData, it is possible to use SQLite C with a layer that provides a Swift API.

Vapor server and companion iOS app examples provides a discussion an approach to have C & Swift packages which run cross platform on iOS, macOS and Linux.

  • Re your rejected edits on [tag:swift], please (re-)read the tag wiki excerpt guidance, in particular point 4. – Stephen Kitt May 14 '19 at 21:17
  • @StephenKitt Unlike Q&A, the tag edit process provides for limited communication and revision. It's voted up or down. At this moment, Acer Swift and OpenStack Swift return as many results the [swift] tag on the Unix & Linux Stack Exchange. As such, the re-submit comment noted that the 'swift' tag itself can be ambiguous in the context of Unix/Linux ... for re-evaluation, per your prior comment. ... – marc-medley May 14 '19 at 22:46
  • @StephenKitt ... the tag wiki had no text whatsoever when I started trying to proposing what seemed to be a resonable minimal something better than nothing ... https://unix.stackexchange.com/posts/518779/revisions. The rejects are OK. Your feedback is appreciated. And, your current edits look like a good example. So, in the end, it took both our efforts to go from zero to something useful. Peace. ;-) – marc-medley May 14 '19 at 22:48