Skip to content

Commit

Permalink
Add AndroidContext
Browse files Browse the repository at this point in the history
  • Loading branch information
marcprux committed Oct 30, 2024
1 parent 6560563 commit 87b99f6
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 399 deletions.
14 changes: 7 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// swift-tools-version: 5.10
// swift-tools-version: 5.9
import PackageDescription

let package = Package(
name: "skip-android-bridge",
defaultLocalization: "en",
platforms: [.iOS(.v16), .macOS(.v13), .tvOS(.v16), .watchOS(.v9), .macCatalyst(.v16)],
products: [
.library(name: "SkipAndroidBridge", type: .dynamic, targets: ["SkipAndroidBridge"]),
.library(name: "AndroidBridge", type: .dynamic, targets: ["AndroidBridge"]),
],
dependencies: [
.package(url: "https://source.skip.tools/skip.git", from: "1.1.16"),
Expand All @@ -15,14 +15,14 @@ let package = Package(
.package(url: "https://source.skip.tools/swift-android-native.git", branch: "main")
],
targets: [
.target(name: "SkipAndroidBridge", dependencies: [
.target(name: "AndroidBridge", dependencies: [
.product(name: "SkipBridge", package: "skip-bridge"),
.product(name: "SkipFoundation", package: "skip-foundation"),
.product(name: "AndroidNative", package: "swift-android-native"),
], resources: [.process("Resources")], plugins: [.plugin(name: "skipstone", package: "skip")]),
.testTarget(name: "SkipAndroidBridgeTests", dependencies: [
"SkipAndroidBridge",
], plugins: [.plugin(name: "skipstone", package: "skip")]),
.testTarget(name: "AndroidBridgeTests", dependencies: [
"AndroidBridge",
.product(name: "SkipTest", package: "skip"),
], resources: [.process("Resources")], plugins: [.plugin(name: "skipstone", package: "skip")]),
], plugins: [.plugin(name: "skipstone", package: "skip")]),
]
)
13 changes: 13 additions & 0 deletions Sources/AndroidBridge/AndroidBridge.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU Lesser General Public License 3.0
// as published by the Free Software Foundation https://fsf.org

import Foundation
#if canImport(AndroidNative)
import AndroidNative
#else
import OSLog
#endif

fileprivate let logger: Logger = Logger(subsystem: "AndroidBridge", category: "AndroidSwiftBridge")

26 changes: 26 additions & 0 deletions Sources/AndroidBridge/Kotlin/AndroidKotlinBridge.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Foundation
import OSLog

fileprivate let logger: Logger = Logger(subsystem: "AndroidBridge", category: "AndroidKotlinBridge")

// SKIP @BridgeToSwift
func getJavaSystemProperty(_ name: String) -> String? {
#if SKIP
return java.lang.System.getProperty(name)
#else
return nil
#endif
}

// SKIP @BridgeToSwift
public class AndroidContext {
#if SKIP
public static let shared: AndroidContext = AndroidContext(context: ProcessInfo.processInfo.androidContext)

private let context: android.content.Context

private init(context: android.content.Context) {
self.context = context
}
#endif
}
File renamed without changes.
14 changes: 0 additions & 14 deletions Sources/SkipAndroidBridge/Kotlin/AndroidKotlinBridge.swift

This file was deleted.

Loading

0 comments on commit 87b99f6

Please sign in to comment.