Open amzada opened 1 month ago
Hi @amzada, it seems that you are using mapbox-navigation-ios
v2 that still depends on mapbox-direction-swift
that is not compatible with mapbox-maps-ios
v11. Could you try update your dependencies to use mapbox-navigation-ios
v3.0.2 or latest?
hello @maios thank you for your answer. I was indeed using latest version of mapbox-navigation-ios
but realised from your comment that I no longer need mapbox-direction-swift
.
The error I am now getting is:
multiple targets named **MapboxCoreMaps** in: **mapbox-core-maps-ios,** **mapbox-navigation-ios**; consider using the moduleAliases parameter in manifest to provide unique names
How can I resolve this?
Could you provide your package manifest? IIUC mapbox-navigation-ios already have dependencies on mapbox-maps-ios
@maios yep that's right. I can provide the package manifests that come with the libraries if that's what you mean?
MapboxNavigation
// swift-tools-version: 5.8
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let version = "3.0.2"
let binaries = [
"MapboxCoreMaps": "a164dc57d0c3eaffe9a6fd493f5d2bef47cbf3fd9a0365679771e78df0421f37",
"MapboxDirections": "a2e19aa52a0aa78417f379fb60aef1772ae00da777e92c761febc6a6ea744554",
"MapboxMaps": "ffd302cd2d6fbadd37bff6d391a2c48fcb7aa2620a219103ce7a2a5e3c7b9fb0",
"Turf": "4eabc83d358f6962a80bec3a988723c5e7eda20d85333d019966c4ec12b5c066",
"MapboxNavigationCore": "ecfab910af2df3b430c3094501b904c54e12fb773a63f2eabaa8885fb75dec43",
"_MapboxNavigationUXPrivate": "9c3a30a473e28361c34d6dd8ab8c8c5f501094b2a1699a31fe898448cdebba25",
"MapboxNavigationUIKit": "203e840e647bb10799a6348ade7730cc2a5d59f058fc74ef8b69437e737a86a3",
]
let package = Package(
name: "MapboxNavigation",
platforms: [.iOS(.v14)],
products: [
.library(
name: "MapboxNavigationCore",
targets: ["MapboxNavigationCoreWrapper"]
),
.library(
name: "MapboxNavigationUIKit",
targets: ["MapboxNavigationUIKitWrapper"]
),
],
dependencies: [
.package(url: "https://github.com/mapbox/mapbox-common-ios.git", exact: "24.3.1"),
.package(url: "https://github.com/mapbox/mapbox-navigation-native-ios.git", exact: "305.0.0"),
],
targets: [
.target(
name: "MapboxNavigationCoreWrapper",
dependencies: binaries.keys.map { .byName(name: $0) } + [
.product(name: "MapboxCommon", package: "mapbox-common-ios"),
.product(name: "MapboxNavigationNative", package: "mapbox-navigation-native-ios"),
]
),
.target(
name: "MapboxNavigationUIKitWrapper",
dependencies: [
"MapboxNavigationCoreWrapper"
]
),
] + binaryTargets()
)
func binaryTargets() -> [Target] {
return binaries.map { binaryName, checksum in
Target.binaryTarget(
name: binaryName,
url: "https://api.mapbox.com/downloads/v2/navsdk-v3-ios" +
"/releases/ios/packages/\(version)/\(binaryName).xcframework.zip",
checksum: checksum
)
}
}
Mapbox Maps
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
import Foundation
let coreMaps = MapsDependency.coreMaps(version: "11.3.0")
let common = MapsDependency.common(version: "24.3.1")
let mapboxMapsPath: String? = nil
let package = Package(
name: "MapboxMaps",
defaultLocalization: "en",
// Maps SDK doesn't support macOS but declared the minimum macOS requirement with downstream deps to enable `swift run` cli tools
platforms: [.iOS(.v12), .macOS(.v10_15), .custom("visionos", versionString: "1.0")],
products: [
.library(
name: "MapboxMaps",
targets: ["MapboxMaps"]),
],
dependencies: [
.package(url: "https://github.com/mapbox/turf-swift.git", exact: "2.8.0"),
] + coreMaps.packageDependencies + common.packageDependencies,
targets: [
.target(
name: "MapboxMaps",
dependencies: [
coreMaps.mapsTargetDependencies,
common.mapsTargetDependencies,
.product(name: "Turf", package: "turf-swift")
],
path: mapboxMapsPath,
exclude: [
"Info.plist",
],
resources: [
.copy("MapboxMaps.json"),
.copy("PrivacyInfo.xcprivacy"),
]
),
.testTarget(
name: "MapboxMapsTests",
dependencies: [
"MapboxMaps",
],
resources: [
.copy("MigrationGuide/Fixtures/polygon.geojson"),
.copy("Helpers/MapboxAccessToken"),
.copy("Resources/empty-style-chicago.json"),
.copy("Snapshot/testDoesNotShowAttribution().png"),
.copy("Snapshot/testDoesNotShowLogo().png"),
.copy("Snapshot/testDoesNotShowLogoAndAttribution().png"),
.copy("Snapshot/testShowsLogoAndAttribution().png"),
.copy("Snapshot/testSnapshotAttribution-100.png"),
.copy("Snapshot/testSnapshotAttribution-150.png"),
.copy("Snapshot/testSnapshotAttribution-200.png"),
.copy("Snapshot/testSnapshotAttribution-250.png"),
.copy("Snapshot/testSnapshotAttribution-300.png"),
.copy("Snapshot/testSnapshotAttribution-50.png"),
.copy("Snapshot/testSnapshotLogoVisibility.png"),
.copy("Snapshot/testSnapshotOverlay.png"),
.process("Resources/MapInitOptionsTests.xib"),
]
)
] + coreMaps.packageTargets + common.packageTargets
)
struct MapsDependency {
init(name: String, version: String, checksum: String? = nil, isSnapshot: Bool?, repositoryName: String, registryProjectName: String, registryFileName: String) {
self.name = name
self.version = version
self.checksum = checksum
self.isSnapshot = isSnapshot ?? version.contains("SNAPSHOT")
self.repositoryName = repositoryName
self.registryProjectName = registryProjectName
self.registryFileName = registryFileName
}
let name: String
let version: String
let checksum: String?
let isSnapshot: Bool
let repositoryName: String
let registryProjectName: String
let registryFileName: String
static func coreMaps(version: String, checksum: String? = nil, isSnapshot: Bool? = nil) -> MapsDependency {
return MapsDependency(name: "MapboxCoreMaps", version: version, checksum: checksum, isSnapshot: isSnapshot,
repositoryName: "mapbox-core-maps-ios",
registryProjectName: "mobile-maps-core",
registryFileName: "MapboxCoreMaps.xcframework-dynamic.zip")
}
static func common(version: String, checksum: String? = nil, isSnapshot: Bool? = nil) -> MapsDependency {
return MapsDependency(name: "MapboxCommon", version: version, checksum: checksum, isSnapshot: isSnapshot,
repositoryName: "mapbox-common-ios",
registryProjectName: "mapbox-common",
registryFileName: "MapboxCommon.zip")
}
var packageDependencies: [Package.Dependency] {
guard !isSnapshot else { return [] }
return [
.package(url: repositoryURL, exact: Version(stringLiteral: version))
]
}
var packageTargets: [Target] {
guard isSnapshot else { return [] }
return [
.binaryTarget(name: name, url: registryURL, checksum: checksum ?? "")
]
}
var mapsTargetDependencies: Target.Dependency {
if isSnapshot {
return .byName(name: name)
} else {
return .product(name: name, package: repositoryName)
}
}
var repositoryURL: String { return "https://github.com/mapbox/\(repositoryName).git" }
var registryReleaseFolder: String { isSnapshot ? "snapshots" : "releases" }
var registryURL: String {
return "https://api.mapbox.com/downloads/v2/\(registryProjectName)/\(registryReleaseFolder)/ios/packages/\(version)/\(registryFileName)"
}
}
hi @maios any update on this?
NavSDK already bundles MapboxMaps SDK, their v3 should be compatible with our v11, so I think you can remove your dependency on MapboxMaps SDK and use only NavSDK.
are you certain that I'm able to do this @maios ? I believe I tried this but couldn't get MapboxMaps SDK from NavSDK
Yes I am certain. What is the error you get when you tried to access MapboxMaps from NavSDK?
ahh thanks for the image @maios - I think I was trying it in a different way ie by looking for separate frameworks and not directly importing MapboxMaps. Will try this!
@amzada did you resolve this issue?
@maios Hi, I encountered the same problem. Can you please share your Package.swift
file from the TestSPM
package? Especially the target dependencies part.
I tried to reproduce this, but without success. Mine look like following (target dependencies part commented with Error message provided)
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "TestSPM",
products: [
.library(
name: "TestSPM",
targets: ["TestSPM"]
)
],
dependencies: [
.package(url: "https://github.com/mapbox/mapbox-navigation-ios.git", .upToNextMajor(from: "3.1.0"))
],
targets: [
.target(
name: "TestSPM",
dependencies: [
// ERROR: product 'MapboxMaps' required by package 'testspm' target 'TestSPM' not found in package 'mapbox-navigation-ios'. Did you mean 'MapboxMaps'?
// .product(name: "MapboxMaps", package: "mapbox-navigation-ios"),
// ERROR: product 'MapboxNavigation' required by package 'testspm' target 'TestSPM' not found in package 'mapbox-navigation-ios'. Did you mean 'MapboxNavigationCore'?
// .product(name: "MapboxNavigation", package: "mapbox-navigation-ios"),
]),
.testTarget(
name: "TestSPMTests",
dependencies: [
"TestSPM"
]
),
]
)
With above package the compiler is indeed suggesting to import MapboxMaps, but then, after build it fails with No such module 'MapboxMaps'
error
Mapbox Maps iOS SDK version
11.3.0
Steps to reproduce
Install latest versions of mapbox-search-ios, mapbox-maps-ios, mapbox-navigation-ios & mapbox-directions-switft
Expected behaviour
Package resolution succeeds
Actual behaviour
Package resolution fails
Failed to resolve dependencies Dependencies could not be resolved because root depends on 'mapbox-directions-swift' 2.12.0 and root depends on 'mapbox-maps-ios' 11.3.0. 'mapbox-maps-ios' is incompatible with 'mapbox-directions-swift' because 'mapbox-maps-ios' 11.3.0 depends on 'turf-swift' 2.8.0 and 'mapbox-directions-swift' 2.12.0 depends on 'turf-swift' 2.7.0..<2.8.0.
Is this a one-time issue or a repeatable issue?
repeatable