# Xcode cannot load a package manifest unless its URLs are percent encoded

**URL:** <https://forums.swift.org/t/xcode-cannot-load-a-package-manifest-unless-its-urls-are-percent-encoded/35185>\
**Category:** Package Manager\
**Tags:** xcode, packagemanager\
**Created:** [April 8, 2020, 3:54am UTC](https://forums.swift.org/t/xcode-cannot-load-a-package-manifest-unless-its-urls-are-percent-encoded/35185 "2020-04-08T03:54:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDGGiesbrecht](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sdggiesbrecht/32/4768_2.png) [@SDGGiesbrecht](https://forums.swift.org/u/SDGGiesbrecht)\
**Post date:** [April 8, 2020, 3:54am UTC](https://forums.swift.org/t/xcode-cannot-load-a-package-manifest-unless-its-urls-are-percent-encoded/35185/1 "2020-04-08T03:54:07Z")

</div>

I already filed FB7655953, but I thought I’d mention it here where it’s more likely to be seen by the relevant developers. This way it’s also visible to anyone else looking for a workaround.

As of 11.4, Xcode is once again incapable of loading a manifest containing something like this:

```swift
.package(url: "file:///Wherever/Παράδειγμα", from: "1.0.0")

```

SwiftPM handles that just fine on its own, but for Xcode you have to manually percent‐encode it:

```swift
import Foundation
let path = ProcessInfo.processInfo.environment["PATH"] ?? ""
let firstColon = path.range(of: ":")?.lowerBound ?? path.endIndex
let firstEntry = path[..<firstColon]
if firstEntry.hasSuffix("/Contents/Developer/usr/bin") {
  // Xcode is loading the manifest, not SwiftPM
  package.dependencies = package.dependencies.map { dependency in
    var modifiedURL = dependency.url.components(separatedBy: "/")
    var last = modifiedURL.removeLast()
    last = last.addingPercentEncoding(
      withAllowedCharacters: CharacterSet.urlPathAllowed
    )!
    modifiedURL.append(last)
    return .package(
      name: dependency.name,
      url: modifiedURL.joined(separator: "/"),
      dependency.requirement
    )
  }
}

```

---

<div class="post-metadata">

**Author:** ![SDGGiesbrecht](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sdggiesbrecht/32/4768_2.png) [@SDGGiesbrecht](https://forums.swift.org/u/SDGGiesbrecht)\
**Post date:** [June 10, 2021, 2:57am UTC](https://forums.swift.org/t/xcode-cannot-load-a-package-manifest-unless-its-urls-are-percent-encoded/35185/2 "2021-06-10T02:57:12Z")

</div>

Xcode 12.5 seems fatally broken.

Now, with the `%`, it objects:

> The source control operation failed because the specified URL cannot be used. Make sure the URL is valid and try again.

But even without, it still objects:

> The URL “blah.blah/blah” is invalid

A new workaround would be much appreciated if anyone can figure one out.

---

<div class="post-metadata">

**Author:** ![Karl](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@Karl](https://forums.swift.org/u/Karl)\
**Post date:** [June 17, 2021, 9:02am UTC](https://forums.swift.org/t/xcode-cannot-load-a-package-manifest-unless-its-urls-are-percent-encoded/35185/3 "2021-06-17T09:02:18Z")

</div>

Out of curiosity, is this actually for a file URL? Does it perhaps work if you use a path (without %-encoding) instead?

---

<div class="post-metadata">

**Author:** ![SDGGiesbrecht](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sdggiesbrecht/32/4768_2.png) [@SDGGiesbrecht](https://forums.swift.org/u/SDGGiesbrecht)\
**Post date:** [June 17, 2021, 8:14pm UTC](https://forums.swift.org/t/xcode-cannot-load-a-package-manifest-unless-its-urls-are-percent-encoded/35185/4 "2021-06-17T20:14:17Z")

</div>

I tried a local URL expressed both as a path `/Users/...` and as a URL `file:///Users/...`. It makes no difference. Both work with SwiftPM; neither works with Xcode.

Using the `path` argument instead does work, but it rules out versioning and cannot point at a bare repository.
