Getting existing Objc to work with Swift on Linux


(Edgar Aroutiounian) #1

Greetings,

I have some Objective-C that I really want to have work on linux. I saw that core-libs foundation has been implemented for swift so I have some hopes.

Ideally I’m looking for a self contained example where I can call Objective C code from swift, think command line tool.

If this is possible, I’d very much appreciated an example including build steps and directory structure needed.

Thank you.


(Jens Alfke) #2

I have some Objective-C that I really want to have work on linux. I saw that core-libs foundation has been implemented for swift so I have some hopes.

This is a re-implementation of a Foundation-like API in pure(?) Swift, not an Obj-C framework.

My understanding is that the Swift/Obj-C integration is not part of the open-source release, because Apple’s Obj-C runtime is not open source.

Ideally I’m looking for a self contained example where I can call Objective C code from swift, think command line tool.

You should be able to do this by calling the Obj-C runtime’s C API from Swift as you’d call any other C API. (Of course, the details of that C API depend on which runtime you’re using on Linux — IIRC there are at least two of them, and their C APIs are not the same as Apple’s.)

—Jens

···

On Jan 11, 2016, at 11:54 PM, Edgar Aroutiounian via swift-users <swift-users@swift.org> wrote:


(Dru Satori) #3

Correct me if I’m wrong. In order for this to work, wouldn’t you need the GnuStep Obj-C libraries compiled under LLVM installed and available on your Linux install to get all of the Foundation bits for Objective-C anyways ?

···

On 1/12/16, 2:54 AM, "swift-users-bounces@swift.org on behalf of Edgar Aroutiounian via swift-users" <swift-users-bounces@swift.org on behalf of swift-users@swift.org> wrote:

Greetings,

I have some Objective-C that I really want to have work on linux. I saw that core-libs foundation has been implemented for swift so I have some hopes.

Ideally I’m looking for a self contained example where I can call Objective C code from swift, think command line tool.

If this is possible, I’d very much appreciated an example including build steps and directory structure needed.

Thank you.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Tom Sheffler) #4

GnuStep on Linux works well, even though the compilation and installation can be a little bit challenging. I spent part of December doing just that. The GUI support isn’t so good (I’d avoid that), but Blocks, Dispatch and ARC and @properties all work well together, and Foundation works fine. (or at least the bits of it I’ve used).

Tom

···

On Jan 12, 2016, at 9:10 AM, Dru Satori via swift-users <swift-users@swift.org> wrote:

Correct me if I’m wrong. In order for this to work, wouldn’t you need the GnuStep Obj-C libraries compiled under LLVM installed and available on your Linux install to get all of the Foundation bits for Objective-C anyways ?

On 1/12/16, 2:54 AM, "swift-users-bounces@swift.org on behalf of Edgar Aroutiounian via swift-users" <swift-users-bounces@swift.org on behalf of swift-users@swift.org> wrote:

Greetings,

I have some Objective-C that I really want to have work on linux. I saw that core-libs foundation has been implemented for swift so I have some hopes.

Ideally I’m looking for a self contained example where I can call Objective C code from swift, think command line tool.

If this is possible, I’d very much appreciated an example including build steps and directory structure needed.

Thank you.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Edgar Aroutiounian) #5

Tom,

Can you provide a self contained example that uses NSStrings and compiles on Linux? I also need to use headers from mach, I suppose I could just include them as well since they are just definitions

···

On Jan 12, 2016, at 9:27 AM, Tom Sheffler <tom.sheffler@gmail.com> wrote:

GnuStep on Linux works well, even though the compilation and installation can be a little bit challenging. I spent part of December doing just that. The GUI support isn’t so good (I’d avoid that), but Blocks, Dispatch and ARC and @properties all work well together, and Foundation works fine. (or at least the bits of it I’ve used).

Tom

On Jan 12, 2016, at 9:10 AM, Dru Satori via swift-users <swift-users@swift.org> wrote:

Correct me if I’m wrong. In order for this to work, wouldn’t you need the GnuStep Obj-C libraries compiled under LLVM installed and available on your Linux install to get all of the Foundation bits for Objective-C anyways ?

On 1/12/16, 2:54 AM, "swift-users-bounces@swift.org on behalf of Edgar Aroutiounian via swift-users" <swift-users-bounces@swift.org on behalf of swift-users@swift.org> wrote:

Greetings,

I have some Objective-C that I really want to have work on linux. I saw that core-libs foundation has been implemented for swift so I have some hopes.

Ideally I’m looking for a self contained example where I can call Objective C code from swift, think command line tool.

If this is possible, I’d very much appreciated an example including build steps and directory structure needed.

Thank you.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Quinn “The Eskimo!”) #6

Just FYI, Apple's Obj-C runtime /is/ open source as part of Darwin, although that fact doesn't change your overall conclusion about Swift / Obj-C integration.

<http://www.opensource.apple.com/source/objc4/objc4-680/>

Share and Enjoy

···

On 12 Jan 2016, at 16:51, Jens Alfke via swift-users <swift-users@swift.org> wrote:

… Apple’s Obj-C runtime is not open source.

--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware