Skip to content

Commit c378b52

Browse files
authored
Merge pull request #1 from PureSwift/feature/javakit
Add JavaKit support
2 parents 252379a + c562ead commit c378b52

File tree

109 files changed

+6459
-16789
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+6459
-16789
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# These are supported funding model platforms
2+
ko_fi: colemancda

.github/pull_request_template.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
**Issue**
2+
3+
Fixes #1.
4+
5+
**What does this PR Do?**
6+
7+
Description of the changes in this pull request.
8+
9+
**Where should the reviewer start?**
10+
11+
`main.swift`
12+
13+
**Sweet giphy showing how you feel about this PR**
14+
15+
![Giphy](https://media.giphy.com/media/rkDXJA9GoWR2/giphy.gif)

.github/workflows/swift.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Swift
2+
on: [push]
3+
jobs:
4+
5+
android:
6+
name: Android
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
swift: ['6.1']
11+
arch: ['aarch64', 'x86_64']
12+
sdk: ['24', '28', '29']
13+
runs-on: macos-15
14+
timeout-minutes: 30
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: "Build Swift Package for Android"
18+
run: |
19+
brew install skiptools/skip/skip || (brew update && brew install skiptools/skip/skip)
20+
skip android sdk install --version ${{ matrix.swift }}
21+
ANDROID_NDK_ROOT="" ANDROID_SDK_VERSION=${{ matrix.sdk }} skip android build --arch ${{ matrix.arch }} --android-api-level ${{ matrix.sdk }}

Package.swift

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
// swift-tools-version:5.7
1+
// swift-tools-version:6.1
22
import PackageDescription
3+
import CompilerPluginSupport
4+
5+
import class Foundation.FileManager
6+
import class Foundation.ProcessInfo
7+
8+
// Get NDK version from command line
9+
let environment = ProcessInfo.processInfo.environment
10+
let ndkVersion = environment["ANDROID_NDK_VERSION"].flatMap { UInt($0) } ?? 27
11+
let ndkVersionDefine = SwiftSetting.define("ANDROID_NDK_VERSION_" + ndkVersion.description)
12+
13+
// Get Android API version
14+
let sdkVersion = environment["ANDROID_SDK_VERSION"].flatMap { UInt($0) } ?? 29
15+
let sdkVersionDefine = SwiftSetting.define("ANDROID_SDK_VERSION_" + ndkVersion.description)
316

417
let package = Package(
518
name: "AndroidBluetooth",
619
platforms: [
7-
.macOS(.v10_15),
8-
.iOS(.v13),
9-
.watchOS(.v6),
10-
.tvOS(.v13),
20+
.macOS(.v15)
1121
],
1222
products: [
1323
.library(
@@ -25,24 +35,39 @@ let package = Package(
2535
),
2636
.package(
2737
url: "https://github.com/PureSwift/Bluetooth.git",
28-
.upToNextMajor(from: "6.0.0")
38+
from: "7.2.0"
2939
)
3040
],
3141
targets: [
3242
.target(
3343
name: "AndroidBluetooth",
3444
dependencies: [
35-
"Android",
36-
"Bluetooth",
37-
"GATT",
45+
.product(
46+
name: "Bluetooth",
47+
package: "Bluetooth"
48+
),
3849
.product(
3950
name: "BluetoothGAP",
4051
package: "Bluetooth"
52+
),
53+
.product(
54+
name: "GATT",
55+
package: "GATT"
56+
),
57+
.product(
58+
name: "AndroidKit",
59+
package: "Android"
4160
)
42-
]),
43-
.testTarget(
44-
name: "AndroidBluetoothTests",
45-
dependencies: ["AndroidBluetooth"]
61+
],
62+
exclude: ["swift-java.config"],
63+
swiftSettings: [
64+
.swiftLanguageMode(.v5),
65+
ndkVersionDefine,
66+
sdkVersionDefine
67+
],
68+
plugins: [
69+
//.plugin(name: "SwiftJavaPlugin", package: "swift-java")
70+
]
4671
)
4772
]
4873
)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Auto-generated by Java-to-Swift wrapper generator.
2+
import JavaKit
3+
import JavaRuntime
4+
5+
@JavaClass("android.bluetooth.le.AdvertiseCallback")
6+
open class AdvertiseCallback: JavaObject {
7+
@JavaMethod
8+
@_nonoverride public convenience init(environment: JNIEnvironment? = nil)
9+
10+
@JavaMethod
11+
open func onStartSuccess(_ arg0: AdvertiseSettings?)
12+
13+
@JavaMethod
14+
open func onStartFailure(_ arg0: Int32)
15+
}
16+
extension JavaClass<AdvertiseCallback> {
17+
@JavaStaticField(isFinal: true)
18+
public var ADVERTISE_FAILED_ALREADY_STARTED: Int32
19+
20+
@JavaStaticField(isFinal: true)
21+
public var ADVERTISE_FAILED_DATA_TOO_LARGE: Int32
22+
23+
@JavaStaticField(isFinal: true)
24+
public var ADVERTISE_FAILED_FEATURE_UNSUPPORTED: Int32
25+
26+
@JavaStaticField(isFinal: true)
27+
public var ADVERTISE_FAILED_INTERNAL_ERROR: Int32
28+
29+
@JavaStaticField(isFinal: true)
30+
public var ADVERTISE_FAILED_TOO_MANY_ADVERTISERS: Int32
31+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Auto-generated by Java-to-Swift wrapper generator.
2+
import AndroidOS
3+
import JavaKit
4+
import JavaRuntime
5+
6+
extension AdvertiseData {
7+
@JavaClass("android.bluetooth.le.AdvertiseData$Builder")
8+
open class Builder: JavaObject {
9+
@JavaMethod
10+
@_nonoverride public convenience init(environment: JNIEnvironment? = nil)
11+
12+
@JavaMethod
13+
open func addServiceUuid(_ arg0: ParcelUuid?) -> AdvertiseData.Builder!
14+
15+
@JavaMethod
16+
open func addServiceData(_ arg0: ParcelUuid?, _ arg1: [Int8]) -> AdvertiseData.Builder!
17+
18+
@JavaMethod
19+
open func addServiceSolicitationUuid(_ arg0: ParcelUuid?) -> AdvertiseData.Builder!
20+
21+
@JavaMethod
22+
open func addTransportDiscoveryData(_ arg0: TransportDiscoveryData?) -> AdvertiseData.Builder!
23+
24+
@JavaMethod
25+
open func addManufacturerData(_ arg0: Int32, _ arg1: [Int8]) -> AdvertiseData.Builder!
26+
27+
@JavaMethod
28+
open func setIncludeTxPowerLevel(_ arg0: Bool) -> AdvertiseData.Builder!
29+
30+
@JavaMethod
31+
open func setIncludeDeviceName(_ arg0: Bool) -> AdvertiseData.Builder!
32+
33+
@JavaMethod
34+
open func build() -> AdvertiseData!
35+
}
36+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Auto-generated by Java-to-Swift wrapper generator.
2+
import AndroidOS
3+
import AndroidUtil
4+
import JavaKit
5+
import JavaKitCollection
6+
import JavaRuntime
7+
import JavaUtil
8+
9+
/**
10+
Advertise data packet container for Bluetooth LE advertising. This represents the data to be advertised as well as the scan response data for active scans.
11+
12+
Use ``AdvertiseData.Builder`` to create an instance of ``AdvertiseData`` to be advertised.
13+
*/
14+
@JavaClass("android.bluetooth.le.AdvertiseData", implements: Parcelable.self)
15+
open class AdvertiseData: JavaObject {
16+
@JavaMethod
17+
open func describeContents() -> Int32
18+
19+
@JavaMethod
20+
open func writeToParcel(_ arg0: Parcel?, _ arg1: Int32)
21+
22+
@JavaMethod
23+
open func getServiceUuids() -> List<ParcelUuid>!
24+
25+
@JavaMethod
26+
open func getServiceData() -> Map<ParcelUuid, JavaArray>!
27+
28+
@JavaMethod
29+
open func getServiceSolicitationUuids() -> List<ParcelUuid>!
30+
31+
@JavaMethod
32+
open func getManufacturerSpecificData() -> SparseArray<JavaArray>!
33+
34+
@JavaMethod
35+
open func getTransportDiscoveryData() -> List<TransportDiscoveryData>!
36+
37+
@JavaMethod
38+
open func getIncludeTxPowerLevel() -> Bool
39+
40+
@JavaMethod
41+
open func getIncludeDeviceName() -> Bool
42+
43+
@JavaMethod
44+
open func equals(_ arg0: AdvertiseData?) -> Bool
45+
46+
@JavaMethod
47+
open override func toString() -> String
48+
49+
@JavaMethod
50+
open override func hashCode() -> Int32
51+
}
52+
extension JavaClass<AdvertiseData> {
53+
@JavaStaticField(isFinal: true)
54+
public var CREATOR: Parcelable.Creator<AdvertiseData>!
55+
56+
@JavaStaticField(isFinal: true)
57+
public var CONTENTS_FILE_DESCRIPTOR: Int32
58+
59+
@JavaStaticField(isFinal: true)
60+
public var PARCELABLE_WRITE_RETURN_VALUE: Int32
61+
}
62+
63+
extension AdvertiseData: CustomStringConvertible {
64+
65+
public var description: String {
66+
toString()
67+
}
68+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Auto-generated by Java-to-Swift wrapper generator.
2+
import JavaKit
3+
import JavaRuntime
4+
5+
extension AdvertiseSettings {
6+
@JavaClass("android.bluetooth.le.AdvertiseSettings$Builder")
7+
open class Builder: JavaObject {
8+
@JavaMethod
9+
@_nonoverride public convenience init(environment: JNIEnvironment? = nil)
10+
11+
@JavaMethod
12+
open func setAdvertiseMode(_ arg0: Int32) -> AdvertiseSettings.Builder!
13+
14+
@JavaMethod
15+
open func setTxPowerLevel(_ arg0: Int32) -> AdvertiseSettings.Builder!
16+
17+
@JavaMethod
18+
open func setConnectable(_ arg0: Bool) -> AdvertiseSettings.Builder!
19+
20+
@JavaMethod
21+
open func setDiscoverable(_ arg0: Bool) -> AdvertiseSettings.Builder!
22+
23+
@JavaMethod
24+
open func setTimeout(_ arg0: Int32) -> AdvertiseSettings.Builder!
25+
26+
@JavaMethod
27+
open func build() -> AdvertiseSettings!
28+
}
29+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Auto-generated by Java-to-Swift wrapper generator.
2+
import AndroidOS
3+
import JavaKit
4+
import JavaRuntime
5+
6+
@JavaClass("android.bluetooth.le.AdvertiseSettings", implements: Parcelable.self)
7+
open class AdvertiseSettings: JavaObject {
8+
@JavaMethod
9+
open func describeContents() -> Int32
10+
11+
@JavaMethod
12+
open func writeToParcel(_ arg0: Parcel?, _ arg1: Int32)
13+
14+
@JavaMethod
15+
open func isConnectable() -> Bool
16+
17+
@JavaMethod
18+
open func isDiscoverable() -> Bool
19+
20+
@JavaMethod
21+
open func getTxPowerLevel() -> Int32
22+
23+
@JavaMethod
24+
open func getMode() -> Int32
25+
26+
@JavaMethod
27+
open func getTimeout() -> Int32
28+
29+
@JavaMethod
30+
open override func toString() -> String
31+
}
32+
extension JavaClass<AdvertiseSettings> {
33+
@JavaStaticField(isFinal: true)
34+
public var ADVERTISE_MODE_BALANCED: Int32
35+
36+
@JavaStaticField(isFinal: true)
37+
public var ADVERTISE_MODE_LOW_LATENCY: Int32
38+
39+
@JavaStaticField(isFinal: true)
40+
public var ADVERTISE_MODE_LOW_POWER: Int32
41+
42+
@JavaStaticField(isFinal: true)
43+
public var ADVERTISE_TX_POWER_HIGH: Int32
44+
45+
@JavaStaticField(isFinal: true)
46+
public var ADVERTISE_TX_POWER_LOW: Int32
47+
48+
@JavaStaticField(isFinal: true)
49+
public var ADVERTISE_TX_POWER_MEDIUM: Int32
50+
51+
@JavaStaticField(isFinal: true)
52+
public var ADVERTISE_TX_POWER_ULTRA_LOW: Int32
53+
54+
@JavaStaticField(isFinal: true)
55+
public var CREATOR: Parcelable.Creator<AdvertiseSettings>!
56+
57+
@JavaStaticField(isFinal: true)
58+
public var CONTENTS_FILE_DESCRIPTOR: Int32
59+
60+
@JavaStaticField(isFinal: true)
61+
public var PARCELABLE_WRITE_RETURN_VALUE: Int32
62+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Auto-generated by Java-to-Swift wrapper generator.
2+
import JavaKit
3+
import JavaRuntime
4+
5+
@JavaClass("android.bluetooth.le.AdvertisingSet")
6+
open class AdvertisingSet: JavaObject {
7+
@JavaMethod
8+
open func enableAdvertising(_ arg0: Bool, _ arg1: Int32, _ arg2: Int32)
9+
10+
@JavaMethod
11+
open func setAdvertisingData(_ arg0: AdvertiseData?)
12+
13+
@JavaMethod
14+
open func setScanResponseData(_ arg0: AdvertiseData?)
15+
16+
@JavaMethod
17+
open func setAdvertisingParameters(_ arg0: AdvertisingSetParameters?)
18+
19+
@JavaMethod
20+
open func setPeriodicAdvertisingParameters(_ arg0: PeriodicAdvertisingParameters?)
21+
22+
@JavaMethod
23+
open func setPeriodicAdvertisingData(_ arg0: AdvertiseData?)
24+
25+
@JavaMethod
26+
open func setPeriodicAdvertisingEnabled(_ arg0: Bool)
27+
}

0 commit comments

Comments
 (0)