skip to Main Content

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

3

Answers


  1. Does your project build successfully even while showing the error? Can you successfully Run it on a simulator or testing device?

    If so, you may be able to fix this error by resetting the package cache

    File > Packages > Reset Package Cache

    And then quitting Xcode (⌘Q) and reopening it.

    Login or Signup to reply.
  2. 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"),
    ],
    
    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search