-
Notifications
You must be signed in to change notification settings - Fork 1.4k
PIF: Ensure targets are created #9212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// swift-tools-version: 6.2 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "Simple", | ||
products: [ | ||
// Products define the executables and libraries a package produces, making them visible to other packages. | ||
.library( | ||
name: "Simple", | ||
targets: ["Simple"] | ||
), | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package, defining a module or a test suite. | ||
// Targets can depend on other targets in this package and products from dependencies. | ||
.target( | ||
name: "Simple" | ||
), | ||
.testTarget( | ||
name: "SimpleTests", | ||
dependencies: ["Simple"] | ||
), | ||
] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// The Swift Programming Language | ||
// https://docs.swift.org/swift-book | ||
|
||
public func greet(name: String = "world") -> String { | ||
return "Hello, \(name)!" | ||
} | ||
|
||
public func libA() -> String { | ||
return "libA" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Testing | ||
import XCTest | ||
@testable import Simple | ||
|
||
@Test( | ||
arguments: [ | ||
"Bob", | ||
"Alice", | ||
"", | ||
] | ||
) | ||
func testGreet( | ||
name: String | ||
) async throws { | ||
let actual = greet(name: name) | ||
|
||
#expect(actual == "Hello, \(name)!") | ||
} | ||
|
||
final class SimpleTests: XCTestCase { | ||
func testExample() throws { | ||
XCTAssertEqual(libA(), "libA", "Actual is not as expected") | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
import lib1 | ||
|
||
foo() | ||
print("1") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
import lib1 | ||
|
||
foo() | ||
print("2") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
public func foo() { | ||
print("In lib") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,7 +199,6 @@ extension PackagePIFProjectBuilder { | |
/// we also construct a testable version of said executable. | ||
mutating func makeTestableExecutableSourceModule(_ executableModule: PackageGraph.ResolvedModule) throws { | ||
precondition(executableModule.type == .executable) | ||
guard self.package.manifest.toolsVersion >= .v5_5 else { return } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: For reference, this is the comment on the original PIF builder (which I preserved in the // If we're building an executable and the tools version is new enough,
// we also construct a testable version of the executable.
if manifest.toolsVersion >= .v5_5 { ... } So maybe Swift 5.5 somehow made this possible? Have you tested this in toolchains older than 5.5? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The SwiftBuild integration in SwiftPM is occurring on branch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Packages below tools version 5.5 shouldn't generate this target representing the testable version of an executable since that feature isn't available. The tools version of a package is independent of the version of the tools themselves. I think the underlying issue here is likely that |
||
|
||
let inputResourceBundleName: String? = if mainModuleTargetNamesWithResources.contains(executableModule.name) { | ||
resourceBundleName(forModuleName: executableModule.name) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: I would favor
TSCAbsolutePath(...)
instead of the harder to read.init(...)
.