xcode source control with fork of github project

I found a project on Github that I'd like to take a stab at converting for macOS. (This is still Xcode 8, btw).

The original project is a C# project that appears to have been created with Form Designer, although I don't think the precise details are at issue (I could be wrong!).


I forked the project on github into my own account. I updated the .gitignore file to exclude any of the Xcode files that don't need versioning (using the gitignore.io for xcode).


However, there appears to be a catch-22 with creating/using an Xcode project for versioning with this fork.


If I use Xcode to create a project from the remote repository, it clones the remote locally but doesn't create an Xcode project (presumably, because the existing project is CS, not Swift/Obj-C). In fact, all it does is clone the remote, check it out, and then sit there, Xcode open, with no files open.


If I use Xcode to create a project without SCM, if I try to check out the remote (after having destroyed the directory from the earlier clone/checkout) it then clobbers the .xcproject file and all of its associated files and gives an error:


"The workspace file that was at “/Users/[redacted path & whatnot].xcodeproj/project.xcworkspace” has disappeared."


If I use Xcode to create a project with SCM, and then try to add the remote and pull from it, nothing happens. I can commit locally, but pushing to the remote gives an error message about there not being a repository for it.


Frankly, I think I understand why all of these happen. In the first case, it's not an Xcode project and has no Swift or Objective-C files, and therefore is not an Xcode-recognized code project. In the second case, pulling the remote should clobber the local, since none of the remote files exist locally and none of the local files exist remotely, and I am explicitly telling it to pull the remote repository. In the third case, even though I've added the remote as a repository (and I have the credentials to do so), there is no local copy of the remote (the local copy is of the present project, and contains none of the remote files) and therefore the local and remote don't really know about each other.


So how do I make this work? I believe that what I will probably have to do is to checkout the remote to my local machine (either in Xcode or through CLI, I think either should work the same way), then create an Xcode project in the same directory without SCM, add the files from the local repository into the project, save the project and quit Xcode. Then, I would probably have to run git from the terminal, and have it add the new Xcode files (minus, of course, the .gitignore files), then commit & push.


When that happens, will Xcode then recognize that this project is under SCM, via git? Did I miss some (to me at least) non-obvious step that would make this work from within Xcode?

Accepted Reply

>> what I will probably have to do is to checkout the remote to my local machine (either in Xcode or through CLI, I think either should work the same way), then create an Xcode project in the same directory without SCM, add the files from the local repository into the project, save the project and quit Xcode.


I think the first part of this is one correct approach. Clone the repository locally, and create an Xcode project in the same directory (without SCM), and close the project. Then, I would use the git command line to add the new files (modulo stuff you want to ignore) to the existing local repository. That mostly means the Xcode project package itself, along with any source files it created for free. Then, re-open the project, and you should be able to start adding files (now in the local repository to the project).


There's another approach which should also work. Don't clone the github remote repository, but create a new Xcode project with SCM locally. Then, set the github repository as the remote for the local repository, and pull it (rather than trying to clone it over the top of your project as you did). Then when you push it back again later, the remote will acquire the Xcode project and other new files.


This second approach is what I used to do before Xcode dealt with remotes as directly as now. I'd create an empty repository on github, create a local SCM project in Xcode, set the remote and pull/push. That's the same as what you want, except that the inital remote already has some files in it.

Replies

>> what I will probably have to do is to checkout the remote to my local machine (either in Xcode or through CLI, I think either should work the same way), then create an Xcode project in the same directory without SCM, add the files from the local repository into the project, save the project and quit Xcode.


I think the first part of this is one correct approach. Clone the repository locally, and create an Xcode project in the same directory (without SCM), and close the project. Then, I would use the git command line to add the new files (modulo stuff you want to ignore) to the existing local repository. That mostly means the Xcode project package itself, along with any source files it created for free. Then, re-open the project, and you should be able to start adding files (now in the local repository to the project).


There's another approach which should also work. Don't clone the github remote repository, but create a new Xcode project with SCM locally. Then, set the github repository as the remote for the local repository, and pull it (rather than trying to clone it over the top of your project as you did). Then when you push it back again later, the remote will acquire the Xcode project and other new files.


This second approach is what I used to do before Xcode dealt with remotes as directly as now. I'd create an empty repository on github, create a local SCM project in Xcode, set the remote and pull/push. That's the same as what you want, except that the inital remote already has some files in it.

Thank you for the response, the sanity check, and the additional suggestions. Your second approach sounds like it is simpler to implement, thank you!