skiptools / skiptools/skip-android-bridge

skip-android-bridge 0.6.1: fromJavaObject references UserDefaultsAccess outside #if SKIP guard, breaking Android cross-compile

Open
#21 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
4
Forks
9
Avg merge
41m
Merged PRs (30d)
1

Description

Description:**

Environment

  • skip-android-bridge: 0.6.1
  • skip-fuse-ui: 1.14.0
  • Swift toolchain: swift-6.2.3-RELEASE
  • Swift SDK: aarch64-unknown-linux-android28
  • Host: macOS, building for Android via Xcode/Skip plugin

What happens

The Android cross-compile step fails with:

Sources/SkipAndroidBridge/AndroidUserDefaults.swift:186:31: error: cannot find 'UserDefaultsAccess' in scope

Full command that fails (run by the Skip plugin):

swift build \
  --swift-sdk aarch64-unknown-linux-android28 \
  --configuration debug \
  -Xswiftc -DSKIP_BRIDGE \
  -Xswiftc -DTARGET_OS_ANDROID \
  --product SkipSpike

Root cause

In AndroidUserDefaults.swift, the JObjectProtocol/JConvertible conformance extension (line 184) sits outside the #if SKIP block but references UserDefaultsAccess, which is defined inside #if SKIP (line 197):

// line 184 — outside #if SKIP
extension AndroidUserDefaults : JObjectProtocol, JConvertible {
    public static func fromJavaObject(_ obj: JavaObjectPointer?, options: JConvertibleOptions) -> Self {
        return try! Self.init(UserDefaultsAccess(...))  // ← UserDefaultsAccess not in scope here
    }
    ...
}

#if SKIP  // line 194

public class UserDefaultsAccess {  // ← defined here, too late
    ...
}

The cross-compile uses -DSKIP_BRIDGE and -DTARGET_OS_ANDROID but not -DSKIP, so UserDefaultsAccess is never declared when the extension is compiled.

What was tried

Moving the extension inside #if SKIP resolves the UserDefaultsAccess scope error but produces a new transpiler error:

error: This API is implemented as a Kotlin extension function. 
This release does not support bridging from Swift to Kotlin extension functions

So the extension can't live inside #if SKIP either. The root fix likely needs UserDefaultsAccess to be declared before/outside the #if SKIP block (at minimum for its type signature), or the conformance extension needs a different approach for the cross-compile path.

Impact

Any project depending on skip-fuse-ui >= 1.14.0 (which requires skip-android-bridge >= 0.6.1) fails to build for Android. This blocks all Android builds introduced by this version combination.


I'm quite new to swift and skip - coming from flutter to try and nuke the BLE issues we've been constantly hitting. The above is info I managed to divine through use of AI tooling.

Compile through Xcode works fine for iOS

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Sources/SkipAndroidBridge/AndroidUserDefaults.swift around the JObjectProtocol/JConvertible extension and the #if SKIP block defining UserDefaultsAccess. Reproduce the reported swift build with the Android SDK and compiler flags, then determine a compatible arrangement that avoids both the missing-type and Kotlin-extension transpiler errors. Done means the Skip plugin Android cross-compile succeeds for the reported dependency versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, swift
Domain
build-system, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.