With the 2.0.0 release, AndroidLogging was changed and a new OSLog wrapper was introduced for API compatibility with the OSLog module on Darwin systems. However, it doesn't seem to be able to be used by downstream projects, and the example code in the README does not compile.
Adding AndroidLogging as a dependency alone does not bring in the OSLog wrapper, but trying to add OSLog as a dependency results in an error:
dependencies: [
.product(name: "Logging", package: "swift-log", condition: .when(platforms: [.linux])),
.product(name: "OSLog", package: "swift-android-native", condition: .when(platforms: [.android]))
]
error: 'myproj': product 'OSLog' required by package 'myproj' target 'MyLogger' not found in package 'swift-android-native'.
It looks like the OSLog module is conditionally defined in Package.swift, which is probably why it is unavailable:
|
if android { |
|
// add compatibility import from OSLog to AndroidLogging |
|
package.targets += [.target(name: "OSLog", dependencies: ["AndroidLogging"])] |
|
package.targets.first(where: { $0.name == "AndroidLoggingTests" })?.dependencies += [.target(name: "OSLog")] |
|
} |
Is there a reason it can't be unconditionally defined when targeting the Android platform? Or, how is this intended to be used since the example code is broken?
With the 2.0.0 release, AndroidLogging was changed and a new OSLog wrapper was introduced for API compatibility with the OSLog module on Darwin systems. However, it doesn't seem to be able to be used by downstream projects, and the example code in the README does not compile.
Adding AndroidLogging as a dependency alone does not bring in the OSLog wrapper, but trying to add OSLog as a dependency results in an error:
It looks like the OSLog module is conditionally defined in Package.swift, which is probably why it is unavailable:
swift-android-native/Package.swift
Lines 224 to 228 in 255a289
Is there a reason it can't be unconditionally defined when targeting the Android platform? Or, how is this intended to be used since the example code is broken?