Xcode project renamed and now it is lost - ios

I was trying to rename my Xcode project and I followed the apple developer guide and went to View -> Utilities -> Open file inspector and changed the name. Now the initial project only has the pods and the new project created won't run. Is there a way to restore it? I have been working on this project for months and would be devastated if it was lost.

would be devastated if it was lost
That's what version control is for (git).
But if you don't have a git commit to revert to, don't worry; there is a simple solution. Start a new empty project based on one of the built-in app templates and just migrate everything from your old project into that. No actual files have been deleted by whatever you did, so there should be no difficulty about this.

Related

Xcode 12 how to add an existing project to a workspace

I cannot believe how hard this is. Perhaps because the word 'workspace' is overloaded by Apple and perhaps because the UI keeps changing every version. For a newbie to iOS, Xcode and Apple it's a nightmare.
I have Xcode 12
I have created a project.
I used File/save as
workspace to create a workspace to (eventually) hold multiple
projects.
Gave it a name.
I have another already created project (a
static library) that I would like to add to this workspace.
I cannot for the life of me figure out how to do it. I see things for
previous Xcode versions but those UI options are not present in 12.
In the end I want to have a workspace where I have a demo project that uses the static library project for Bluetooth LE communications. I will be spending 90% of my time developing the BT library so I want to be able to access the source of both projects.
By the way, I am not using Storyboards. Not sure if that makes a difference, but just in case!
Thanks for any help
You can do this by
Close the project to add in Xcode
Drag the existing.xcodeproj file (one you closed) from Finder to Xcode and drop it next to existing sources/projects in the workspace
Xcode settings are often painful for even seasoned developers. And every update seems to break something.
As far as I can tell it just doesn't seem possible.
The only option seems to be to create the workspace in XCode 11 add the projects there then open in XCode 12
If you already have a Workspace (i.e. a .xcworkspace file) ready to go, all you need to do is:
Close your project
Open your Workspace
Go to File > Add Files to "<your_workspace_name>"...
Select your existing project
Xcode will duplicate the references to your files, so you manually have to go to the Project navigator (shortcut: ⌘ + 1), select the duplicated references (they'll be at your Workspace's root) and delete them (select Remove Reference, not Move to Trash)
Enjoy your Workspace!
For good measure, select your scheme (most times it'll become available immediately, but sometimes you'll need to restart Xcode), build, and run your project to verify that everything went well.
Verified in Xcode 13.

Create a new Xcode project in an existing Git repo

I have an iOS app I was writing using React Native until I realized React Native wouldn't fit my needs and I'd need to write the app with Xcode. Because my original project is already in a repo on GitHub, I'd like to use my existing Git repo for the new Xcode project.
I'm new to IDEs and a little scared that if I just move the files over something will get messed up and I won't know how to fix it. Is there a more orthodox way to do this? I've googled this and have come up with lots of advice for adding a new Git repo to an existing Xcode project, but not the other way around.
I appreciate any help I can get!
Simply create a new Xcode project and choose to create it in the same folder on your Mac that is the local copy of the repo.
Deselect the option that says "Create Git repository on my Mac".
This will effectively show up in your local repo as a bunch of files that were added—even an empty Xcode project contains several files.
Xcode will just use the existing repo setup that was already there. So naturally the first step after creating the project would be to commit the Xcode project.
(NB. there is no "rule" that a single repo can not house various projects or "things", although in practice you would often create a fresh repo for the new thing instead of throwing everything together in one)

XCode 8 Git pull does not load into XCode

I have a problem pulling from remote with XCode 8. Problem is when I do Git pull, it pulls all changes, and I see that new classes are added in Finder window but it does NOT load them into XCode project. I need to add them manually in XCode every time to my project. I've tried from terminal, source tree and inside XCode, every time, same thing. With prior XCodes everything is working as expected.
Are you also getting change in xcodeproj file? May be the latest commit to server missed pushing changes to xcodeproj because of which Xcode is not able to figure out new classes etc. Xcodeproj file is the way via which Xcode recognise changes to project structure.

XCode Source Control - Discard Changes Deleted imported files

I am doing a game for iPhone and iPad using SpriteBuilder. SpriteBuilder makes a couple of files in the same folder as the XCode project. I was using Source Control and I just made a commit, then I changed a little bit of the code in the XCode (I changed nothing of the spritebuilder files) and then I changed my mind and I wanted to go back to the commit I made. So I did source control -> discard changes. The XCode successfully replaced the new code with the old code but it erased most of my SpriteBuilder files!!
How do I get my SpriteBuilder files again?
Screenshot of the last commit. You can see that xcode knows when the spritebuilder files are changed so it should keep them no?
Unfortunately the way Xcode calls Git appears to do this. All may not be lost, however. Check the trash for your missing files.
Quit Xcode.
Open the file you wish to bring back your lost changes to using TextEdit.
Go to File -> Revert To -> Browse All Versions...
Scroll through the available versions. Hopefully you will have many available to choose from.
Select a version and hit Restore.
Follow 1-5 for all necessary files.
Launch Xcode. You should now see the M next to these files in Project Navigator indicating they include uncommited changes (the changes you previously discarded).

Xcode 4.2 does not commit files?

I have Xcode 4.2 and I was working ona a project, that was commited previously with - let;s call it - place A. Then I copied it on my disk to another place, made modifications and now I imported via Xcode Organizer whole new project into place B. But when I checked out project from place B I cannot commit any file. I select a file, choose commit, write comment and go. It looks ok, but in fact the status of this file is not changing, so I can without any warning make commits on and on... Is it problem with some project setting or what? I remember that in previous Xcode in project settings you could set svn location, but here I don't see anything like it.
I think you have not copied a folder .svn in the root of your Project - there are the meta-informations of SVN, without this infos SVN can not work. Just find and copy this folder from A to B and the issue will gone!

Resources