Skip to content

Commit ce62d23

Browse files
authored
Merge pull request #10 from skiptools/androidbundle
Expose AndroidBundle to non-os(Android) code
2 parents 9aa8d0a + 20a3af5 commit ce62d23

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

Sources/SkipAndroidBridge/AndroidBridgeBootstrap.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public class AndroidBridgeBootstrap {
8686
logger.debug("initAndroidBridge: bootstrapSSLCertificates")
8787
try bootstrapSSLCertificates()
8888
logger.debug("initAndroidBridge: AndroidLooper.setupMainLooper")
89-
AndroidLooper.setupMainLooper()
89+
let _ = AndroidLooper.setupMainLooper()
9090
logger.debug("initAndroidBridge: done")
9191
#endif
9292
logger.debug("AndroidBridgeBootstrap.initAndroidBridge done in \(Date.now.timeIntervalSince(start)) applicationSupportDirectory=\(URL.applicationSupportDirectory.path)")

Sources/SkipAndroidBridge/AndroidBundle.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright 2025 Skip
22
// SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
3-
#if os(Android) || ROBOLECTRIC
43
import Foundation
54
import SkipBridge
65

76
/// Override of native `Bundle` for Android that delegates to our `skip.foundation.Bundle` Kotlin object.
87
open class AndroidBundle : Foundation.Bundle, @unchecked Sendable {
8+
#if os(Android) || ROBOLECTRIC
99
fileprivate let bundleAccess: BundleAccess
1010

1111
open override class var main: AndroidBundle {
@@ -303,8 +303,11 @@ open class AndroidBundle : Foundation.Bundle, @unchecked Sendable {
303303
open override var executableArchitectures: [NSNumber]? {
304304
fatalError()
305305
}
306+
#endif
306307
}
307308

309+
#if os(Android) || ROBOLECTRIC
310+
308311
extension AndroidBundle : JObjectProtocol, JConvertible {
309312
public static func fromJavaObject(_ obj: JavaObjectPointer?, options: JConvertibleOptions) -> Self {
310313
return try! Self.init(BundleAccess(AnyDynamicObject(for: obj!, options: options)))

Sources/SkipAndroidBridge/AssetURLProtocol.swift

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,13 @@ public class AssetURLProtocol: URLProtocol {
5959
return
6060
}
6161

62-
do {
63-
let assetPath = String(url.path.trimmingPrefix("/")) // Asset read paths are without preceeding slashes
64-
if let data = assetManager.load(from: assetPath) {
65-
sendHTTP(code: 200)
66-
client.urlProtocol(self, didLoad: data)
67-
} else {
68-
sendHTTP(code: 404)
69-
}
70-
} catch {
71-
client.urlProtocol(self, didFailWithError: error)
62+
let assetPath = String(url.path.trimmingPrefix("/")) // Asset read paths are without preceeding slashes
63+
if let data = assetManager.load(from: assetPath) {
64+
sendHTTP(code: 200)
65+
client.urlProtocol(self, didLoad: data)
66+
} else {
67+
sendHTTP(code: 404)
7268
}
73-
7469
}
7570

7671
public override class func canInit(with request: URLRequest) -> Bool {

0 commit comments

Comments
 (0)