Creating an Xcode project from existing .C file on GitLAB [duplicate] - xcode

I am working with an existing GitHub repository and I want to create a new Xcode project from it. How can this be done?
I have previously used Xcode just as a python script editor and never created a project, but I would like to do so in this case so that I can have a special indentation style just for the files in this project (this is Python, so no interest in build targets etc, just want to edit and use git).
I am using Xcode 6.0.1 on Mavericks.

IanAuld's answer sent me in the right direction and I figured out what I was doing wrong. I had been assuming that the Xcode project should be inside the directory with the git project, but that was causing problems because then git tries to track the Xcode project.
Here's what I am now doing, which seems to work:
Create a new Xcode project somewhere that is not managed by git. Make sure that "Create Git repository on ..." is not checked.
Clone the github project to a directory that does not include the Xcode project.
In Xcode, File | Add Files to "ProjectName"..., and select the folder with the git project.
Now, if I edit any of those files in the context of the project, it uses the indentation style I set for the project (though if I edit the file on its own it uses my global indentation style), and I can control git through the Source Control menu.
Problem solved.

Related

Xcode 8: how to add a GIT repository to an existing project

When I created this Xcode (Swift) project I forgot to check "Create Git repository". I spent many hours getting the first part of the project working and then realized I can't do a GIT commit. Is there some way to correct that oversight? IOW is there a way to change an existing Xcode project to include a GIT repository?
Usually I make a GIT commit right at the beginning but I obviously forgot to do that.
I'm not going to spend the time to learn GIT command line commands. If that's what it would take I'll instead make a new project that includes a repository and copy everything into it from the existing project. I've done that before but it's not quite as simple as it sounds.
Check if you have enabled Source Control in your existing XCode project.
Xcode > Preferences... > Source Control: check the Enable Source Control box.
That will give you access to Git menu commands.
For a full tutorial (XCode only, not git command line), see "Using Git with an existing XCode project" (answer starting with "Xcode 7 (and 8)")
The OP RobertL adds in the comments:
that answer misses one thing, namely that it puts only one file into the repository, not all of the project files.
If you make a change in every file in the project and commit again they all get into the repository.

How to add existing Xcode project to git version control in Xcode?

It's clear how to add an existing project to GitHub outside of Xcode, there are a number of tutorial: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
There are also a number of tutorial of how to create a new project in Xcode under version control.
However, there are no tutorial on how to do both: add an existing project with the controls within Xcode. Is this even possible? Or since I already started the project, I'll have to do it all via command line?
Since you didn't ask Xcode for a local git repository inside this project folder when you created the project, you will have to create one via the command line.
After that, you can use Xcode's internal GUI to give git commands in your project - if that's the kind of thing you really want to do (personally I abhor Xcode's git interface).

How do I add Source Control to an existing project

How do I add Source Control to an existing project?
On some of my projects (originally created in Xcode3) I added Source control in Xcode4. I recollect there was an option to do this.
I now want to do similar for some old projects, but can find no way to do so.
I have searched and the only "solutions" I can find is to create a new project, and copy the original source files.
Unfortunately the way Xcode5 structures a new project is quite different, so this is not straightforward.
Is there a way to do this in Xcode5? I could probably do this in git, or even go back to Lion, but I am sure I am not the only person who wants to resurrect an old project.
Xcode doesn't have an option to create repositories for existing projects. You'll have to create a git repository from the command line. Launch the Terminal application, navigate to your project's directory, and run the git init command to create a git repository for your project.
If Xcode doesn't automatically recognize the repository you just created, open Xcode's Accounts preferences and add your repository from there.

Does CocoaPods prevent double clicks on XCode project files?

I am considering using CocoaPods on an existing iOS project.
However I got confused when I read the installation instructions, which say:
Make sure to always open the Xcode workspace instead of the project
file when building your project:
$ open App.xcworkspace
I have no idea what they want to tell me with that. I know there is a .xworkspace file within the .xcodeproj bundle.
But does that mean I can never again simple double click on my .xcodeproj file? Can I no longer open the project from the XCode recent items menu? And do I always need to open it from Terminal?
The concept of CocoaPods sounds interesting, but I don't want to mess with XCodes internal project structure...
A workspace is like a step up from a project. It can contain several projects. When you install Cocoapods on your project, it creates a workspace which contains your original project and a new Pods project which contains the code from the pods you are using.
It also creates dependencies between your project and the pods project (since your project needs the pods project to be built before you can build your own, it has to look for the headers, etc.). Because of this, if you subsequently open the project file instead of the workspace file, it will fail to build because it doesn't have the right information about the Pods.
The change doesn't really affect anything about the way you work - just double-click the workspace file instead of the project file, and the workspace will subsequently show up in your recent items list.
You don't need to open it from the terminal, that guide is just there because you would have installed the pods from the command line, so it is a convenience to then open the workspace file immediately from there.

XCode 4.3 and SVN

I'm new to iOS developing, I haven't used earlier versions of XCode.
Yet I have stored my project on my local hd. Now I want to use some online subversion service.
I cannot seem to find the appropriate options in XCode. The hints that I googled all refer to a menu called SCM which I don't seem to have.
I created a new and empty repository online (webbased) and tried to configure XCode to use it by selecting the "Connect to a repository" menu when xcode starts. After some tweeking in the command line this "connect to a repository" succeeded but afterwards XCode simply closed itself again.
I tried copying the files that belong to my project to the path that I set up to be used with SVN manually. I opened the project in XCode from that path and after adding another file wanted to commit that change but couldn't find how to do that from within XCode.
Now I found that in XCode / Organizer / Repositories / MyProject is listed but has the type "GIT", which is wrong.
Do I have to change the repository type to SVN instead of GIT? If so, how can I?
When you created the project there was an option to put the project under source control. This option creates a git repository and is checked by default.
To use SVN you have to import your project into the SVN repository. (And you probably don't want it to be under git and svn at the same time, so you'll either delete the .git folder or recreate your project without the scm option selected.) Once the project is imported into your repository then you make sure Xcode knows about the repository and you can check the project out.
But really I'd recommend just using Git. It's a modern version control system with lots of nice features (though to do much of anything out of the ordinary requires using the command line) and there are nice project hosting sites for it like GitHub. I don't think SVN compares very well to git.

Resources