jeryycnlong
jeryycnlong

Reputation: 161

Where can I see the source code of swiftUI?

Can you see more detailed code?

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
@frozen public struct HStack<Content> : View where Content : View {

    /// Creates a horizontal stack with the given spacing and vertical alignment.
    ///
    /// - Parameters:
    ///   - alignment: The guide for aligning the subviews in this stack. This
    ///     guide has the same vertical screen coordinate for every child view.
    ///   - spacing: The distance between adjacent subviews, or `nil` if you
    ///     want the stack to choose a default distance for each pair of
    ///     subviews.
    ///   - content: A view builder that creates the content of this stack.
    @inlinable public init(alignment: VerticalAlignment = .center, spacing: CGFloat? = nil, @ViewBuilder content: () -> Content)

    /// The type of view representing the body of this view.
    ///
    /// When you create a custom view, Swift infers this type from your
    /// implementation of the required `body` property.
    public typealias Body = Never
}

Upvotes: 15

Views: 9288

Answers (3)

AtomSys
AtomSys

Reputation: 1

SwiftUI is very similar to AppKit,so you an get code from there by searching "AppKit" in the open quickly menu on Xcode.

Upvotes: -2

Ayman Ferki
Ayman Ferki

Reputation: 313

SwiftUI isn't included in the Open Source Swift Project, but There Is an undergoing project to build an Open Source implementation of Apple's SwiftUI DSL. https://github.com/Cosmo/OpenSwiftUI

Upvotes: 13

jnpdx
jnpdx

Reputation: 52555

Most of Apple's frameworks are closed source and you cannot see more than these public headers.

There are exceptions (like the Darwin kernel is open source), and the Swift language itself is open source, but the frameworks themselves (like SwiftUI) are closed.

Many of Apple's open source initiatives (like the Swift language) can be found at their GitHub page: https://github.com/apple/

It's also probably worth mentioning that there are some projects underway to reverse-engineer/recreate open source versions of some of Apple's frameworks, which can give you some idea about how they might be built. Case in point: OpenCombine https://github.com/OpenCombine/OpenCombine

Upvotes: 2

Related Questions