You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a plugin that generates a swift file on build via a plugin. In another target in the same package I would like to use that file as input. However I notice that the sourcefiles on the target do not include generated source files in the pluginWorkingDirectory?
Inside my plugin I have the following:
import Foundation
import PackagePlugin
enumError:Swift.Error{case missingAssetSwiftFile
case missingUIComponents
}@mainstructReuseGenerated:BuildToolPlugin{func createBuildCommands(context:PluginContext, target:Target)asyncthrows->[Command]{print("📦 reuse generated started")
guard let uiComponents =try context.package.targets(named:["UIComponents"]).first as?SwiftSourceModuleTargetelse{throwError.missingUIComponents
}print("Did find files in UIComponents")print(uiComponents.sourceFiles.map{ $0.path.string}.joined(separator:"\n"))print("---")
guard let swiftAssetFile =(uiComponents.sourceFiles.first{ $0.path.lastComponent =="Assets.swift"})else{throwError.missingAssetSwiftFile
}letoutput= context.pluginWorkDirectory.appending("Assets.swift")return[.prebuildCommand(
displayName:"📦 Generate new content based on generated source code of other target",
executable:.init("/usr/bin/touch"),
arguments:[output.string],
outputFilesDirectory: context.pluginWorkDirectory)]}}
Expected behavior
I would expect the file generated before to be there, or the docs telling me that sourceFiles only include non generated files
Swift & OS version (output of swift --version && uname -a)
swift-driver version: 1.75.1 Apple Swift version 5.8 (swiftlang-5.8.0.119.11 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0
Darwin stijns-mac.lan 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 arm64
The text was updated successfully, but these errors were encountered:
Description
I have a plugin that generates a swift file on build via a plugin. In another target in the same package I would like to use that file as input. However I notice that the sourcefiles on the target do not include generated source files in the pluginWorkingDirectory?
Inside my plugin I have the following:
Expected behavior
I would expect the file generated before to be there, or the docs telling me that sourceFiles only include non generated files
Actual behavior
It is not there
Steps to reproduce
I have created a sample project reporduces the issue when building lib
FoodoozMen/swift-generated-asset-plugin: Shows how to generate an asset catalog that can load colors into a SwiftUI view from the plugin working directorySwift Package Manager version/commit hash
releases with xcode 14.3 beta 2
Swift & OS version (output of
swift --version && uname -a)swift-driver version: 1.75.1 Apple Swift version 5.8 (swiftlang-5.8.0.119.11 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0
Darwin stijns-mac.lan 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 arm64
The text was updated successfully, but these errors were encountered: