Swift Base Library

The Swift Base Library is a small library that can be optionally used in Swift projects compiled with the Elements compiler. It provides some of the core types, classes and functions that, while not part of the Swift language spec per se, are commonly used in Swift apps (and provided in a similar Swift Base Library in Apple's implementation).

This includes types like the Swift-native array and dictionary types, and base functions like print().

The Swift Base Library ships precompiled with the Elements compiler, and new projects created with one of the RemObjects Silver project templates will automatically have a reference to it. If you are adding Swift files to a project that started out with a different language, you can add a reference to your projects via the Add References dialog in Fire, Water or Visual Studio, where the Swift library should show automatically.

The library is called Swift.dll on .NET, libSwift.fx on Cocoa, swift.jar on Java and Android and swift.fx on Island. All its content is contained in the Swift namespace, which is automatically in scope in .swift source files, but may also be specified explicitly (for example to resolve ambiguity).

While it is not their intended use, most of the types and functions exposed in the library are perfectly valid to be used from Oxygene, C# and Java, as well. In these languages, the Swift namespace will need to be explicitly specified or added to the uses/using/import section.

Source Code

The Swift Base Library is open source and implemented fully in Silver. You can find the source code on GitHub, and contributions and pull requests are more than welcome.

Note that you will need the very latest compiler to rebuild the SBL, and in some cases, the git repository might even contain code that requires a later compiler than is available. Refer to the commit messages for details on this, and check out an older revision, if necessary.

Classes and Types

This library is a work in progress; all functionality presented is useable now, and it will be expanded and grown over time. Contributions on GitHub are more than welcome.

Currently, the following major types are supported/implemented. Unless otherwise noted, all parts of Elements RTL are available across all platforms, including Island.

Classes

Structs

Interfaces

Enums

Aliases

  • AnsiChar = Byte  .NET, Cooper
  • Any
    • dynamic  .NET, Cooper, Island
    • id  Toffee
  • AnyClass
    • Type  .NET
    • Class  Toffee
  • AnyClass<T> = Class<T>  Cooper
  • AnyObject
    • dynamic  .NET, Cooper, Island
    • id  Toffee
  • ArrayLiteralConvertible<Element> = IExpressibleByArrayLiteral<Element>
  • Bool = Boolean
  • BooleanLiteralConvertible<BooleanLiteralType> = IExpressibleByBooleanLiteral<BooleanLiteralType>
  • BooleanLiteralType = Boolean
  • CBool = Boolean
  • CChar = SByte
  • CChar16
  • CChar32
  • CDouble = Double
  • CFloat = Single
  • CInt
  • CLong
    • Int64  .NET, Cooper, Island-Android-arm64-v8a, Island-Android-x86_64, Island-iOS, Island-iOS Simulator-x86_64, Island-macOS-x86_64, Island-tvOS, Island-tvOS Simulator-x86_64, Island-Ubuntu-x86_64, Island-watchOS Simulator-x86_64, Island-watchOS-arm64, Island-Windows-x86_64, Toffee-iOS, Toffee-iOS Simulator, Toffee-macOS, Toffee-tvOS, Toffee-tvOS Simulator, Toffee-watchOS
    • Int32  Island-Android-armeabi, Island-Android-armeabi-v7a, Island-Android-x86, Island-Ubuntu-armv6, Island-watchOS Simulator-i386, Island-watchOS-armv7k, Island-WebAssembly-wasm32, Island-Windows-i386, Toffee-watchOS Simulator
  • CLongLong = Int64
  • CShort
  • CSignedChar = SByte
  • CUnsignedChar = Byte
  • CUnsignedInt
  • CUnsignedLong
    • UInt64  .NET, Cooper, Island-Android-arm64-v8a, Island-Android-x86_64, Island-iOS, Island-iOS Simulator-x86_64, Island-macOS-x86_64, Island-tvOS, Island-tvOS Simulator-x86_64, Island-Ubuntu-x86_64, Island-watchOS Simulator-x86_64, Island-watchOS-arm64, Island-Windows-x86_64, Toffee-iOS, Toffee-iOS Simulator, Toffee-macOS, Toffee-tvOS, Toffee-tvOS Simulator, Toffee-watchOS
    • UInt32  Island-Android-armeabi, Island-Android-armeabi-v7a, Island-Android-x86, Island-Ubuntu-armv6, Island-watchOS Simulator-i386, Island-watchOS-armv7k, Island-WebAssembly-wasm32, Island-Windows-i386, Toffee-watchOS Simulator
  • CUnsignedLongLong = UInt64
  • CUnsignedShort
  • CustomDebugStringConvertible = ICustomDebugStringConvertible
  • CustomStringConvertible = ICustomStringConvertible
  • CWideChar
  • DictionaryLiteralConvertible<Key,alue> = IExpressibleByDictionaryLiteral<Key,Value>  Cooper
  • DictionaryLiteralConvertible<Key,Value> = IExpressibleByDictionaryLiteral<Key,Value>  .NET, Island, Toffee
  • Error
    • Exception  .NET, Cooper
    • Exception  Island
    • NSException  Toffee
  • ErrorType = IErrorType
  • ExpressibleByArrayLiteral<Element> = IExpressibleByArrayLiteral<Element>
  • ExpressibleByBooleanLiteral<BooleanLiteralType> = IExpressibleByBooleanLiteral<BooleanLiteralType>
  • ExpressibleByDictionaryLiteral<Key,alue> = IExpressibleByDictionaryLiteral<Key,Value>  Cooper
  • ExpressibleByDictionaryLiteral<Key,Value> = IExpressibleByDictionaryLiteral<Key,Value>  .NET, Island, Toffee
  • ExpressibleByFloatLiteral<FloatLiteralType> = IExpressibleByFloatLiteral<FloatLiteralType>
  • ExpressibleByIntegerLiteral<IntegerLiteralType> = IExpressibleByIntegerLiteral<IntegerLiteralType>
  • ExpressibleByNilLiteral = IExpressibleByNilLiteral
  • ExpressibleByStringInterpolation<StringInterpolationType> = IExpressibleByStringInterpolation<StringInterpolationType>
  • ExpressibleByStringLiteral<StringLiteralType> = IExpressibleByStringLiteral<StringLiteralType>
  • ExpressibleByUnicodeScalarLiteral<UnicodeScalarLiteralType> = IExpressibleByUnicodeScalarLiteral<UnicodeScalarLiteralType>
  • ExtendedGraphemeClusterType
    • String  .NET, Cooper, Island
    • NSString  Toffee
  • Float = Single
  • Float32 = Single
  • Float64 = Double
  • FloatLiteralConvertible<FloatLiteralType> = IExpressibleByFloatLiteral<FloatLiteralType>
  • FloatLiteralType = Double
  • Hashable = IHashable
  • IBooleanType = BooleanType
  • ICollectionType<SubSequence,Index,Distance,Element> = CollectionType<SubSequence,Index,Distance,Element>
  • IIncrementable = Incrementable
  • IIndexable<Index,Distance,Element> = Indexable<Index,Distance,Element>
  • ILazySequence<T>
    • not nullable System.Collections.Generic.IEnumerable<T>  .NET
    • not nullable java.lang.Iterable<T>  Cooper
    • not nullable RemObjects.Elements.System.IEnumerable<T>  Island
    • not nullable RemObjects.Elements.System.INSFastEnumeration<T>  Toffee
  • ILazySequenceType<T>
    • not nullable not nullable System.Collections.Generic.IEnumerable<T>  .NET
    • not nullable not nullable java.lang.Iterable<T>  Cooper
    • not nullable not nullable RemObjects.Elements.System.IEnumerable<T>  Island
    • not nullable not nullable RemObjects.Elements.System.INSFastEnumeration<T>  Toffee
  • Int
    • Int64  .NET, Cooper, Island-Android-arm64-v8a, Island-Android-x86_64, Island-iOS, Island-iOS Simulator-x86_64, Island-macOS-x86_64, Island-tvOS, Island-tvOS Simulator-x86_64, Island-Ubuntu-x86_64, Island-watchOS Simulator-x86_64, Island-watchOS-arm64, Island-Windows-x86_64, Toffee-iOS, Toffee-iOS Simulator, Toffee-macOS, Toffee-tvOS, Toffee-tvOS Simulator, Toffee-watchOS
    • Int32  Island-Android-armeabi, Island-Android-armeabi-v7a, Island-Android-x86, Island-Ubuntu-armv6, Island-watchOS Simulator-i386, Island-watchOS-armv7k, Island-WebAssembly-wasm32, Island-Windows-i386, Toffee-watchOS Simulator
  • Int8 = SByte
  • IntegerLiteralConvertible<IntegerLiteralType> = IExpressibleByIntegerLiteral<IntegerLiteralType>
  • IntegerLiteralType
    • Int64  .NET, Cooper, Island-Android-arm64-v8a, Island-Android-x86_64, Island-iOS, Island-iOS Simulator-x86_64, Island-macOS-x86_64, Island-tvOS, Island-tvOS Simulator-x86_64, Island-Ubuntu-x86_64, Island-watchOS Simulator-x86_64, Island-watchOS-arm64, Island-Windows-x86_64, Toffee-iOS, Toffee-iOS Simulator, Toffee-macOS, Toffee-tvOS, Toffee-tvOS Simulator, Toffee-watchOS
    • Int32  Island-Android-armeabi, Island-Android-armeabi-v7a, Island-Android-x86, Island-Ubuntu-armv6, Island-watchOS Simulator-i386, Island-watchOS-armv7k, Island-WebAssembly-wasm32, Island-Windows-i386, Toffee-watchOS Simulator
  • IntMax = Int64
  • ISequenceType<T>
    • System.Collections.Generic.IEnumerable<T>  .NET
    • java.lang.Iterable<T>  Cooper
    • RemObjects.Elements.System.IEnumerable<T>  Island
    • INSFastEnumeration  Toffee
  • LazySequenceType<T>
    • not nullable not nullable System.Collections.Generic.IEnumerable<T>  .NET
    • not nullable not nullable java.lang.Iterable<T>  Cooper
    • not nullable not nullable RemObjects.Elements.System.IEnumerable<T>  Island
    • not nullable not nullable RemObjects.Elements.System.INSFastEnumeration<T>  Toffee
  • NativeString
    • String  .NET, Cooper, Island
    • NSString  Toffee
  • NativeStringBuilder
  • NilLiteralConvertible = IExpressibleByNilLiteral
  • NSObject
  • OpaquePointer = ^Void  Toffee
  • OutputStreamType = IOutputStreamType
  • PlatformDictionary<T,U>
    • not nullable Dictionary<T, U>  .NET
    • not nullable HashMap<T, U>  Cooper
    • not nullable Dictionary<T,U>  Island
    • not nullable NSMutableDictionary<T, U>  Toffee
  • PlatformImmutableDictionary<T,U>
    • not nullable not nullable Dictionary<T, U>  .NET
    • not nullable not nullable HashMap<T, U>  Cooper
    • not nullable not nullable Dictionary<T,U>  Island
    • not nullable Foundation.NSDictionary<T, U>  Toffee
  • PlatformImmutableList<T>
    • not nullable not nullable List<T>  .NET
    • not nullable not nullable ArrayList<T>  Cooper
    • not nullable not nullable List<T>  Island
    • not nullable NSArray<T>  Toffee
  • PlatformList<T>
    • not nullable List<T>  .NET
    • not nullable ArrayList<T>  Cooper
    • not nullable List<T>  Island
    • not nullable NSMutableArray<T>  Toffee
  • PlatformSequence<T> = not nullable RemObjects.Elements.System.IEnumerable<T>  Island
  • PlatformSet<T> = not nullable List<T>  Island
  • RawRepresentable<RawValue> = IRawRepresentable<RawValue>
  • Selector = SEL  Toffee
  • SequenceType<T>
    • not nullable System.Collections.Generic.IEnumerable<T>  .NET
    • not nullable java.lang.Iterable<T>  Cooper
    • not nullable RemObjects.Elements.System.IEnumerable<T>  Island
    • not nullable RemObjects.Elements.System.INSFastEnumeration<T>  Toffee
  • Set<T>.Element<T> = T  Island
  • SignedIntegerType = ISignedIntegerType
  • SignedNumberType<IntegerLiteralType> = ISignedNumberType<IntegerLiteralType>
  • Sliceable<SubSlice,SubSequence,Index,Distance,Element> = ISliceable<SubSlice,SubSequence,Index,Distance,Element>
  • StaticString
    • String  .NET, Cooper, Island
    • NSString  Toffee
  • Streamable = IStreamable
  • StringInterpolationConvertible<StringInterpolationType> = IExpressibleByStringInterpolation<StringInterpolationType>
  • StringLiteralConvertible<StringLiteralType> = IExpressibleByStringLiteral<StringLiteralType>
  • StringLiteralType
    • String  .NET, Cooper, Island
    • NSString  Toffee
  • StringProtocol = IStringProtocol
  • SwiftString.UnicodeScalarView
  • TextOutputStream = ITextOutputStream
  • TextOutputStreamable = ITextOutputStreamable
  • UInt
    • UInt64  .NET, Cooper, Island-Android-arm64-v8a, Island-Android-x86_64, Island-iOS, Island-iOS Simulator-x86_64, Island-macOS-x86_64, Island-tvOS, Island-tvOS Simulator-x86_64, Island-Ubuntu-x86_64, Island-watchOS Simulator-x86_64, Island-watchOS-arm64, Island-Windows-x86_64, Toffee-iOS, Toffee-iOS Simulator, Toffee-macOS, Toffee-tvOS, Toffee-tvOS Simulator, Toffee-watchOS
    • UInt32  Island-Android-armeabi, Island-Android-armeabi-v7a, Island-Android-x86, Island-Ubuntu-armv6, Island-watchOS Simulator-i386, Island-watchOS-armv7k, Island-WebAssembly-wasm32, Island-Windows-i386, Toffee-watchOS Simulator
  • UInt8 = Byte
  • UIntMax = UInt64
  • UnicodeScalar
  • UnicodeScalarLiteralConvertible<UnicodeScalarLiteralType> = IExpressibleByUnicodeScalarLiteral<UnicodeScalarLiteralType>
  • UnicodeScalarType
    • String  .NET, Cooper, Island
    • NSString  Toffee
  • UnsignedIntegerType = IUnsignedIntegerType
  • UTF16Char = Char
  • UTF32Char
  • UTF8Char
  • UWord
  • Word
    • Int64  .NET, Cooper, Island-Android-arm64-v8a, Island-Android-x86_64, Island-iOS, Island-iOS Simulator-x86_64, Island-macOS-x86_64, Island-tvOS, Island-tvOS Simulator-x86_64, Island-Ubuntu-x86_64, Island-watchOS Simulator-x86_64, Island-watchOS-arm64, Island-Windows-x86_64, Toffee-iOS, Toffee-iOS Simulator, Toffee-macOS, Toffee-tvOS, Toffee-tvOS Simulator, Toffee-watchOS
    • Int32  Island-Android-armeabi, Island-Android-armeabi-v7a, Island-Android-x86, Island-Ubuntu-armv6, Island-watchOS Simulator-i386, Island-watchOS-armv7k, Island-WebAssembly-wasm32, Island-Windows-i386, Toffee-watchOS Simulator

See Also