Essentially what the subject says (I'm new to the Swift ecosystem). You can download the full package here:
https://drive.google.com/file/d/1dqjJACKX1cIVUk-cwxZxOEd8taKAU1i3/view?usp=share_link
My package is fairly simple:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "McuMgr.Bindings.iOS",
platforms: [.iOS(.v9), .macOS(.v10_13)],
products: [
.library(
name: "McuMgr.Bindings.iOS",
targets: ["McuMgr.Bindings.iOS"]
),
],
dependencies: [
.package(
name: "McuMgr",
url: "https://github.com/Laerdal/IOS-nRF-Connect-Device-Manager.git",
.exact("0.13.0")
),
],
targets: [
.target(
name: "McuMgr.Bindings.iOS",
path: "Source",
exclude:["Info.plist"]
)
]
)
But 'swift build' complains that dependency 'ios-nrf-connect-device-manager' is not used by any target and then it fails to compile
% swift build
Fetching https://github.com/Laerdal/IOS-nRF-Connect-Device-Manager.git from cache
Fetching https://github.com/unrelentingtech/SwiftCBOR.git from cache
Fetched https://github.com/unrelentingtech/SwiftCBOR.git (0.48s)
Fetched https://github.com/Laerdal/IOS-nRF-Connect-Device-Manager.git (0.48s)
Computing version for https://github.com/Laerdal/IOS-nRF-Connect-Device-Manager.git
Computed https://github.com/Laerdal/IOS-nRF-Connect-Device-Manager.git at 0.13.0 (0.49s)
Computing version for https://github.com/unrelentingtech/SwiftCBOR.git
Computed https://github.com/unrelentingtech/SwiftCBOR.git at 0.4.4 (0.46s)
Creating working copy for https://github.com/Laerdal/IOS-nRF-Connect-Device-Manager.git
Working copy of https://github.com/Laerdal/IOS-nRF-Connect-Device-Manager.git resolved at 0.13.0
Creating working copy for https://github.com/unrelentingtech/SwiftCBOR.git
Working copy of https://github.com/unrelentingtech/SwiftCBOR.git resolved at 0.4.4
warning: dependency 'ios-nrf-connect-device-manager' is not used by any target
Building for debugging...
/Users/acme/Repos/cmps/mcumgr.dev/bindings/Laerdal.McuMgr.Bindings.iOS/.build/arm64-apple-macosx/debug/McuManager.build/module.modulemap:2:12: error: header '/Users/acme/Repos/cmps/mcumgr.dev/bindings/Laerdal.McuMgr.Bindings.iOS/.build/arm64-apple-macosx/debug/McuManager.build/McuManager-Swift.h' not found
header "/Users/acme/Repos/cmps/mcumgr.dev/bindings/Laerdal.McuMgr.Bindings.iOS/.build/arm64-apple-macosx/debug/McuManager.build/McuManager-Swift.h"
^
/Users/acme/Repos/cmps/mcumgr.dev/bindings/Laerdal.McuMgr.Bindings.iOS/Source/iOSFirmwareUpgrader.swift:1:8: error: could not build Objective-C module 'McuManager'
import McuManager
^
/Users/acme/Repos/cmps/mcumgr.dev/bindings/Laerdal.McuMgr.Bindings.iOS/.build/arm64-apple-macosx/debug/McuManager.build/module.modulemap:2:12: error: header '/Users/acme/Repos/cmps/mcumgr.dev/bindings/Laerdal.McuMgr.Bindings.iOS/.build/arm64-apple-macosx/debug/McuManager.build/McuManager-Swift.h' not found
header "/Users/acme/Repos/cmps/mcumgr.dev/bindings/Laerdal.McuMgr.Bindings.iOS/.build/arm64-apple-macosx/debug/McuManager.build/McuManager-Swift.h"
^
/Users/acme/Repos/cmps/mcumgr.dev/bindings/Laerdal.McuMgr.Bindings.iOS/Source/iOSFirmwareUpgrader.swift:1:8: error: could not build Objective-C module 'McuManager'
import McuManager
^
What gives?
CodePudding user response:
In your code you have import McuManager
but your Package.swift doesn't define a package or dependency named McuManager
.
You need to ensure the package names match, and explicitly add McuManager
as a dependency of your target.
Update your Package.swift
to
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "Laerdal.McuMgr.Bindings.iOS",
platforms: [.iOS(.v9), .macOS(.v10_13)],
products: [
.library(
name: "Laerdal.McuMgr.Bindings.iOS",
targets: ["Laerdal.McuMgr.Bindings.iOS"]
),
],
dependencies: [
.package(
name: "McuManager", // << updated package name
url: "https://github.com/Laerdal/IOS-nRF-Connect-Device-Manager.git",
.exact("0.13.0")
),
],
targets: [
.target(
name: "Laerdal.McuMgr.Bindings.iOS",
dependencies: ["McuManager"], // << added depedency
path: "Source",
exclude:["Info.plist"]
)
]
)