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 or Visual Studio, where the Swift library should show automatically.

The library is called Swift.dll on .NET, libSwift.fx on Cocoa and swift.jar on Java and Android. 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 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

Interfaces

Enums

Aliases

  • AnsiChar = Byte  .NET, Iodine
  • Any
    • dynamic  .NET, Iodine, Island
    • id  Toffee
  • AnyClass
    • Type  .NET
    • Class  Toffee
  • AnyClass<T> = Class<T>  Iodine
  • AnyObject
    • dynamic  .NET, Iodine, Island
    • id  Toffee
  • ArrayLiteralConvertible<Element> = IExpressibleByArrayLiteral<Element>
  • Bool
    • Boolean  .NET, Iodine, Toffee
    • Boolean  Island
  • BooleanLiteralConvertible<BooleanLiteralType> = IExpressibleByBooleanLiteral<BooleanLiteralType>
  • BooleanLiteralType
    • Boolean  .NET, Iodine, Toffee
    • Boolean  Island
  • CBool
    • Boolean  .NET, Iodine, Toffee
    • Boolean  Island
  • CChar
    • SByte  .NET, Iodine, Toffee
    • SByte  Island
  • CChar16
    • UInt16  .NET, Toffee
    • Word  Iodine
    • UInt16  Island
  • CChar32
    • UInt32  .NET, Toffee
    • Cardinal  Iodine
    • UInt32  Island
  • CDouble
    • Double  .NET, Iodine, Toffee
    • Double  Island
  • CFloat
    • Single  .NET, Iodine, Toffee
    • Single  Island
  • CInt
    • Int32  .NET, Toffee
    • Integer  Iodine
    • Int32  Island
  • CLong
    • Int64  .NET, Iodine, Toffee-iOS, Toffee-iOS Simulator, Toffee-macOS, Toffee-tvOS, Toffee-tvOS Simulator, Toffee-watchOS
    • Int64  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
    • 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
    • Int32  Toffee-watchOS Simulator
  • CLongLong
    • Int64  .NET, Iodine, Toffee
    • Int64  Island
  • CShort
    • Int16  .NET, Toffee
    • SmallInt  Iodine
    • Int16  Island
  • CSignedChar
    • SByte  .NET, Iodine, Toffee
    • SByte  Island
  • CUnsignedChar
    • Byte  .NET, Iodine, Toffee
    • Byte  Island
  • CUnsignedInt
    • UInt32  .NET, Toffee
    • Cardinal  Iodine
    • UInt32  Island
  • CUnsignedLong
    • UInt64  .NET, Iodine, Toffee-iOS, Toffee-iOS Simulator, Toffee-macOS, Toffee-tvOS, Toffee-tvOS Simulator, Toffee-watchOS
    • UInt64  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
    • 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
    • UInt32  Toffee-watchOS Simulator
  • CUnsignedLongLong
    • UInt64  .NET, Iodine, Toffee
    • UInt64  Island
  • CUnsignedShort
    • UInt16  .NET, Toffee
    • Word  Iodine
    • UInt16  Island
  • CustomDebugStringConvertible = ICustomDebugStringConvertible
  • CustomStringConvertible = ICustomStringConvertible
  • CWideChar
    • UInt32  .NET, Toffee
    • Cardinal  Iodine
    • UInt32  Island
  • DictionaryLiteralConvertible<Key,alue> = IExpressibleByDictionaryLiteral<Key,Value>  Iodine
  • DictionaryLiteralConvertible<Key,Value> = IExpressibleByDictionaryLiteral<Key,Value>  .NET, Island, Toffee
  • ErrorType = IErrorType
  • ExpressibleByArrayLiteral<Element> = IExpressibleByArrayLiteral<Element>
  • ExpressibleByBooleanLiteral<BooleanLiteralType> = IExpressibleByBooleanLiteral<BooleanLiteralType>
  • ExpressibleByDictionaryLiteral<Key,alue> = IExpressibleByDictionaryLiteral<Key,Value>  Iodine
  • 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, Iodine
    • String  Island
    • NSString  Toffee
  • Float
    • Single  .NET, Iodine, Toffee
    • Single  Island
  • Float32
    • Single  .NET, Iodine, Toffee
    • Single  Island
  • Float64
    • Double  .NET, Iodine, Toffee
    • Double  Island
  • FloatLiteralConvertible<FloatLiteralType> = IExpressibleByFloatLiteral<FloatLiteralType>
  • FloatLiteralType
    • Double  .NET, Iodine, Toffee
    • Double  Island
  • 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>
  • ILazySequenceType<T>
    • not nullable not nullable IEnumerable<T>  .NET
    • not nullable not nullable Iterable<T>  Iodine
    • not nullable not nullable IEnumerable<T>  Island
    • not nullable not nullable INSFastEnumeration<T>  Toffee
  • Int
    • Int64  .NET, Iodine, Toffee-iOS, Toffee-iOS Simulator, Toffee-macOS, Toffee-tvOS, Toffee-tvOS Simulator, Toffee-watchOS
    • Int64  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
    • 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
    • Int32  Toffee-watchOS Simulator
  • Int8
    • SByte  .NET, Iodine, Toffee
    • SByte  Island
  • IntegerLiteralConvertible<IntegerLiteralType> = IExpressibleByIntegerLiteral<IntegerLiteralType>
  • IntegerLiteralType
    • Int64  .NET, Iodine, Toffee-iOS, Toffee-iOS Simulator, Toffee-macOS, Toffee-tvOS, Toffee-tvOS Simulator, Toffee-watchOS
    • Int64  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
    • 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
    • Int32  Toffee-watchOS Simulator
  • IntMax
    • Int64  .NET, Iodine, Toffee
    • Int64  Island
  • ISequenceType<T>
    • IEnumerable<T>  .NET
    • Iterable<T>  Iodine
    • IEnumerable<T>  Island
    • INSFastEnumeration  Toffee
  • LazySequenceType<T>
    • not nullable not nullable IEnumerable<T>  .NET
    • not nullable not nullable Iterable<T>  Iodine
    • not nullable not nullable IEnumerable<T>  Island
    • not nullable not nullable INSFastEnumeration<T>  Toffee
  • NativeString
    • String  .NET, Iodine
    • String  Island
    • NSString  Toffee
  • NativeStringBuilder
  • NilLiteralConvertible = IExpressibleByNilLiteral
  • NSObject
    • Object  .NET, Iodine
    • Object  Island
    • Foundation.NSObject  Toffee
  • OpaquePointer = ^void  Toffee
  • OutputStreamType = IOutputStreamType
  • PlatformDictionary<T,U>
    • not nullable Dictionary<T, U>  .NET
    • not nullable HashMap<T, U>  Iodine
    • 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>  Iodine
    • 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>  Iodine
    • not nullable not nullable List<T>  Island
    • not nullable NSArray<T>  Toffee
  • PlatformList<T>
    • not nullable List<T>  .NET
    • not nullable ArrayList<T>  Iodine
    • not nullable List<T>  Island
    • not nullable NSMutableArray<T>  Toffee
  • PlatformSequence<T> = not nullable IEnumerable<T>  Island
  • PlatformSet<T> = not nullable List<T>  Island
  • RawRepresentable<RawValue> = IRawRepresentable<RawValue>
  • Selector = SEL  Toffee
  • SequenceType<T>
  • 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, Iodine
    • String  Island
    • NSString  Toffee
  • Streamable = IStreamable
  • StringInterpolationConvertible<StringInterpolationType> = IExpressibleByStringInterpolation<StringInterpolationType>
  • StringLiteralConvertible<StringLiteralType> = IExpressibleByStringLiteral<StringLiteralType>
  • StringLiteralType
    • String  .NET, Iodine
    • String  Island
    • NSString  Toffee
  • StringProtocol = IStringProtocol
  • SwiftString.UnicodeScalarView
  • TextOutputStream = ITextOutputStream
  • TextOutputStreamable = ITextOutputStreamable
  • UInt
    • UInt64  .NET, Iodine, Toffee-iOS, Toffee-iOS Simulator, Toffee-macOS, Toffee-tvOS, Toffee-tvOS Simulator, Toffee-watchOS
    • UInt64  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
    • 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
    • UInt32  Toffee-watchOS Simulator
  • UInt8
    • Byte  .NET, Iodine, Toffee
    • Byte  Island
  • UIntMax
    • UInt64  .NET, Iodine, Toffee
    • UInt64  Island
  • UnicodeScalar
    • UInt32  .NET, Toffee
    • Cardinal  Iodine
    • UInt32  Island
  • UnicodeScalarLiteralConvertible<UnicodeScalarLiteralType> = IExpressibleByUnicodeScalarLiteral<UnicodeScalarLiteralType>
  • UnicodeScalarType
    • String  .NET, Iodine
    • String  Island
    • NSString  Toffee
  • UnsignedIntegerType = IUnsignedIntegerType
  • UTF16Char
    • Char  .NET, Iodine, Toffee
    • Char  Island
  • UTF32Char
    • UInt32  .NET, Toffee
    • Cardinal  Iodine
    • UInt32  Island
  • UTF8Char
    • Byte  .NET, Iodine
    • AnsiChar  Island
    • AnsiChar  Toffee
  • UWord
    • UInt16  .NET, Toffee
    • Word  Iodine
    • UInt16  Island
  • Word
    • Int64  .NET, Iodine, Toffee-iOS, Toffee-iOS Simulator, Toffee-macOS, Toffee-tvOS, Toffee-tvOS Simulator, Toffee-watchOS
    • Int64  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
    • 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
    • Int32  Toffee-watchOS Simulator

See Also