Libraries written in Objective-C in Swift 3


(Mike Berg) #1

Hi everyone,

A question has come up on my project that nobody seems to have an answer
for. I was hoping someone here might know:

On my project, we have a longstanding iOS application that has both objC
and swift source files. As is the case for most old apps out there (a few
years), we regularly use swift code in objC and vice versa.

We have been keeping tabs on how Swift has been expanding and we noticed
that with Swift 3, the foundation classes will be rewritten in swift. So
does this mean that all Swift classes using Foundation automatically start
using Foundation written in Swift or is it opt-in? If it’s mandatory, then
will libraries dependent on the Objective-C runtime no longer work (i.e.
the Alamofire git repo)?

Thanks for reading and take care,

···

--
Michael Berg
Technical Analyst
Solstice Mobile
(630) 414-6938


(David Smith) #2

Hi Mike,

The Foundation shipping with OS X and iOS is still written in Objective-C. The Swift-Corelibs Foundation is for use on other platforms currently.

  David

···

On Apr 22, 2016, at 2:03 PM, Mike Berg via swift-dev <swift-dev@swift.org> wrote:

Hi everyone,

A question has come up on my project that nobody seems to have an answer for. I was hoping someone here might know:

On my project, we have a longstanding iOS application that has both objC and swift source files. As is the case for most old apps out there (a few years), we regularly use swift code in objC and vice versa.

We have been keeping tabs on how Swift has been expanding and we noticed that with Swift 3, the foundation classes will be rewritten in swift. So does this mean that all Swift classes using Foundation automatically start using Foundation written in Swift or is it opt-in? If it’s mandatory, then will libraries dependent on the Objective-C runtime no longer work (i.e. the Alamofire git repo)?

Thanks for reading and take care,
--
Michael Berg
Technical Analyst
Solstice Mobile
(630) 414-6938
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev


(Philippe Hausler) #3

Hi everyone,

A question has come up on my project that nobody seems to have an answer for. I was hoping someone here might know:

On my project, we have a longstanding iOS application that has both objC and swift source files. As is the case for most old apps out there (a few years), we regularly use swift code in objC and vice versa.

We have been keeping tabs on how Swift has been expanding and we noticed that with Swift 3, the foundation classes will be rewritten in swift. So does this mean that all Swift classes using Foundation automatically start using Foundation written in Swift or is it opt-in? If it’s mandatory, then will libraries dependent on the Objective-C runtime no longer work (i.e. the Alamofire git repo)?

The foundation classes are not being re-written in Swift (for Darwin, the linux versions however are). The current proposal on the evolution list is for structures, which act in parallel to their reference type counterparts. You can still use a reference type where it makes sense, but now you can use a struct type where that is desired for a few new types.

One slight change that might have some effect is how the APIs are imported. If an API exposed a return type of NSData now it will return a struct Data. That can easily be converted back via using `as NSData`.

···

On Apr 22, 2016, at 2:03 PM, Mike Berg via swift-dev <swift-dev@swift.org> wrote:

Thanks for reading and take care,
--
Michael Berg
Technical Analyst
Solstice Mobile
(630) 414-6938
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev


(Chris Bailey) #4

Is there a view (yet) on if/when/how the "Swift" implementation of
Foundation will be used on Darwin?

Currently under TestFoundation, the "Swift" version is its imported as
SwiftFoundation on Darwin. Is the medium/long term view? ie, that the
Swift implementation will be "SwiftFoundation", with function renaming
done to drop the "NS", thereby allowing developers to keep their existing
applications on the Obj-C implementation, or consciously decide to migrate
to the Swift version?

Thanks,

Chris

···

From: Philippe Hausler via swift-dev <swift-dev@swift.org>
To: Mike Berg <mberg@solstice-consulting.com>
Cc: Justin Baumgartner <jbaumgartner@solstice-consulting.com>,
swift-dev@swift.org
Date: 22/04/2016 22:36
Subject: Re: [swift-dev] Libraries written in Objective-C in Swift
3
Sent by: swift-dev-bounces@swift.org

On Apr 22, 2016, at 2:03 PM, Mike Berg via swift-dev <swift-dev@swift.org> wrote:

Hi everyone,

A question has come up on my project that nobody seems to have an answer

for. I was hoping someone here might know:

On my project, we have a longstanding iOS application that has both objC

and swift source files. As is the case for most old apps out there (a few
years), we regularly use swift code in objC and vice versa.

We have been keeping tabs on how Swift has been expanding and we noticed

that with Swift 3, the foundation classes will be rewritten in swift. So
does this mean that all Swift classes using Foundation automatically start
using Foundation written in Swift or is it opt-in? If it’s mandatory, then
will libraries dependent on the Objective-C runtime no longer work (i.e.
the Alamofire git repo)?

The foundation classes are not being re-written in Swift (for Darwin, the
linux versions however are). The current proposal on the evolution list is
for structures, which act in parallel to their reference type
counterparts. You can still use a reference type where it makes sense, but
now you can use a struct type where that is desired for a few new types.

One slight change that might have some effect is how the APIs are
imported. If an API exposed a return type of NSData now it will return a
struct Data. That can easily be converted back via using `as NSData`.

Thanks for reading and take care,
--
Michael Berg
Technical Analyst
Solstice Mobile
(630) 414-6938
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

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


(Tony Parker) #5

Hi Chris,

Is there a view (yet) on if/when/how the "Swift" implementation of Foundation will be used on Darwin?

Currently under TestFoundation, the "Swift" version is its imported as SwiftFoundation on Darwin. Is the medium/long term view? ie, that the Swift implementation will be "SwiftFoundation", with function renaming done to drop the "NS", thereby allowing developers to keep their existing applications on the Obj-C implementation, or consciously decide to migrate to the Swift version?

Thanks,

Chris

We don’t have any plans to replace the Objective-C Foundation with the Swift one on Darwin.

I suspect that as we write more code in the overlay (the value types proposal I sent out to swift-evolution on Friday is a good example of this), we can share more code on that side.

- Tony

···

On Apr 25, 2016, at 5:45 AM, Chris Bailey via swift-dev <swift-dev@swift.org> wrote:

From: Philippe Hausler via swift-dev <swift-dev@swift.org>
To: Mike Berg <mberg@solstice-consulting.com>
Cc: Justin Baumgartner <jbaumgartner@solstice-consulting.com>, swift-dev@swift.org
Date: 22/04/2016 22:36
Subject: Re: [swift-dev] Libraries written in Objective-C in Swift 3
Sent by: swift-dev-bounces@swift.org

> On Apr 22, 2016, at 2:03 PM, Mike Berg via swift-dev <swift-dev@swift.org> wrote:
>
> Hi everyone,
>
> A question has come up on my project that nobody seems to have an answer for. I was hoping someone here might know:
>
> On my project, we have a longstanding iOS application that has both objC and swift source files. As is the case for most old apps out there (a few years), we regularly use swift code in objC and vice versa.
>
> We have been keeping tabs on how Swift has been expanding and we noticed that with Swift 3, the foundation classes will be rewritten in swift. So does this mean that all Swift classes using Foundation automatically start using Foundation written in Swift or is it opt-in? If it’s mandatory, then will libraries dependent on the Objective-C runtime no longer work (i.e. the Alamofire git repo)?

The foundation classes are not being re-written in Swift (for Darwin, the linux versions however are). The current proposal on the evolution list is for structures, which act in parallel to their reference type counterparts. You can still use a reference type where it makes sense, but now you can use a struct type where that is desired for a few new types.

One slight change that might have some effect is how the APIs are imported. If an API exposed a return type of NSData now it will return a struct Data. That can easily be converted back via using `as NSData`.

>
> Thanks for reading and take care,
> --
> Michael Berg
> Technical Analyst
> Solstice Mobile
> (630) 414-6938
> _______________________________________________
> swift-dev mailing list
> swift-dev@swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev

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

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