Skip to content
Lucent
SEARCH LUCENT

Search guides, APIs, and examples.

GitHub

Very early and experimental. The language, the generated native code and every package API change without notice. Do not use Lucent in production.

SDK types

How iOS and Android SDK declarations appear in Lucent: names, nullability, enums, errors, callbacks.

In the SDKIn Lucent
a framework or pod moduleimport { … } from "lucent:ios/UIKit"
class and member namesSwift's names: UIDevice.current, FileManager.default
nested typesjoined with _: UIImpactFeedbackGenerator_FeedbackStyle
methodsSwift's base name, labels dropped: evaluatePolicy(policy, reason). Colliding overloads keep their labels: resizeHeight.
protocol requirements you implementthe base name and labels joined with _: locationManager_didUpdateLocations
initializersconstructor, labels dropped: new CLLocation(48.85, 2.35)
T?T | null; nil where the SDK promises a value throws a TypeError
NSInteger, NSUInteger, int64_t, uint64_t, Swift's Int, Int64, UInt64bigint, exact: list.count is 3n; a bigint the type can't hold throws a RangeError
int, double, CGFloat and other numbersnumber
enums, C enumsenum members, checked against the SDK when the C++ compiles
C functions and constantsfunctions and constants: SecItemCopyMatching, kSecClass
C structsobject types, copied: CGRect is { origin: { x, y }, size: { width, height } }
NSString, NSData, NSDatestring, Uint8Array, Date
NSNumberthe NSNumber class: read doubleValue (import Foundation); an Any holding one reads with asNumber
NSArray<T>, NSSet<T>, NSDictionary<NSString, T>T[], Set<T>, Record<string, T>, copied
id, AnyObjCValue as a parameter, NSObject as a result; read it with asString, asNumber, asData…
throws (an NSError **)a thrown error whose code is "domain:code"
an NSError ** Swift doesn't turn into throwsan Out<Error> argument, read after the call
a completion handlera promise, under the name of Swift's async form: await context.evaluatePolicy(policy, reason)
a block parametera function
a protocolan interface to implements; optional requirements are optional
@MainActoronly inside main(), or a block or requirement the SDK calls on the main thread (LUCENT3006)
a weak delegate propertykept alive by its owner while set
In the SDKIn Lucent
a package of android.jar or of the app's Gradle dependenciesimport { … } from "lucent:android/android.os"
class and member namesJava's names: Build.MODEL, getSystemService
nested classesjoined with _: Build_VERSION, ConnectivityManager_NetworkCallback
getX() and isX() without argumentsalso a read-only property: getDefaultVibrator() is defaultVibrator, isCharging() is charging
references without a @NonNull annotationT | null
Class<T> parametersthe class itself: getSystemService(Vibrator)
longbigint, exact: vibrate(20n); a bigint a long can't hold throws a RangeError
int, double and other numbers, @IntDef and @LongDef constantsnumber
arraysbyte[], int[], long[] (as bigint[]), String[] only
an exceptiona thrown error whose code is the exception's class: java.lang.SecurityException
an interface with one method to implementa function, or a class that implements it
an interface with severala class that implements it; default methods keep their Java body
a class to extendclass Watcher extends ConnectivityManager_NetworkCallback, calling super() with no arguments
APIs newer than API 24only under available("android", N) or Build_VERSION.SDK_INT >= N (LUCENT3007)
@RequiresPermissionthe permission is added to the native package's manifest
  • iOS: pointers, ObjCBool, Selector, AnyClass, generic Objective-C classes and protocol compositions.
  • iOS: Swift-only APIs, factory initializers, and subclassing iOS classes.
  • iOS: catching an NSException, passing an Error to Objective-C, and collections nested in collections.
  • Android: members of generic classes that use the class's type parameters, such as Consumer<T>.accept and List<E>.get. Other members of a java.util collection, such as size(), work.
  • Android: arrays other than those above, writing Java fields, and the current Activity.
  • Android: a char argument to a Lucent function, and a Lucent function returning an object to Java.
  • Both: SDK objects crossing to JavaScript, and calling a method of an SDK object as a value.

The roadmap tracks what comes next.