• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Need for Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need for Swift


  • Subject: Re: Need for Swift
  • From: Jens Alfke via Cocoa-dev <email@hidden>
  • Date: Tue, 15 Oct 2019 09:52:08 -0700


> On Oct 15, 2019, at 9:40 AM, Richard Charles via Cocoa-dev
> <email@hidden> wrote:
>
> 2. Another option is Swift but it has zero integration with C++. So this is
> really not a choice at all.

Swift integrates with C. So you can declare C APIs to your C++ codebase, and
call those from Swift. This does mean writing a lot of C++ wrapper code in the
form of extern "C" functions that call your C++ methods. Which is admittedly
extra work, but hardly rocket science.

For context: I work on a database library[1] implemented in C++ that provides
exactly such a C API, which is then used by higher-layer frameworks written in
Objective-C, Swift, Java, and C#. So I know this works and is not an
unreasonable amount of work. Here [2] is an example source file if you want to
see what it looks like. (Note that some of the boilerplate is to catch
exceptions thrown by the C++ layer; if your C++ doesn't use exceptions, you
don't need that.)

—Jens

[1]: https://github.com/couchbase/couchbase-lite-core
[2]:
https://github.com/couchbase/couchbase-lite-core/blob/master/C/c4DocExpiration.cc
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Need for Swift
      • From: Turtle Creek Software via Cocoa-dev <email@hidden>
References: 
 >Re: Need for Swift (From: Turtle Creek Software via Cocoa-dev <email@hidden>)
 >Re: Need for Swift (From: Richard Charles via Cocoa-dev <email@hidden>)

  • Prev by Date: Re: Need for Swift
  • Next by Date: Re: Need for Swift
  • Previous by thread: Re: Need for Swift
  • Next by thread: Re: Need for Swift
  • Index(es):
    • Date
    • Thread