This is a minimal Objective C runtime written in C, designed to be portable across different platforms, including ARM and x86 architectures, mostly targeting embedded systems. It uses the "gcc" ABI for the moment, as that is the most portable across different platforms.
You will minimally need the following tools to build the runtime:
make and cmake - for the build systemclang or gcc - for compiling the runtime (clang is not supported on Apple Silicon). You can use the environment variable CC to specify the compiler, e.g. CC=clang or CC=gcc.openssl for Linux and Darwin - for the hash functions, which are used in the runtime and Foundation framework.docker is needed for generating the documentation from the source code./opt directory. You can use the environment variable TOOLCHAIN_PATH to specify the path to the toolchain, e.g. TOOLCHAIN_PATH=/opt/LLVM-ET-Arm-19.1.5-Darwin-universal.Several static libraries are currently built:
objc-gcc - the Objective C runtime library using the ancient GCC ABIruntime-sys - a minimal set of system functions, needed to bind the runtime to the underlying system, on a per-platform basis. Includes cryptographic hash functions (MD5, SHA-256).runtime-hw - hardware interfaces like SPI, I2C, GPIO. These are stubs for Linux and Darwin, but I guess some of these interfaces couple be implemented later.runtime-fs - organizing files, directories and volumes which can either be volatile (in-memory) or non-volatile (file-based or in flash)drivers and runtime-pix have a long way to go but should provide hardware driver and display support eventually.Foundation - a minimal set of classes, to support memory management and basic types such as string, array, dictionary, date, time and number.Application - the application framework, which provides a runloop and handles input, display, power and sensors.A lot of this code is in development still. See the "examples" or documentation on what's been implemented so far.
Download the source code from GitHub:
The TOOLCHAIN_PATH environment variable should point to the directory where the toolchain is installed. For Macintosh, you can use Homebrew to install the GCC toolchain, which is required for compiling the runtime on MacOS:
Once you've made the libraries, use the make tests target to run the unit tests. There is information about test coverage in the tests directory.
On macOS, build and run all tests:
Run an individual test target (replace <test_target> with e.g. fs_09):
See the tests README for a catalog of tests (fs_01..fs_09 and others) and details.
You can target different architectures by setting the TARGET environment variable. For a RP2040-based board, you can use the clang compiler with the ARM toolchain. The TARGET environment variable should be set to the target architecture, such as armv6m-none-eabi for the RP2040 Pico board:
See the list of supported targets in the cmake directory. You can exclude the environment variable RELEASE=1 to build debugging versions of the libraries.
For Pico cross-compilation, after building, you can load a specific test onto a Pico W board (example for <test_target>):
For Linux cross-compilation using Docker (Bookworm):
The libraries should be installed under a prefix path:
These can subsequently be used in projects to make executables for any combination of platform.
To build the API documentation, you will need to have docker installed. The documentation is built using doxygen through docker so you don't need to have it installed directly.
The documentation is also published on the project documentation site.
NXConstantString[super init] for exampleNXZonevsprintf - printf-like function which can be used by NXLog, NXString and sys_panicfNXDate - mutable date and timeNXNumber with booleansNXNull - singleton for null objects that can be inserted into collectionsconformsTo:NXNumber with NXNumberInt16 and NXNumberUnsignedInt16NXNumber with NXNumberInt32 and NXNumberUnsignedInt32NXNumber with NXNumberInt64 and NXNumberUnsignedInt64NXString - mutable strings - append, appendFormatNXArray - ordered collections of objects, with methods for adding, removing, and accessing objectsNXData - mutable binary data with Base64/hex encoding and append operationssys_hash_* API%@ format specifier for logging objects and [Object description]T format specifier for time intervalsNXArray - string methods - joinNXMap - unordered collections with string-keys (what about NXDictionary?)NXMap - arbitary key sizesGPIO uses static instances, and <GPIODelegate> protocol to handle GPIO events which are pushed from the runloopNXInputManager - input manager for handling keyboard, mouse, GPIO and other input devices with single click, double click and so forth.NXApplication and NXRunLoop running on both coresPower class and <PowerDelegate> for managing power, resets, uptime, etc.@synchronized support - use fixed-size table to store locks for objects, no allocationsNXNumberUnsignedInt8 and NXNumberInt8NXScanner, ReaderProtocol - scanning, parsing and tokenizing - needs unicode workNXData - fix hexString encoding and decoding (see test NXFoundation_22)?NXArray sortWithFunction: sortedArrayWithFunction: reverse: and reversedArray:NXArray filterWithFunction: filteredArrayWithFunction:NXRange and NXString - substringWithRange and substringWithRange:options:NXString - rangeOfSubstring and rangeOfSubstring:options:NXArray - subarrayWithRange: and subarrayWithRange:options:NXString - array methods - componentsSeparatedByString and componentsSeparatedByByteNXNumber with NXNumberFloat and NXNumberDoublef and lf format specifier for floats and doublesmake install will compile the libraries and install them to a prefix path - third-party repositories can compile against itrespondsToSelector: (see test runtime_14) and lots of tests - might be working?NXSensorManager - sensor manager for handling sensors such as accelerometer, gyroscope, magnetometer, temperature, humidity, pressure, etc.NXWirelessManager - keeps track of wireless networks, connections, disconnectionsNXURL class - URL/filepath parsing and manipulationNXFile - represents an open fileNXFileManager - manages files and directories on a volumeNXFileDirectory - represents a directory on a volumeNXCoder - JSON / Binary marshalling and unmarshalling+[initialise] for categoriesHere are some references that may be useful for understanding the Objective C runtime and its implementation: