1

I've been trying to use Symbolic Links in my swift app with no luck. Is there anything I might be missing or is this even possible to begin with?

Here is my sample code and I have been using FileKit plugin to create my symlink. I also tried it without a plugin but no luck.

I tried this first:

import FileKit

do {
   try Path(Bundle.main.bundlePath + "/wwww/assets").symlinkFile(to: "/assets")
   debugPrint("Success")
} catch {
   debugPrint("Failed")
}

I always get the Failed message.

I also made sure that the bundle paths are valid with this test:

debugPrint(Path(Bundle.main.bundlePath + "/wwww/assets").exists) //true

Can you guys give me any pointers?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Luis C
  • 49
  • 7
  • 4
    The application bundle is *read-only.* You cannot create files, symlinks, or anything else in the application bundle at runtime. – Martin R Jun 08 '18 at 20:16
  • 1
    Printing `error.localizedDescription` in the failure case should also give some clue. – Martin R Jun 08 '18 at 20:23
  • Looks like a duplicate of https://stackoverflow.com/questions/13399864/adding-a-symbolic-link-in-the-application-bundle to me. – Martin R Jun 08 '18 at 20:31
  • 1
    Thanks for the quick reply... I did see the other question being posted while looking around but it wasn't clear if you can actually create a symlink in ios/swift/xcode. It makes sense now that you mention it that it wouldn't let you create one since it makes the device vunerable. Thanks! – Luis C Jun 08 '18 at 20:41
  • 1
    The key part here is *in the app bundle*. You should be able to create them in other areas that you have write access to – Michael Hulet Jun 08 '18 at 20:45

0 Answers0