Table of Contents
What is swiftui
SwiftUI is a toolkit for building apps with Swift on the web and mobile devices. The framework’s goal is to simplify the process of deploying apps on any platform – be it iOS, macOS, tvOS or watchOS. You can build a single Swift-based UI codebase, and it will run on any of the mentioned platforms.
Here are a few examples of the framework in action:
To see a full list of our partners who currently support the SwiftUI framework, head to the website.
Facebook is also investing heavily on what they call as “Frictionless sharing” – a great example is this blog post on their website. They are also sponsoring Toolbox, an initiative around supporting iOS developers transitioning to Swift and our open source projects. Visit their blog for more information. You can read more about Toolbox here: https://facebookengineering.com/toolbox
What were previously known as “iOS WKWebViews” (also referred to as “UI WebViews”) are now known as “WebViews”. They support the same plugin API and capabilities of UI Webviews, and in addition, they provide an implementation of the UIWebView delegates. A visual example is available in our documentation.

How to use swiftui
To use SwiftUI, you’ll have to install it into your project. For example, if your project is called SingleViewApp and it is based on Xcode 9, the following instruction allows you to import SwiftUI into that project: framework “swiftui” // imports library “SwiftUI” // imports (required) You can import the SwiftUI Core and the SwiftUI iOS UI Framework individually. You can also choose to import the entire framework (including both UI Frameworks). To install the SwiftUI Core, add the following dependency to your project: swift build dependency “swift-core/swift-ui-core” If you are not using your own UI engine, you can import the SwiftUI Core directly: swift build framework “swift.plist” // imports core “swift.framework” // imports (required) To download and copy the SwiftUI iOS UI Framework into your project, add this to your project’s info.plist file: application identified by “com.companyname.ApplicationName” {
identifier “com.companyname.ApplicationName”
} dependencies {
compile “swift.foundation:ios-base:4.2” // imports the Core framework (required)
compile “swift.ui:ios-ui-core:4.2” // imports the iOS UI Framework (required)
// additional imports can be specified here, such as view management libraries, etc., e.g.: import “com.companyname.DependencyName” as “DependencyName”
} or: import “swift.ui” // entire UI framework, including iOS and macOS

Pros and cons of swiftui
The SwiftUI Core is very basic, and doesn’t use any complicated code. This means that even if you have complex logic in your project, it will still run. The framework has a basic architecture. Its main components are a Server , which is connected to all the UI Elements, and a Stack, which bundles the UI Elements (you can also use other means of bundling).
Another benefit is that SwiftUI has a quite easy API for defining UI Elements, compared to its competitors. I won’t compare it to React, because the way of defining components in React is not actually their own API. They just use JavaScript + JSX.
SwiftUI also supports Multi-Binding . This means that we can bind the same value to multiple UI elements at once, which we can then use to define animations, or even cascade effects if we want by using functions. (This means you can use multiple UI Elements to respond to the same event, which is something that React does not do.)
On the other hand, SwiftUI has a bad performance, even on very simple projects. On my 1000 lines of code project with a lot of UI Elements (1% has more than 2 UI Elements), it is 150 times slower than React js. I am using Electron with SwiftUI:

When to use swiftui
You should use SwiftUI when you want to develop a single UI codebase and run it from any platform. For example, if you want to make an app that’s available in both iOS and Android, you should use SwiftUI. It will take less time to deploy your app, since you’re working with a single codebase. Furthermore, you can quickly make changes on your app to take advantage of new iOS features or make the app support a new platform.
In short, SwiftUI is a good choice if you want to focus on developing your app and don’t care about different platforms.
Here are some of the main differences between SwiftUI and UIKit:
SwiftUI views can be easily declared, since they’re just UIViews.
SwiftUI supports a single codebase, so you don’t have to write the same code each time you have to develop an app.
SwiftUI doesn’t support custom view controllers, so it’s not a good choice if you want to create your own custom views. This means that you’ll have to use UIKit if you want custom views.
SwiftUI doesn’t support universal storyboards, so you won’t be able to develop views for both iOS and macOS in the same view controller.
SwiftUI relies on code instead of Interface Builder (IB), so you won’t be able to use IB to create your UI. This means that you’ll have to edit your UI by hand, which could be time-consuming.
