# URL.relative(to:) strange error: CFURLCopyResourcePropertyForKey failed because it was passed a URL which has no scheme

**URL:** <https://forums.swift.org/t/url-relative-to-strange-error-cfurlcopyresourcepropertyforkey-failed-because-it-was-passed-a-url-which-has-no-scheme/63880>\
**Category:** Using Swift\
**Tags:** url\
**Created:** [March 22, 2023, 2:16pm UTC](https://forums.swift.org/t/url-relative-to-strange-error-cfurlcopyresourcepropertyforkey-failed-because-it-was-passed-a-url-which-has-no-scheme/63880 "2023-03-22T14:16:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wizard](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@Wizard](https://forums.swift.org/u/Wizard)\
**Post date:** [March 22, 2023, 2:16pm UTC](https://forums.swift.org/t/url-relative-to-strange-error-cfurlcopyresourcepropertyforkey-failed-because-it-was-passed-a-url-which-has-no-scheme/63880/1 "2023-03-22T14:16:25Z")

</div>

Hi,  
I am using `URL.relative(to:)` with two URLs, which both have 'file' scheme. Nevertheless I still get the error (console output) 'CFURLCopyResourcePropertyForKey failed because it was passed a URL which has no scheme'. This happens when using iOS simulator or on a real device.

Interestingly enough, I still get a result from `URL.relative(to:)`, which seems to be correct as far as I can tell.

Anybody knows what is going on here?

information:  
Xcode 14.2 running on macOS Ventura 13.2.1  
Simulator running iOS 16.2  
IPad running iOS 16.3.1

---

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [March 22, 2023, 2:45pm UTC](https://forums.swift.org/t/url-relative-to-strange-error-cfurlcopyresourcepropertyforkey-failed-because-it-was-passed-a-url-which-has-no-scheme/63880/2 "2023-03-22T14:45:52Z")

</div>

If you make a minimal reproducible example one of the two things will then happen:

- by the end of doing so you'll solve the issue yourself.
- having that minimal example it is more likely that someone on this forum will be able to help you.

---

<div class="post-metadata">

**Author:** ![Wizard](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@Wizard](https://forums.swift.org/u/Wizard)\
**Post date:** [March 22, 2023, 5:24pm UTC](https://forums.swift.org/t/url-relative-to-strange-error-cfurlcopyresourcepropertyforkey-failed-because-it-was-passed-a-url-which-has-no-scheme/63880/3 "2023-03-22T17:24:22Z")

</div>

Sorry for any sort of confusion. For some reason I did not realise that `URL.relative(to:)` was my own implementation and not part of Foundation. And it is clear to me why the error occurred there. As I do not have permission to remove the topic, maybe some administrator can do that. Thanks!

---

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [March 22, 2023, 5:27pm UTC](https://forums.swift.org/t/url-relative-to-strange-error-cfurlcopyresourcepropertyforkey-failed-because-it-was-passed-a-url-which-has-no-scheme/63880/4 "2023-03-22T17:27:38Z")

</div>

Heh, as promised, _"• by the end of doing so you'll solve the issue yourself."_
