- Support for multiple platforms in the same framework.
- Support for Swift, Objective-C and C.
- Support for dynamic frameworks and static libraries.
- Support for Swift Package Manager.
- End of fat binaries.
- Open Current framework project
import SwiftUI | |
import UIKit | |
class MyViewController: UIViewController { | |
// this is how you embed a SwiftUI View | |
lazy var host: UIViewController = { | |
return UIHostingController(rootView: MySwiftUIView()) | |
}() | |
struct AutoHeightLabelView: View { | |
var attributedString: NSAttributedString | |
var body: some View { | |
HorizontalGeometryReader { width in | |
UILabelView( | |
attributedString: attributedString, | |
preferredMaxLayoutWidth: width | |
) | |
} |
/// An iOS style TabView that doesn't reset it's childrens navigation stacks when tabs are switched. | |
public struct UIKitTabView: View { | |
private var viewControllers: [UIHostingController<AnyView>] | |
private var selectedIndex: Binding<Int>? | |
@State private var fallbackSelectedIndex: Int = 0 | |
public init(selectedIndex: Binding<Int>? = nil, @TabBuilder _ views: () -> [Tab]) { | |
self.viewControllers = views().map { | |
let host = UIHostingController(rootView: $0.view) | |
host.tabBarItem = $0.barItem |
import Foundation | |
var json = """ | |
{ | |
"lastSyncDate": "2018-10-28T09:03:59+0000", | |
"posts": [ | |
{ | |
"id": 0, | |
"title": "Swift 4 Codable: tips and tricks", | |
"link": "https://medium.com/@MarioIannotta/swift-4-codable-tips-and-tricks-7ab4674736d2", |
import Foundation | |
public struct Log | |
{ | |
public static var isEnabled = true | |
public static func debug(_ m: @autoclosure ()->String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) { | |
print(m(), file ?? "", f, line) | |
} |
/// A type that has an "empty" representation. | |
public protocol EmptyRepresentable { | |
static func empty() -> Self | |
} | |
extension Array: EmptyRepresentable { | |
public static func empty() -> Array<Element> { | |
return Array() | |
} | |
} |
import Foundation | |
protocol Completable { | |
func addCompletionOperation(on queue: OperationQueue, complete: @escaping (Self) -> Void) -> Operation | |
} | |
extension Completable where Self: Operation { | |
func addCompletionOperation(on queue: OperationQueue, complete: @escaping (Self) -> Void) -> Operation { | |
let completionOperation = BlockOperation { |
// Basic.swift | |
extension Notification.Name { | |
func post(object:Any? = nil, userInfo:[AnyHashable: Any]? = nil) { | |
NotificationCenter.default.post(self, object: object, userInfo: userInfo) | |
} | |
} | |
// DataModel.swift | |
extension Notification.Name { | |
static let AccountBalanceUpdated = Notification.Name("accountBalanceUpdated") |
/* | |
*** Academy Engraved LET *** | |
AcademyEngravedLetPlain | |
--------------------- | |
*** Al Nile *** | |
AlNile | |
AlNile-Bold | |
--------------------- | |
*** American Typewriter *** | |
AmericanTypewriter |