aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
  • Tools
  • About
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
  • Tools
  • About
aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
  • Tools
  • About
  • Programming
  • Software
  • Tech

Introducing Swift On Windows

  • aster_cloud
  • September 23, 2020
  • 5 minute read

The Swift project is introducing new downloadable Swift toolchain images for Windows! These images contain development components needed to build and run Swift code on Windows.

For over a year now, there has been a significant endeavour to port Swift to Windows in conjunction with the developer community at swift.org. The Windows support is now at a point where early adopters can start using Swift to build real experiences on this platform.


Partner with aster.cloud
for your next big idea.
Let us know here.


cyberpogo

 

Bringing Swift to Windows

Porting Swift to Windows is not about simply porting the compiler, but rather ensuring that the full ecosystem is available on the platform. This includes the compiler, the standard library, and the core libraries (dispatch, Foundation, XCTest). These libraries are part of what enables developers to write powerful applications with ease and without having to worry about many of the details of the underlying system. There are many technical details in the story of bringing Swift to a usable state on Windows, and if you are interested in them, I would recommend checking out my talk on the topic from the LLVM Developer Conference.

With these core libraries and the flexible interoperability of Swift with C, it is possible to develop applications on Windows purely in Swift while taking advantage of the existing corpus of libraries on the Windows platforms.

 

Example Application

This demo calculator is written entirely in Swift, with code seamlessly flipping between the application code written in Swift and the system libraries:

Calculator app written in Swift running on Windows

This project was built using:

  1. The Swift toolchain on Windows
  2. An installation of Visual Studio 2019 which delivers the other needed pieces in the form of CMake, Ninja, and the Windows SDK
Read More  Swift 5.3 Released!

Although the demo application is built with CMake, Swift Package Manager support on Windows is coming along. It will soon be possible to get the application building using swift build without needing CMake or Ninja.

Here you can see stepping through the application using lldb:

LLDB console debugging Swift application on Windows

 

Cross-Platform Applications

Early adopters like Readdle are experimenting with cross-platform applications written in Swift, easily bringing many of the existing Swift libraries to Windows to support their applications.

I had been working with Alexander at Readdle about his team’s work, and he sent me this note:

We at Readdle started experimenting with Swift on Windows more than a year ago, in Q2 of 2019. By that time we already released Spark for Android which uses Swift to share core code with iOS/macOS, and the opportunity to extend to one more platform was really tempting.

Despite some functionality being unready as of yet, Swift on Windows turned out to be fully satisfying our needs. In fact, some third party C/C++ dependencies gave us more headaches than Swift did itself. All business logic of Spark is located in a separate Core module. A pack of modules, actually, but we refer to them as Core. This allows us to use any UI framework on the target platform: AppKit on macOS, UIKit on iOS, native UI Toolkit on Android. So, basically, we had to port Spark Core on Windows. After all initial concepts were proved, it was mostly routine day-to-day work to bring it alive on Windows.

What we have now:

  • 9 Swift modules (255 739 SLOC, 2 133 source files)
  • 3 third party swift modules
  • 1452 tests (powered by XCTest)
  • Windows-based CI to keep all tests green
  • Heterogenous build system (partially CMake, partially custom scripts)

As a good example, pure Swift modules like CryptoSwift and OAuthSwift almost worked right out of the box. We did trivial imports adjustment, excluded a few AppKit/UIKit references and voilà!

Another challenge was to decide how to implement the user interface. After extensive discourse we ended up with Electron as the front-end part of future Spark for Windows. That meant we not only needed to be able to build Spark Core on Windows but also use it as a loadable addon for Node.js.

Node.js addon in pure Swift? That appeared to be surprisingly easy. Swift perfectly imports N-API headers. We still need three lines of C code plus one small C header to define addon entry point, but all logic is in Swift. Due to the crossplatform nature of Node.js, we were able to use macOS as a development platform with Xcode as IDE, and then use the agility of CMake to build the same code on Windows.

Since the first day we started, Swift on Windows did a giant step forward in terms of platform support and stability. I’d say, if you are thinking about extending your existing application codebase to platforms other than macOS/iOS – you absolutely can do it with Swift now, or, at least, soon. If you are maintaining a small Swift library – you could easily add Windows support already!

— Alexander Smarus; Product Engineering Lead at Spark Team, Readdle Inc

More details are available on Readdle’s blog.

Read More  Application Service Adapter For VMware Tanzu Application Platform: New Beta Release Now Available

Adding support for Windows to Swift is the beginning of a journey. The current support sets the first milestone where the language is usable. There is yet another even broader part of the ecosystem like lldb and the Swift Package Manager which still need more work to be as complete in their support for this different platform.

 

Getting Started and Getting Involved!

The Getting Started section has been updated with new information about using Swift on Windows! For the early adopters who are getting started and finding issues, please report them to the Swift Bug Tracker.

There are many opportunities for those interested in helping push Swift on Windows forward. One of the things that makes Swift easy to use is libraries: publishing new libraries and packages for Swift on Windows or porting existing ones is another way to get involved and help make working with Swift an ever greater delight.

For the ones interested in working on core tooling, there is plenty of work to be done to improve the debugger and to improve the Windows support in the Swift Package Manager. We invite you to check out the Swift Bug Tracker for the current issues and to send patches to the GitHub repositories. There is also a new section on the Swift forums to discuss the development of Swift on Windows. There the community can discuss issues or you can introduce yourself and let others know what area of the tooling you are focusing on. This is the perfect opportunity to become involved in the project and help it grow into a strong, vibrant, cross-platform ecosystem. We cannot wait to see what exciting things you build with Swift!

Read More  7 Ways To Turn Developer Experience Into A Competitive Edge

 

Saleem Abdulrasool is a member of the Swift Core Team and a software engineer at Google Brain.

Our humans need coffee too! Your support is highly appreciated, thank you!

aster_cloud

Related Topics
  • Readdle
  • Swift
  • Swift Bug Tracker
  • Windows
You May Also Like
View Post
  • Architecture
  • Data
  • Engineering
  • People
  • Programming
  • Software Engineering
  • Technology

Predictions: Top 25 Careers Likely In High Demand In The Future

  • June 6, 2023
View Post
  • Architecture
  • Platforms
  • Software
  • Solutions
  • Technology

What To Expect From Apple’s WWDC 2023

  • June 1, 2023
View Post
  • Tech

What Is Platform Engineering And Why Adopt It In Your Company?

  • June 1, 2023
View Post
  • Programming
  • Software Engineering
  • Technology

Build a Python App to Alert You When Asteroids Are Close to Earth

  • May 22, 2023
View Post
  • Programming

Illuminating Interactions: Visual State In Jetpack Compose

  • May 20, 2023
View Post
  • Containers
  • Public Cloud
  • Software
  • Software Engineering

How To Easily Migrate Your Apps To Containers — Free Deep Dive And Workshop

  • May 18, 2023
View Post
  • Software
  • Technology

Somehow OpenSearch Has Succeeded

  • May 16, 2023
View Post
  • Public Cloud
  • Software

Best Practices For Monetizing Cloud-based Technology And 5G Networks

  • May 15, 2023

Stay Connected!
LATEST
  • 1
    Microsoft Offers Azure ML Data Import CLI, SDK For Snowflake, Other Databases
    • June 8, 2023
  • 2
    Why Are Humans Afraid Of AI?
    • June 7, 2023
  • 3
    The Technical Architecture And Components Of A.I. Systems
    • June 7, 2023
  • 4
    Nature Already Inspired A.I. Than Most Realise
    • June 7, 2023
  • 5
    “A Field Guide To AI: For Business, Institutions, Society & Political Economy” — Your Essential Companion In Navigating the World of Artificial Intelligence.
    • June 7, 2023
  • 6
    Predictions: Top 25 Careers Likely In High Demand In The Future
    • June 6, 2023
  • 7
    A S.W.O.T. Analysis Of Current A.I. Systems
    • June 6, 2023
  • Apple-WWCD23-Vision-Pro-glass-230605 8
    Introducing Apple Vision Pro: Apple’s first spatial compute
    • June 5, 2023
  • 9
    Apple Unveils New Mac Studio And Brings Apple Silicon To Mac Pro
    • June 5, 2023
  • 10
    Apple Introduces M2 Ultra
    • June 5, 2023
about
Hello World!

We are aster.cloud. We’re created by programmers for programmers.

Our site aims to provide guides, programming tips, reviews, and interesting materials for tech people and those who want to learn in general.

We would like to hear from you.

If you have any feedback, enquiries, or sponsorship request, kindly reach out to us at:

[email protected]
Most Popular
  • 1
    tvOS 17 Brings FaceTime And Video Conferencing To The Biggest Screen In The Home
    • June 5, 2023
  • 2
    Apple Introduces The 15‑Inch MacBook Air
    • June 5, 2023
  • 3
    Huawei ICT Competition 2022-2023 Global Final Held In Shenzhen — 146 Teams From 36 Countries And Regions Win Awards
    • May 27, 2023
  • 4
    Building A Kubernetes Platform: How And Why To Apply Governance And Policy
    • June 4, 2023
  • 5
    Leave, This “United” “Kingdom”, This “Great” “Britain”
    • June 4, 2023
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.