3

Is there some easy way to rename Swift Package?

I tried some standard ways but there wasn't result in finding quickly solution

Please help me, thanks in advance


Sorry guys i put it badly. more description: I have created SP in the my workspace a some time ago and now there are a lot links (imports of this package) around all project and now I want to rename this package. Special tool not avalible for this and i was looking some ather way to avoing a lot of routine work

NoliNik
  • 125
  • 1
  • 7

4 Answers4

2

Go into your Package.swift file and change any instance of your old name to your new name. Hit save, then your xcode project should update itself.

Dan
  • 191
  • 1
  • 7
2

Unfortunately I only found a manual way to do it.

These are the steps that I did to change OldName to NewName:

  1. To change the package name that shown on Xcode, you can rename the root folder on your Finderenter image description here
  2. If your project are currently open, A popup will appear, you can just close the xcode.
  3. Then you can re-open your package.swift file again.
  4. Last, Rename the folder inside your Sources and Tests folder to the new name. Also adjust your file name too. enter image description
here
Muhammad Fauzi Masykur
  • 1,994
  • 1
  • 15
  • 18
0

Sadly it doesn't look like there's a good way to do this, and when it's come up I've ended up making a new package with the correct name, moving all the code into it, and updating references to the old package to point to the new one.

Bee G
  • 1
  • 1
    https://stackoverflow.com/a/35500038/7860206 here's something you are looking for – Arash Afsharpour May 21 '21 at 16:41
  • Ah, that's renaming a project, not a package- thanks though! TBH I would go with the 'make a new package' approach, since this step-by-step is fragile and Xcode doesn't really give you the tools to debug these under-the-hood files. – Bee G May 24 '21 at 08:02
0

I just renamed my package, which was easier than expected. As previously described, you have to do it manually.

  1. Open your package in Xcode (not in a project)
  2. Open the package.swift file and change the name everywhere
  3. In your Sources folder is another folder with your package's name, rename that, too

If you don't use Git, that's pretty much it. If you do, you can commit your files (which will be a lot, because you renamed a parent folder) and change your repository's name. You probably have to clone it again, so there won't be any errors in the future.

After everything is renamed, you need to update your project(s). If you added your package locally, just search for all the import statements and change the name to your package's new name. If you added it via Github, remove the package dependency, add it again and then search for all the import statements and update them accordingly.

kaevinio
  • 351
  • 1
  • 7