I've got two projects setup like the following.
.
|____ios
| |____LICENSE
| |____Classes
| |____Package.swift
| |____Example
| | |____LinuxMain.swift
| | |____Tests
| | | |____Tests.swift
| | | |____Info.plist
| | |____CodeGen
| | | |____ViewController.swift
| | | |____Base.lproj
| | | | |____LaunchScreen.xib
| | | | |____Main.storyboard
| | | |____Images.xcassets
| | | | |____AppIcon.appiconset
| | | | | |____Contents.json
| | | |____AppDelegate.swift
| | | |____Info.plist
| | |____Package.swift
| | |____SwiftPackageManagerTests
| | | |____AllTests.swift
| | | |____RequestMocker.swift
| | |____project.pbxproj
| | |____BaseTests_Info.plist
| | |____YLIntegrationClient_Info.plist
One outer project called ios
, and one project inside that project called Example
. Both have Package.swift manifest files.
ios/Package.swift:
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "YLIntegrationClient",
platforms: [
.iOS(.v11),
.watchOS(.v6),
.macOS(.v10_14),
.tvOS(.v9)
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "YLIntegrationClient",
type: .static,
targets: ["YLIntegrationClient"]),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "YLIntegrationClient",
path: "Classes",
exclude: [
]
),
.testTarget(name: "BaseTests", dependencies: ["YLIntegrationClient"], path: "Example/SwiftPackageManagerTests")
]
)
ios/Example/Package.swift:
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "CodeGen",
platforms: [
.iOS(.v11),
],
dependencies: [
.package(url: "../", from: "1.0.0")
],
targets: [
// This is just an arbitrary Swift file in the app, that has
// no dependencies outside of Foundation, the dependencies section
.target(name: "CodeGen", dependencies: ["YLIntegrationClient"], path: "CodeGen"),
.testTarget(name: "CodeGenTests", dependencies: ["CodeGen"], path: "SwiftPackageManagerTests")
]
)
Running swift package generate-xcodeproj
from within ios/Example
seems to be using the Package.swift from ios
after it gets checked out into ios/Example
's .build
directory, because I get the following error:
'YLIntegrationClient' /redacted/ios/Example/.build/checkouts/ios: error: invalid custom path 'Example/SwiftPackageManagerTests' for target 'BaseTests'`
Is this expected behaviour? Is there a workaround?