Saving a project swift UI WITH Xcode and playing again

Hi Team,

sounds simple but maybe there is a better way than what I’m doing today.

issues : I‘m tired of messing up my project when doing to much modification and can’t make it work again because of to much change in the same time.

temporary fix: save the full xcode folder into a new project

question:: is there a more professional way to keep change a project structur, code, line, func , or whatever but having all the modifications highlighted . something similar to GIT but without git ?

Answered by Matt Cox in 780118022

I think really the only option that gives you what you need is Git or some form of version control, so you could keep track of changes, diff changes, revert changes...etc.

I'd be curious why you're averse to git? Is it because it feels like a lot of ceremony for saving your files? Or that you want to keep everything local?

If you're not collaborating with others, you don't necessarily need a server or host like GitHub to use git - you can use it entirely locally if you want your changes to remain local. This will give you some of the benefits of Git, but remain local to your file system. Bear in mind though that you lose the benefits of storing your code externally, or easily moving your work to another machine if necessary, but pushing to a remote server can be added later if your needs change.


To setup Git locally, you have three options:

When you create the project, choose "Create git repository on my Mac"

This is obviously the easiest way to get started, and then you can use Xcode to manage changes. But... if you have an existing project, it's probably not that helpful. But is a good option when starting a project from scratch.

Add a Git repository for an existing project from Xcode

This is useful if you have an existing project structure and you want to setup a git repository around it.

  1. In Xcode, navigate to Integrate > New Git Repository...
  2. Select the project in the dialog, and click "Create"

Xcode will setup that local repo, and automatically commit your project structure, allowing you to start making changes and diffing immediately.

Initialise an empty git repository from the command line

This is also useful when you have an existing project. It doesn't really do anything differently, but allows you to use terminal if that's your preference.

  1. In the terminal application, navigate to a folder where you want to store your project, making a new folder if necessary.
  2. Run the command git init.
  3. Copy your project files into that directory if necessary.

If you've copied your files into that new directory, git won't automatically commit them. You must do this manually. On the command line enter: git commit --message "The initial commit of my project".

You now have basically the same setup as performed by Xcode, and can use Xcode to manage the changes, diff the changes...etc.

Saving changes

You can either manage your project from Xcode using the Source Control features, or your can continue to commit changes on the command line.

Either approach you take (and I'd suggest Xcode), your repo remains local and fully functional. You can work offline, and perform most of the operations you need to achieve, without the code ever leaving your machine.


I know you wanted to avoid Git, but I think a local git repo is really the only option that achieves what you need.

Accepted Answer

I think really the only option that gives you what you need is Git or some form of version control, so you could keep track of changes, diff changes, revert changes...etc.

I'd be curious why you're averse to git? Is it because it feels like a lot of ceremony for saving your files? Or that you want to keep everything local?

If you're not collaborating with others, you don't necessarily need a server or host like GitHub to use git - you can use it entirely locally if you want your changes to remain local. This will give you some of the benefits of Git, but remain local to your file system. Bear in mind though that you lose the benefits of storing your code externally, or easily moving your work to another machine if necessary, but pushing to a remote server can be added later if your needs change.


To setup Git locally, you have three options:

When you create the project, choose "Create git repository on my Mac"

This is obviously the easiest way to get started, and then you can use Xcode to manage changes. But... if you have an existing project, it's probably not that helpful. But is a good option when starting a project from scratch.

Add a Git repository for an existing project from Xcode

This is useful if you have an existing project structure and you want to setup a git repository around it.

  1. In Xcode, navigate to Integrate > New Git Repository...
  2. Select the project in the dialog, and click "Create"

Xcode will setup that local repo, and automatically commit your project structure, allowing you to start making changes and diffing immediately.

Initialise an empty git repository from the command line

This is also useful when you have an existing project. It doesn't really do anything differently, but allows you to use terminal if that's your preference.

  1. In the terminal application, navigate to a folder where you want to store your project, making a new folder if necessary.
  2. Run the command git init.
  3. Copy your project files into that directory if necessary.

If you've copied your files into that new directory, git won't automatically commit them. You must do this manually. On the command line enter: git commit --message "The initial commit of my project".

You now have basically the same setup as performed by Xcode, and can use Xcode to manage the changes, diff the changes...etc.

Saving changes

You can either manage your project from Xcode using the Source Control features, or your can continue to commit changes on the command line.

Either approach you take (and I'd suggest Xcode), your repo remains local and fully functional. You can work offline, and perform most of the operations you need to achieve, without the code ever leaving your machine.


I know you wanted to avoid Git, but I think a local git repo is really the only option that achieves what you need.

I did not know Git can allow me to still work only computer I thought GIT everything I do is visible by everyone in the world, while I may build some app for my company in future and I want to keep some data private, that's Why I wanted to avoid Git, but as you explain if Git allow my work to remain local then I will try git, I was also a bit reluctant because there is so many push pull ,commit, fetch, stage,cherry pick on so on so I'm very lost... lol

I'd definitely get started with using the tools in Xcode, and review the link to the docs I shared: https://developer.apple.com/documentation/xcode/source-control-management. The for the most part, if you're remaining local, you only have to worry about committing the changes.

When you do want to start working with GitHub, I believe their free account supports private repositories, so you don't have to share your code with the world.

Saving a project swift UI WITH Xcode and playing again
 
 
Q