19

I am looking for an Apple Swift compiler for Windows (running under Windows and producing code for Windows), without having to virtualize any OS. It needs to run at least on Windows 7 x64.

13

Silver runs on Windows and allows you to compile Swift code to Java and .NET.

Alternatively, you can compile Swift code online in a web browser on any platform, including Windows. Try:

5

Swift is build on the same LLVM Compiler, Objective-C is build on. (See Wikipedia)
So you need an Obj-C environment. And that is a bit complicated, but possible.

It would be much easier to build a Virtual Machine or a Hackintosh.
And as you can read from this answer, it is not a good Idea coding Obj-C (or Swift) on a PC.

3

Swift for Windows now available on Microsoft Codeplex.
https://swiftforwindows.codeplex.com/

enter image description here

System Requirement - Visual C++ Redistributable for Visual Studio 2015.


Or you can use official swift version on Bash On Ubuntu On Windows 10 (Anniversary Update). Checkout full step-wise guide here - Instal Swift 3.0 on Windows 10 Anniversary Update

  • the requirements of first link now changed. now it requires windows 10 x64 , but does not require visual studio any more. – Muhammad Annaqeeb Jun 30 '17 at 13:09
2

Apple shipped Foundation and other ObjC libraries with Safari, but Safari for Windows stopped at 5.1.7. But then iTunes was rewritten to use ObjC libraries, and they are pretty available and up-to-date. There are two problems, however. First, it is not legal to bundle "Application Support.msi" (use 7zip to unpack iTunes installer, and you will find this file), but you can probably advice user to install either Safari for Windows or iTunes for Windows to make your program work. Second, there is no working Objective-C compiler for Windows compatible with Apple libobjc.dll. (GNUStep, Cocotron and Apple use different ABI IIUC). libobjc.dll sources are open, and someone reported to compile it on MSVS (libobjc is plain C library). So it's not a black box, all the keys are lying around. There are rumours that Apple has Objective-C-to-C translator for Windows targeting MSVS as opposed to generating native code directly. Anyway, even if you don't have matching compiler, you can still make GNU-Objective-C-to-Apple-Objective-C bridge or Delphi-to-Objective-C bridge, Nimrod-to-Objective-C bridge or whatever-to-Objective-C using ScriptingBridge XML files.

UPD1 Found on the net, never tested: clang -rewrite-objc -ObjC main.m -o out.cpp (probably must be run on Mac OS X, probably not)

Swift is available in XCode 6 beta, but on Apple Open Source website I can only see XCode 5.1 opensource downloads, and there is no Swift here. So, current answer: no.

1

Apple made Swift to open source last year. Swift for Windows port (forked, incomplete) can be downloaded at swift windows

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.