@@ -20,7 +20,6 @@ struct BridgeJSBuildPlugin: BuildToolPlugin {
2020
2121 private func createGenerateCommand( context: PluginContext , target: SwiftSourceModuleTarget ) throws -> Command {
2222 let outputSwiftPath = context. pluginWorkDirectoryURL. appending ( path: " BridgeJS.swift " )
23- let outputSkeletonPath = context. pluginWorkDirectoryURL. appending ( path: " JavaScript/BridgeJS.json " )
2423
2524 let inputSwiftFiles = target. sourceFiles. filter {
2625 !$0. url. path. hasPrefix ( context. pluginWorkDirectoryURL. path + " / " )
@@ -67,9 +66,14 @@ struct BridgeJSBuildPlugin: BuildToolPlugin {
6766 for skeleton in dependencySkeletons ( context: context, target: target) {
6867 arguments. append ( contentsOf: [
6968 " --dependency-skeleton " ,
70- " \( skeleton. moduleName) = \( skeleton. url . path) " ,
69+ " \( skeleton. moduleName) = \( skeleton. skeletonURL . path) " ,
7170 ] )
72- inputFiles. append ( skeleton. url)
71+ // We have to use the Swift file, not the skeleton, as the input file,
72+ // since we can’t make the skeleton file an output file without it being
73+ // treated as a resource by the build system (and thus included in the
74+ // resource bundle). We need to use something as the inputFile to maintain
75+ // correct ordering.
76+ inputFiles. append ( skeleton. bridgeJSSwiftURL)
7377 }
7478
7579 let allSwiftFiles = inputSwiftFiles + pluginGeneratedSwiftFiles
@@ -80,13 +84,14 @@ struct BridgeJSBuildPlugin: BuildToolPlugin {
8084 executable: try context. tool ( named: " BridgeJSTool " ) . url,
8185 arguments: arguments,
8286 inputFiles: inputFiles,
83- outputFiles: [ outputSwiftPath, outputSkeletonPath ]
87+ outputFiles: [ outputSwiftPath]
8488 )
8589 }
8690
8791 private struct DependencySkeleton {
8892 let moduleName : String
89- let url : URL
93+ let skeletonURL : URL
94+ let bridgeJSSwiftURL : URL
9095 }
9196
9297 /// We only read skeletons from dependencies with a `bridge-js.config.json` file.
@@ -118,7 +123,18 @@ struct BridgeJSBuildPlugin: BuildToolPlugin {
118123 packageID: context. package . id,
119124 buildPluginWorkDirectoryURL: context. pluginWorkDirectoryURL
120125 )
121- skeletons. append ( DependencySkeleton ( moduleName: swiftTarget. name, url: skeletonURL) )
126+ let bridgeJSSwiftURL = BridgeJSPluginPaths . bridgeJSSwiftURL (
127+ targetName: swiftTarget. name,
128+ packageID: context. package . id,
129+ buildPluginWorkDirectoryURL: context. pluginWorkDirectoryURL
130+ )
131+ skeletons. append (
132+ DependencySkeleton (
133+ moduleName: swiftTarget. name,
134+ skeletonURL: skeletonURL,
135+ bridgeJSSwiftURL: bridgeJSSwiftURL
136+ )
137+ )
122138 }
123139 return skeletons
124140 }
0 commit comments