我正在开发一个 Swift 应用程序并在其中使用我自己编写的包。一切正常,直到我尝试通过 Fastlane 运行测试。它会抛出一个错误,指出,
Could not resolve package dependencies.
但是,当我从 Xcode 运行测试时,一切都很顺利。
如果我从 xCode 运行测试,效果很好。
我的包文件:
import PackageDescription
let package = Package(
name: "Package_Name",
platforms: [.iOS(.v17)],
products: [
.library(name: "Package_Name", targets: ["Package_Name"]),
],
dependencies: [
.package(name: "ConfigManager", path: "/Packages/ConfigManager"),
.package(name: "NetworkManager", path: "/Packages/NetworkManager"),
.package(name: "Notifications", path: "/Packages/Notifications")
],
targets: [
.target(
name: "Package_Name",
dependencies: ["ConfigManager",
"NetworkManager",
"Notifications"],
resources: [
.process("Resources")
]),
.testTarget(
name: "Package_NameTests",
dependencies: ["Package_Name",
"ConfigManager",
"NetworkManager",
"Notifications"],
resources: [
.process("Resources")
]),
]
)
来自 fastlane 的错误消息:
▸ xcodebuild: error: Could not resolve package dependencies:
▸ the package at '/Packages/ConfigManager' cannot be accessed (Error Domain=NSCocoaErrorDomain Code=260 "The folder “ConfigManager” doesn’t exist." UserInfo={NSFilePath=/Packages/ConfigManager, NSUserStringVariant=(
▸ Folder
▸ ), NSUnderlyingError=0x6000007aba20 {Error Domain=NSOSStatusErrorDomain Code=-43 "fnfErr: File not found"}})
Fastfile 中的车道
lane :testPackage do
puts 'Test ' + "Package_Name"
scan(
package_path: './Packages/' + "Package_Name",
scheme: "Package_NameTests",
devices: ["iPhone 15"],
output_style: 'standard',
output_directory: './fastlane/report/' + "Package_Name" + '/',
code_coverage: true,
result_bundle: true,
fail_build: false,
clean: true,
configuration: "Debug"
)
end
提前谢谢您,
Package_Name
的依赖项被列为绝对路径。
dependencies: [
.package(name: "ConfigManager", path: "/Packages/ConfigManager"),
.package(name: "NetworkManager", path: "/Packages/NetworkManager"),
.package(name: "Notifications", path: "/Packages/Notifications")
],
这对我来说似乎很可疑。也许您的意思是依赖项位置位于当前
Package.swift
文件的子文件夹中?那就./Packages/...