• Stars
    star
    1,382
  • Rank 34,002 (Top 0.7 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

WIP — OpenSwiftUI is an OpenSource implementation of Apple's SwiftUI DSL.

OpenSwiftUI

OpenSwiftUI is an OpenSource implementation of Apple's SwiftUI DSL (Domain-specific language).

The project's goal is to stay close to the original API as possible.

Currently, this project is in early development.

Background

Apple introduced SwiftUI at WWDC 19. Since then, developing applications with graphical user interfaces became more comfortable to read, write, and maintain. Unfortunately, the principle "Learn once, apply anywhere" works on Apple platforms, only.

Swift runs on Apple platforms, the web, Linux, Windows, and even on embedded devices. Wouldn't it be great if you could write GUI based applications with SwiftUI on platforms that run Swift?

SwiftUI on your platform

OpenSwiftUI provides the API — other projects can implement the actual rendering of UI elements for different platforms like Linux, Windows, Embedded, and many more.

SwiftUIEmbedded is one of the first projects that make use of OpenSwiftUI (Demo).

Demo

Contributing

Over time and collective guesswork, it should be possible to re-create the complete SwiftUI API from Apple. Check the Status overview to see what's missing or needs to be completed.

A good starting point is to get familiar with the SwiftUI interface, focus on certain functionality, and try to re-implement it. A helpful tool is to use reflection (Mirror(reflecting: …)) to peek into SwiftUI types and instances. This reveals the internal structure of instances (properties, types, names and inheritance).

Once you implemented a missing piece, please feel free to contribute a pull request.

Please note:

Private methods and properties of SwiftUI should be prefixed by an _ (underscore) and marked as public in OpenSwiftUI. Doing this is necessary because the frontend might need access.

Xcode 11.2 or higher is required.

Status

Views and Controls

Essentials

Status Name Notes
protocol View

Text

Status Name Notes
struct Text
struct TextField
struct SecureField
struct Font

Images

Status Name Notes
⚠️ struct Image CGImage not supported

Buttons

Status Name Notes
struct Button
struct NavigationLink
struct MenuButton
struct EditButton
struct PasteButton

Value Selectors

Status Name Notes
struct Toggle
⚠️ struct Picker
struct DatePicker
struct Slider
⚠️ struct Stepper

Supporting Types

Status Name Notes
struct ViewBuilder
protocol ViewModifier

View Layout and Presentation

Stacks

Status Name Notes
struct HStack
struct VStack
struct ZStack

Lists and Scroll Views

Status Name Notes
struct List
protocol DynamicViewContent
protocol Identifiable Provided by Swift.
struct ForEach
struct ScrollView
⚠️ enum Axis

Container Views

Status Name Notes
struct Form
⚠️ struct Group
struct GroupBox
struct Section

Spacer and Dividers

Status Name Notes
struct Spacer
struct Divider

Architectural Views

Status Name Notes
struct NavigationView
struct TabView
struct HSplitView
struct VSplitView

Presentations

Status Name Notes
struct Alert
struct ActionSheet

Conditionally Visible Items

Status Name Notes
struct EmptyView
struct EquatableView

Infrequently Used Views

Status Name Notes
⚠️ struct AnyView init?(_fromValue value: Any) missing.
struct TupleView

Drawing and Animation

Essentials
Status Name Notes
⚠️ protocol Shape

Animation

Status Name Notes
struct Animation
protocol Animatable
protocol AnimatableModifier
func withAnimation<Result>(Animation?, () -> Result) -> Result
struct AnimationPair
struct EmptyAnimationData
struct AnyTransition

Shapes

Status Name Notes
⚠️ struct Rectangle
enum Edge
struct RoundedRectangle
⚠️ struct Circle
struct Ellipse
struct Capsule
struct Path

Transformed Shapes

Status Name Notes
protocol InsettableShape
struct ScaledShape
struct RotatedShape
struct OffsetShape
struct TransformedShape

Paints, Styles, and Gradients

Status Name Notes
struct Color
struct ImagePaint
struct Gradient
struct LinearGradient
struct AngularGradient
struct RadialGradient
struct ForegroundStyle
struct FillStyle
protocol ShapeStyle
enum RoundedCornerStyle
struct SelectionShapeStyle
struct SeparatorShapeStyle
struct StrokeStyle

Geometry

Status Name Notes
struct GeometryProxy
struct GeometryReader
protocol GeometryEffect
struct Angle
struct Anchor
struct UnitPoint
enum CoordinateSpace
struct ProjectionTransform
protocol VectorArithmetic

State and Data Flow

Bindings

Status Name Notes
⚠️ struct Binding

Data-Dependent Views

Status Name Notes
struct State
struct ObservedObject
struct EnvironmentObject
struct FetchRequest
struct FetchedResults
⚠️ protocol DynamicProperty func update() missing.

Environment Values

Status Name Notes
struct Environment
struct EnvironmentValues

Preferences

Status Name Notes
protocol PreferenceKey
struct LocalizedStringKey

Transactions

Status Name Notes
struct Transaction

Gestures

Basic Gestures

Status Name Notes
struct TapGesture
struct LongPressGesture
struct DragGesture
struct MagnificationGesture
struct RotationGesture

Combined Gestures

Status Name Notes
struct SequenceGesture
struct SimultaneousGesture
struct ExclusiveGesture

Custom Gesture

Status Name Notes
protocol Gesture
struct AnyGesture

Dynamic View Properties

Status Name Notes
struct GestureState
struct GestureStateGesture

Gesture Support

Status Name Notes
struct GestureMask
struct EventModifiers

Legend

Symbol Description
Done
Open
⚠️ Incomplete

Resources

SwiftUI Interface

Compared to what you can see in Xcode, this gist shows you more than just the public interfaces. It shows private properties, and the body of @inlinable marked properties, functions, and initializers.

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/SwiftUI.framework/Versions/A/Modules/SwiftUI.swiftmodule/x86_64.swiftinterface

SwiftWebUI

SwiftWebUI is an implementation of SwiftUI for the web by Helge Heß. This project's goal is focused exclusively on the web. It deviates a little bit from SwiftUI by taking some shortcuts here and there -- but looks quite complete in functionality and is great for inspiration.

SwiftUI symbols

This command prints the symbol table of SwiftUI via the llvm-mn utility.

nm -gUj /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/SwiftUI.framework/SwiftUI | swift-demangle | sed 's/SwiftUI.//g' | sed 's/Swift.//g'

You can also have a look at this gist instead.

Links

Special thanks

I want to give special thanks to Helge Heß. He created SwiftWebUI, contributed many suggestions to OpenSwiftUI, and helped with insights of his findings.


Contact

License

OpenSwiftUI is released under the MIT License.

More Repositories

1

TinyConsole

📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible.
Swift
1,955
star
2

Clippy

📎💬🎉 Clippy from Microsoft Office is back and runs on macOS! Written in Swift.
Swift
741
star
3

HackMan

🤖🔜🤯 Stop writing boilerplate code yourself. Let hackman do it for you via the command line.
Swift
292
star
4

SwiftUIEmbedded

WIP — SwiftUIEmbedded is an implementation of SwiftUI (based on OpenSwiftUI) for embedded and Linux devices.
Swift
111
star
5

BinaryKit

💾🔍🧮 BinaryKit helps you to break down binary data into bits and bytes, easily access specific parts and write data to binary.
Swift
110
star
6

awesome-embedded-swift

⚡️🛠🧰 A curated list for Embedded and Low-Level development in the Swift programming language.
Swift
69
star
7

GrammaticalNumber

1️⃣🔜🔢 Turns singular words to the plural and vice-versa in Swift.
Swift
35
star
8

SwiftUIEmbedded-Demo

WIP — SwiftUIEmbedded — Demo for Linux
Swift
31
star
9

ISO8859

🌍⏩📄 Convert ISO8859 1-16 Encoded Text to String in Swift. Supports iOS, tvOS, watchOS and macOS.
Swift
18
star
10

Nodes

🌲🌿🌳 Nodes is a class protocol for tree data structures with multiple children. Written in Swift.
Swift
17
star
11

StringCase

👇👆🐍 Converts String to lowerCamelCase, UpperCamelCase and snake_case. Tested and written in Swift.
Swift
16
star
12

ShotPlan

A command line tool that calls your Xcode Test Plan and creates screenshots of your app automatically.
Swift
11
star
13

TransportStream

🎬📺🎞 MPEG-TS (Transport Stream) Tools: Demultiplexer, CRC32, Program Specific Information (PMT PAT, NIT, CAT). Written in Swift.
Swift
10
star
14

bashtv

Hackathon Project — Watch public television in your terminal. No browser needed.
Swift
8
star
15

awesome-swift-platforms

A curated list of Swift on different platforms.
Swift
4
star
16

Pixels

WIP — Pixels is a low level graphics library written in Swift.
Swift
4
star
17

News-Sightseeing

Sophisticated-location-aware-news.
C#
3
star
18

bashtv-service

C#
2
star
19

PSVR_api

C#
2
star
20

ToThePoint

Hackathon Project — Jump right to the interesting parts of a video. Project at mediahackday.
JavaScript
2
star
21

JSKit

A quick and dirty attempt to recreate UIKit in JavaScript
JavaScript
2
star
22

Isometric

JavaScript
1
star
23

SpriteMap

SpriteMap helps you to extract sprites out of a sprite map. Written in Swift.
Swift
1
star
24

spotify-places

Spotify places enables social playlists for bars based on the users favorite songs.
C#
1
star
25

FeedCollectionViewLayout

[WIP] 📱📐 Customizable UICollectionLayout for single and multi-column feeds.
Swift
1
star
26

Note

This is for debugging and reference only. Document Based + ReferenceFileDocument + UndoManager + Commands Example
Swift
1
star