Hacker News new | ask | show | jobs
by smaili 4295 days ago
Stupid question but is Swift just compiled into Objective-C? I'm asking because I'd like to know if I can write an app in Swift that can run on iOS6.
4 comments

No, more correctly ObjC is compiled into assembler that uses a C/C++ runtime.

Swift uses some C/C++ under the hood, and integrates it's object model into the ObjC object model (which is C). However, swift structs are not objects, from what I can tell they are virtually identical to structs in C (from a memory layout perspective).

Some swift objects are incompatible with the ObjC object model and cannot really be used from ObjC or really any other language (it does name mangling like C++ which makes interfacing rather difficult)

https://developer.apple.com/library/mac/documentation/Cocoa/...

> I'd like to know if I can write an app in Swift that can run on iOS6.

No. From Xcode6 release notes:

"iOS 7 and OS X 10.9 minimum deployment target

The Swift compiler and Xcode now enforce a minimum deployment target of iOS 7 or OS X Mavericks. Setting an earlier deployment target results in a build failure."

To clarify, is Xcode 6 enforcing a minimum deployment target of iOS 7 even if the app is written in Objective-C and not Swift? If so, I think I'll need to stay on Xcode 5 a bit longer.
iOS6 user base will be miniscule in a few weeks unless you are targeting corporate or education markets which update slowly.
Swift is just a fresh new language which is compiled statically just like C/C++.

Swift's Objective-C compatibility mode is a kind of ugly extension feature to support their legacy code. The compiler makes inter-op stuffs automatically.

You can target only down to 7.0 because Apple set the goal of 7.0. There should be some stuffs required to support Swift, anyway it doesn't matter unless you're a runtime engineer. Point is earlier than 7.0 is out of support by Apple.

swift compiles to llvm not objective c.