Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Sources/SkipBuild/Commands/VerifyCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,6 @@ extension ToolOptionsCommand where Self : StreamingCommand {

let packageJSON = try await parseSwiftPackage(with: out, at: projectPath)
let packageName = packageJSON.name
guard let moduleName = packageJSON.products.first?.name else {
throw AppVerifyError(errorDescription: "No products declared in package \(packageName) at \(projectPath)")
}

//let project = try FrameworkProjectLayout(root: projectFolderURL)
//let sourcesDir = URL(fileURLWithPath: "Sources", isDirectory: true, relativeTo: projectFolderURL)
Expand Down Expand Up @@ -259,6 +256,14 @@ extension ToolOptionsCommand where Self : StreamingCommand {
throw MissingProjectFileError(errorDescription: "Expected path at \(url.path) does not exist")
}

guard let firstProduct = packageJSON.products.first else {
throw AppVerifyError(errorDescription: "No products declared in package \(packageName) at \(projectPath)")
}

guard let moduleName = firstProduct.targets.first else {
throw AppVerifyError(errorDescription: "The products \(firstProduct) declared in package \(packageName) at \(projectPath) has no targets")
}

let project = try AppProjectLayout(moduleName: moduleName, root: projectFolderURL, check: validateLayoutURL)

await checkFile(project.skipEnv, with: out) { title, url in
Expand Down
21 changes: 9 additions & 12 deletions Sources/SkipSyntax/Kotlin/KotlinBundleTransformer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,24 @@ public final class KotlinBundleTransformer: KotlinTransformer {
let className = moduleBundleAccessorClassName(moduleName: moduleName)
let outputNode = SwiftDefinition { output, indentation, _ in
// The blank line after the SkipBridge import is expected by our bridge testing
// the unusedp_0 param is needed or else error: initializer 'init(path:)' declared in 'Bundle' cannot be overridden from extension
output.append("""
import SkipBridge

import Foundation
import SkipAndroidBridge

typealias Bundle = AndroidModuleBundle
class AndroidModuleBundle : AndroidBundle, @unchecked Sendable {
required init(_ bundle: SkipAndroidBridge.BundleAccess) {
super.init(bundle)
}

init?(path: String) {
super.init(path: path, moduleName: "\(moduleName)") {
public typealias Bundle = AndroidBundle

// Interceptor for initializing a Bundle with a path
// (either manually or through the synthesized Bundle.module property),
// which forwards the bundle access up to the Android asset manager
extension AndroidBundle {
convenience init?(path: String, unusedp_0: Void? = nil) {
self.init(path: path, moduleName: "\(moduleName)") {
try! AnyDynamicObject(className: "\(packageName).\(className)").moduleBundle!
}
}

override init?(url: URL) {
super.init(url: url)
}
}

let NSLocalizedString = AndroidLocalizedString()
Expand Down
20 changes: 8 additions & 12 deletions Tests/SkipSyntaxTests/BridgeToKotlinTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9044,21 +9044,17 @@ final class BridgeToKotlinTests: XCTestCase {
import Foundation
import SkipAndroidBridge

typealias Bundle = AndroidModuleBundle
class AndroidModuleBundle : AndroidBundle, @unchecked Sendable {
required init(_ bundle: SkipAndroidBridge.BundleAccess) {
super.init(bundle)
}

init?(path: String) {
super.init(path: path, moduleName: "") {
public typealias Bundle = AndroidBundle

// Interceptor for initializing a Bundle with a path
// (either manually or through the synthesized Bundle.module property),
// which forwards the bundle access up to the Android asset manager
extension AndroidBundle {
convenience init?(path: String, unusedp_0: Void? = nil) {
self.init(path: path, moduleName: "") {
try! AnyDynamicObject(className: ".module._ModuleBundleAccessor_").moduleBundle!
}
}

override init?(url: URL) {
super.init(url: url)
}
}

let NSLocalizedString = AndroidLocalizedString()
Expand Down
Loading