• Stars
    star
    626
  • Rank 71,755 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 4 years ago

Reviews

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

Repository Details

Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. (Pure Swift, Supports Linux)

SwiftFoundation

Swift Platforms Release License Build Status

Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library.

Goals

  • Provide a cross-platform interface that mimics Apple's Foundation framework.
  • Provide a POSIX-based implementation for maximum portability.
  • Rewrite Foundation with Protocol-Oriented Programming principals.
  • Long-term Pure Swift replacement for the Cocoa frameworks.

Problems with Apple's Foundation

  • Objective-C - Apple's Foundation is an old API designed for Objective-C. While it works great (on Apple's platforms) and has a nice API for Objective-C programming, when imported into Swift, you can see the shortcomings of its 20+ year old API.
  • Unimplemented - The open source version of Apple's Foundation is severly lacking implementation. Most methods are marked with NSUnimplemented(). Only a small subset of Foundation based on CoreFoundation is implemented (e.g. NSArray, NSString, NSDictionary). Basic Functionality like JSON, Base64, and even HTTP requests are not implemented.
  • Portability - Since Apple's Foundation is backed by CoreFoundation, the only supported platforms are currently Linux, Darwin, and (potentially) Windows. Supporting other platforms (e.g. ARM Linux, BSD, SunOS) would require changes to the CoreFoundation codebase, written in C, which is not good for a long term Swift base library. We want all of our code to be understood by any Swift programmer.
  • Protocol Oriented Programming - Perhaps the biggest reason to use this library, is to break free from the old Object-Oriented Programming paradigms. Swift structures and protocols free you from pointers and memory management, along with bugs related to multithreaded environments. Creating structs for basic types like Date and UUID allows you to use let and var correctly. Structs also bring huge performance improvements since the compiler can perform more optimizations and doesn't have to create all the metadata needed for the Swift class runtime.

Targeted Platforms

Implemented

To see what parts of Foundation are implemented, just look at the unit tests. Completed functionality will be fully unit tested. Note that there is some functionality that is written as a protocol only, that will not be included on this list.

  • Base64
  • Data
  • Date
  • FileManager
  • JSON
  • RegularExpression (POSIX, not ICU)
  • Thread
  • URL
  • UUID

License

This program is free software; you can redistribute it and/or modify it under the terms of the MIT License.

More Repositories

1

Cacao

Pure Swift Cross-platform UIKit (Cocoa Touch) implementation (Supports Linux)
Swift
1,078
star
2

BluetoothLinux

Pure Swift Linux Bluetooth Stack
Swift
178
star
3

Bluetooth

Pure Swift Bluetooth library
Swift
174
star
4

Socket

Swift async/await based socket
Swift
114
star
5

Silica

Pure Swift CoreGraphics (Quartz2D) implementation (Supports Linux)
Swift
107
star
6

GATT

Bluetooth Generic Attribute Profile (GATT) for Swift (Supports Linux)
Swift
62
star
7

SeeURL

Swift wrapper for cURL (Supports Linux)
Swift
53
star
8

AndroidUIKit

UIKit for Android
Swift
51
star
9

Android

Swift library for Android
Swift
50
star
10

Cairo

Swift library for Cairo
Swift
40
star
11

CoreModel

Pure Swift ORM (Supports Linux)
Swift
33
star
12

SDL

Swift library for SDL2
Swift
32
star
13

Predicate

Pure Swift Predicate implementation
Swift
32
star
14

SwiftUI

SwiftUI renderer for Linux
Swift
31
star
15

MySQL

Swift library for MySQL
Swift
28
star
16

WLAN

Wireless LAN (WiFi) API for Swift (Supports Linux)
Swift
27
star
17

TLVCoding

TLV8 (Type-Length-Value) Coder library
Swift
27
star
18

Bonjour

Pure Swift NetService (Bonjour / Zeroconf / mDNS) library with async/await support
Swift
24
star
19

BluetoothWeb

Swift library for Bluetooth Web API (WebAssembly)
Swift
15
star
20

SwiftStyleGuide

PureSwift Official Swift Style Guide
12
star
21

MongoDB

Pure Swift library for MongoDB
Swift
12
star
22

Kronos

Pure Swift implementation of GLKit for OpenGL ES (Supports Linux)
Swift
11
star
23

DBus

Swift library for D-Bus
Swift
11
star
24

BluetoothDarwin

Low Level Swift Bluetooth library for the Darwin kernel
Objective-C
10
star
25

Netlink

Swift library for communicating with Linux Kernel Netlink subsystem (Linux Only)
Swift
10
star
26

BinaryJSON

Pure Swift library for BSON
Swift
8
star
27

CFreeType

Swift C module for FreeType 2
Swift
8
star
28

SwiftAndroidSupport

Kotlin Support library for SwiftAndroid
Kotlin
6
star
29

CSDL2

Swift C module for SDL2
Swift
6
star
30

CDBus

Swift C Module for DBus
C
6
star
31

Codable

Codable for Swift 3
Swift
4
star
32

AndroidSwiftUI

SwiftUI for Android
4
star
33

CBlueZ

Linux Bluetooth C API for Swift
Swift
4
star
34

LittleCMS

Swift library for LittleCMS 2
Swift
4
star
35

AndroidBluetooth

Swift Bluetooth stack for Android
Swift
4
star
36

CcURL

Swift C module for cURL (Linux)
Swift
3
star
37

HTTP

Pure Swift HTTP library
Swift
3
star
38

JSON

JSON Value types for Swift
Swift
3
star
39

CSwiftBluetoothLinux

Swift C Module for Swift BluetoothLinux C helper headers
C
3
star
40

AppRuntime

Portable Cross-Platform Swift App Runtime
Swift
2
star
41

Cb64

Swift Module for b64 on Linux
Swift
2
star
42

CryptoLinux

Swift library for Linux Kernel Crypto API
Swift
2
star
43

CCairo

Swift C Module Cairo
Swift
2
star
44

CLinuxWLAN

Swift Module for Linux WiFi headers
C
1
star
45

CMySQL

Swift C Module for MySQL
Swift
1
star
46

NFC

Pure Swift NFC library
1
star
47

CMinizip

Swift Module for MiniZip C library
1
star
48

CoreData

Compatibility library for interacting with CoreData files
Swift
1
star
49

CPNG

Swift C module for PNG
Swift
1
star
50

JNI

Swift JNI helpers
Swift
1
star
51

JSONC

Swift wrapper for JSON-C
Swift
1
star
52

CJSONC

Swift C module for JSON-C
Swift
1
star
53

SwiftAndroidExample

Swift on Android Example Project
1
star
54

CUUID

UUID support missing from Swift's Glibc in Linux
Swift
1
star
55

CFontConfig

Swift C module for FontConfig
Swift
1
star