FREE TRIAL: Accelerate your app development career with Hacking with Swift+! >>

iCloud Drive path returning nil

Forums > SwiftUI

I am getting a nil returned for the path to my iCloud Drive container. I cannot seem to figure out why. I have setup all the capabilities as well:

Under my target:

  1. iCloud Documents is checked
  2. The correct container is checked
  3. I have modified the plist

I am using the following line to get the URL for my iCloud Documents

path = FileManager.default.url(forUbiquityContainerIdentifier: nil)?.appendingPathComponent("Documents")

This is returning nil, can someone help me with this.

Thanks, Mark


I'm having the same issue when trying to view my UI in the canvas, the app crashes stating my "path" (your variable) is nil. When I run it in the simulator, everything is fine.


Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for iOS devs who want to become complete senior developers — from October 18th to 24th. Learn how to apply iOS app architecture patterns through a series of lectures and practical coding sessions.

Learn more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.