Package manifest at '/Package.swift' cannot be accessed (/Package.swift doesn't exist in file system)
Asked Answered
H

7

19

Good Day,

I was working on a project and did a build onto my device for some testing and close down the computer for a few days. When I went to open the project back up today Im being met with this error.

"the package manifest at '/Package.swift' cannot be accessed (/Package.swift doesn't exist in file system)"

Package Error

I tried all the recommended solutions I saw here on Stack with no resolution. The strange thing is that I didn't touch anything and did a build before closing it down so I'm downright stumped into whats going on here.

To help test, I made a totally new project and started to import some packages that I had on my other project. That project works just fine and the files seem to be the same.

Any help on solving this would be appreciated

Heathenish answered 16/2, 2023 at 14:35 Comment(1)
Getting the same issue.Reamonn
W
4

For me, this was happening while attempting to checkout a SPM dependency at a version that didn't yet have a Package.swift (i.e. didn't support SPM yet), e.g.:

.package(name: "MyDependency", url: "https://github.com/user/MyDependency.git", .upToNextMajor(from: "1.0.0")),

While only e.g. v2.0.0 had a Package.swift declared.

Solution was to set the version to a version that had a Package.swift, e.g.:

.package(name: "MyDependency", url: "https://github.com/user/MyDependency.git", .upToNextMajor(from: "2.0.0")),
Wasteland answered 15/5, 2023 at 1:28 Comment(0)
O
1

Check that the SwiftPackage you want to import is setup correctly. The Package.swift file has to be in the base level folder. By default swift package projects are created wrong. So you have to create a new folder in the repo. Move all files into it, except Package.swift. You have to move it (Package.swift) in the base level git folder. The structure should look like this: enter image description here

After that open the Package.swift file with text editor and add custom paths to the targets like this:

// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "AnyIOSCore",
    platforms: [ .iOS(.v14) ],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "AnyIOSCore",
            targets: ["AnyIOSCore"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
    ],
    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 this package depends on.
        .target(
            name: "AnyIOSCore",
            dependencies: [],
            path: "AnyIOSCore/Sources/AnyIOSCore"),
        .testTarget(
            name: "AnyIOSCoreTests",
            dependencies: ["AnyIOSCore"],
            path: "AnyIOSCore/Tests/AnyIOSCoreTests"),
    ]
)

Now just double click the Package.swift file and it should open and build without problems.

I had the same issue when i created new package and imported it into another one.

Good luck.

Orizaba answered 30/3, 2023 at 13:28 Comment(0)
S
1

gone through all the answers but seems no one answered clearly and simply. i resolved it this way. version number- Next major was not satisfied.xcode->your_project->package dependencies just edit version rules by clicking as shown in the picture. find version number specified by the repo itself.

Salvatoresalvay answered 20/7, 2023 at 15:38 Comment(0)
C
1

Other answers are talking about projects that manually manage Package.swift, which isn't the case with plain iOS projects.

tl;dr - Check your spm dependencies for any that are set to 1.0.0 and then check GitHub to make sure you have the correct version.

I think there is an Xcode bug where the first time you add a new package it doesn't set the version correctly and you end up with a default of 1.0.0, but the first resolve works for some reason.

In my case I added Realm, it defaulted to 1.0.0 (should have been 10.0.0) but resolved fine. Then went to run the project on another machine and got the error in OP.

enter image description here

Consecution answered 3/12, 2023 at 15:31 Comment(0)
O
0

For me the issue was an invalid version for the from argument. In my case I had

dependencies: [
    // Dependencies declare other packages that this package depends on.
    .package(url: "https://github.com/Tyler-Keith-Thompson/CucumberSwift", from: "1.0.0"),
],

But 1.0.0 was not a valid git tag. So I checked https://github.com/Tyler-Keith-Thompson/CucumberSwift/tags and saw that 4.2.1 was the latest tag. Once I change the .package to use 4.2.1, the error went away.

dependencies: [
    // Dependencies declare other packages that this package depends on.
    .package(url: "https://github.com/Tyler-Keith-Thompson/CucumberSwift", from: "4.2.1"),
],
Olathe answered 17/3, 2023 at 15:49 Comment(0)
R
0

I experienced this after migrating remote SPM to local SPM, the remote SPM previously was referred from multiple different packages. Now they all had to be linked with binary newly after migration.

Also make sure Test targets are also linked with this new local dependencies binary

Roderic answered 20/10, 2023 at 12:56 Comment(0)
S
0

For me this was occurred with 'firebase-ios-sdk' and 'firebaseui-ios' library. My solution is use 'Extract Version' dependence rule.

  • enter image description here
Septuple answered 13/8 at 8:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.