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, .NET Standard 1.3, Cooper
  • Any
    • dynamic  .NET, .NET Standard 1.3, Cooper, Island
    • id  Toffee
  • AnyClass
    • Type  .NET, .NET Standard 1.3
    • Class  Toffee
  • AnyClass<T> = Class<T>  Cooper
  • AnyObject
    • dynamic  .NET, .NET Standard 1.3, Cooper, Island
    • id  Toffee
  • ArrayLiteralConvertible<Element> = IExpressibleByArrayLiteral<Element>
  • Bool = Boolean
  • BooleanLiteralConvertible<BooleanLiteralType> = IExpressibleByBooleanLiteral<BooleanLiteralType>
  • BooleanLiteralType = Boolean
  • CBool = Boolean
  • CChar = SByte
  • CChar16
    • UInt16  .NET, .NET Standard 1.3, Island, Toffee
    • Word  Cooper
  • CChar32
    • UInt32  .NET, .NET Standard 1.3, Island, Toffee
    • Cardinal  Cooper
  • CDouble = Double
  • CFloat = Single
  • CInt
    • Int32  .NET, .NET Standard 1.3, Island, Toffee
    • Integer  Cooper
  • CLong
    • Int64  .NET, .NET Standard 1.3, 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
  • CollectionOfOne.Distance<Element> = Int64  Cooper
  • CollectionOfOne.Index<Element> = Bit  Cooper
  • CollectionOfOne<Element>.Distance<Element>
    • Int64  .NET, .NET Standard 1.3, 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
    • NSObject  Toffee
  • CollectionOfOne<Element>.Index<Element>
    • Bit  .NET, .NET Standard 1.3, Island
    • NSObject  Toffee
  • CShort
    • Int16  .NET, .NET Standard 1.3, Island, Toffee
    • SmallInt  Cooper
  • CSignedChar = SByte
  • CUnsignedChar = Byte
  • CUnsignedInt
    • UInt32  .NET, .NET Standard 1.3, Island, Toffee
    • Cardinal  Cooper
  • CUnsignedLong
    • UInt64  .NET, .NET Standard 1.3, 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
    • UInt16  .NET, .NET Standard 1.3, Island, Toffee
    • Word  Cooper
  • CustomDebugStringConvertible = ICustomDebugStringConvertible
  • CustomStringConvertible = ICustomStringConvertible
  • CWideChar
    • UInt32  .NET, .NET Standard 1.3, Island, Toffee
    • Cardinal  Cooper
  • DictionaryLiteralConvertible<Key,alue> = IExpressibleByDictionaryLiteral<Key,Value>  Cooper
  • DictionaryLiteralConvertible<Key,Value> = IExpressibleByDictionaryLiteral<Key,Value>  .NET, .NET Standard 1.3, Island, Toffee
  • Error
  • ErrorType = IErrorType
  • ExpressibleByArrayLiteral<Element> = IExpressibleByArrayLiteral<Element>
  • ExpressibleByBooleanLiteral<BooleanLiteralType> = IExpressibleByBooleanLiteral<BooleanLiteralType>
  • ExpressibleByDictionaryLiteral<Key,alue> = IExpressibleByDictionaryLiteral<Key,Value>  Cooper
  • ExpressibleByDictionaryLiteral<Key,Value> = IExpressibleByDictionaryLiteral<Key,Value>  .NET, .NET Standard 1.3, 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, .NET Standard 1.3, 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>
  • ILazySequenceType<T>
  • Int
    • Int64  .NET, .NET Standard 1.3, 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, .NET Standard 1.3, 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>
    • IEnumerable<T>  .NET, .NET Standard 1.3, Island
    • Iterable<T>  Cooper
    • INSFastEnumeration  Toffee
  • LazySequenceType<T>
  • NativeString
    • String  .NET, .NET Standard 1.3, Cooper, Island
    • NSString  Toffee
  • NativeStringBuilder
    • StringBuilder  .NET, .NET Standard 1.3, Cooper
    • StringBuilder  Island
  • NilLiteralConvertible = IExpressibleByNilLiteral
  • NSObject
    • Object  .NET, .NET Standard 1.3, Cooper, Island
    • NSObject  Toffee
  • OpaquePointer
    • ^void  Island
    • ^Void  Toffee
  • OutputStreamType = IOutputStreamType
  • PlatformDictionary<T,U>
    • not nullable Dictionary<T, U>  .NET, .NET Standard 1.3
    • 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, .NET Standard 1.3
    • 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, .NET Standard 1.3
    • 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, .NET Standard 1.3
    • not nullable ArrayList<T>  Cooper
    • 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, .NET Standard 1.3, Cooper, Island
    • NSString  Toffee
  • Streamable = IStreamable
  • StringInterpolationConvertible<StringInterpolationType> = IExpressibleByStringInterpolation<StringInterpolationType>
  • StringLiteralConvertible<StringLiteralType> = IExpressibleByStringLiteral<StringLiteralType>
  • StringLiteralType
    • String  .NET, .NET Standard 1.3, Cooper, Island
    • NSString  Toffee
  • StringProtocol = IStringProtocol
  • SwiftString.UnicodeScalarView
  • TextOutputStream = ITextOutputStream
  • TextOutputStreamable = ITextOutputStreamable
  • UInt
    • UInt64  .NET, .NET Standard 1.3, 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
    • UInt32  .NET, .NET Standard 1.3, Island, Toffee
    • Cardinal  Cooper
  • UnicodeScalarLiteralConvertible<UnicodeScalarLiteralType> = IExpressibleByUnicodeScalarLiteral<UnicodeScalarLiteralType>
  • UnicodeScalarType
    • String  .NET, .NET Standard 1.3, Cooper, Island
    • NSString  Toffee
  • UnsignedIntegerType = IUnsignedIntegerType
  • UTF16Char = Char
  • UTF32Char
    • UInt32  .NET, .NET Standard 1.3, Island, Toffee
    • Cardinal  Cooper
  • UTF8Char
    • Byte  .NET, .NET Standard 1.3, Cooper
    • AnsiChar  Island, Toffee
  • UWord
    • UInt16  .NET, .NET Standard 1.3, Island, Toffee
    • Word  Cooper
  • Word
    • Int64  .NET, .NET Standard 1.3, 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