add Xcode target in git repository - xcode

I am working on an iOS project.
I have checked source control support (git) at project creation.
I have add a target for apple watch. In fact Xcode created 2 targets: watch app and watch app extension.
My problem is i was supposed to see a letter (A) in project tree but i do not see nothing next to new files.
How can i add those new folders and files in git ?
Thanks

git add -A
This command will add all new changes in the current repository. To run it just open Terminal and go to your Xcode project folder and type it in. You can then see the added changes with git status

Related

Xcode source control issue (All projects are already under source control)

The last 5 or 10 sessions, whenever I go to start source control (Source Control > Create Working Copy), I'm prompted by a message "All projects are already under source control." For each of these projects that this message popped up on, I went to the directory of the session in Terminal and ran ls -a to check for hidden files and see if .git files really existed. I did this in the directory the Xcode sessions are located and went back one folder at a time, checking each folder for .git files as well, but none of the parent directories have .git files either. The only way I can get Xcode to start source control is if I use terminal to make the first git commit:
git init git add . git commit -m "Initial Commit." This never used to happen before, I used to always be able to start source control through Xcode.
Then I can use Xcode source control after.
Anyone know of a fix?
On OS 10.12.3 and Xcode 8.2.1
I wrote a solve in the form of articles at a similar issue.
https://stackoverflow.com/a/50751648/2036103
hope will help someone.
The message All projects are already under source control, means the project has already controled by git (.git folder in the same path or as the parent path of the). So what you need to do for the project in xcode is to commit/pull/push. Or you can config the project by source control -> project (usually above create working copy item) -> configure git.
If you want add a file in the same git repo, you should add a file in the path same as .git or it's sub-path, then in xcode -> source control -> commit -> select the file you added -> commit.
If you want to do source control for another project, you should close the current project, and then reopen xcode with another project.

Commit to git after switching to workspace and adding CocoaPods library

I'm a Cocoapods newbie, so I have a basic question.
After adding cocoa pods to my project, a workspace file is generated, and from now on I must to use this file to open and work on the project.
Currently my project is stored in an Git.
To enable my working partners to work with me on the project, I need to commit the .workspace file so they to can open and work on the project too. But unfortunately, after creating the workspace by the cocoa pods, my Git client (Source tree) doesn't recognise the .workspace file as a added file.
Is there something I'm missing? Do have to commit my .workspace file in order to enable my code partners to work on the project with the Cocoapods added library? or maybe its a Xcode setup in order for the Git to recognise the new workspace?
any assistance would be greatly appreciated
Did you try?
git add --all
git commit
And then checking if the file was added???

Xcode won't add files to source control

when ever i add files to my project. Xcode should automatically "at least it did at one point" add it to my source control. and write a A out for it.
now it just does this : see picture
i tried to reinstall Xcode using app-cleaner.. nothing changed there
And NO it doesn't help if i click the add files, no matter where in Xcode i click Add - nothing happens...
i'm using Github as repo
and using Xcode 5.1
i know i could just use Terminal and use git commands like : git add -A git commit -m "first init" and finally git push origin -u
but Xcode should do all this for me
If you click on 'Source Control' in the XCode menu do you see two options listed? I found that I had a .git file located in my iOS projects directory which contains all of my iOS projects. I deleted this and it fixed the problem.
I think that when you import all of your repos into SourceTree it creates a .git file in the parent folder of your repos.

Xcode 5 - How to use source control with a workspace

I've created myself a Xcode 5 workspace and added 2 projects into it. The first project is a Mac OS X Cocoa Application and the second is an External Build System.
When creating the projects I checked the option so it would create a git repository for each. Then, I've tried looking at the menu item Source Control and every sub item was grayed out except Check Out ... which is not what I want to do. I wish to add the files to the repo.
How can use source control in Xcode 5 with a workspace?
Edit: I've tried to create the projects without the git source control option and creating the git repositories manually from the Terminal. Sadly, Xcode is not detecting them.
Finally, I've found a solution to my problem.
I created the workspace with the projects inside without any source control options. Then, I manually created a single git repo inside my source folder by doing the following in the Terminal.
cd /path-to-my-source-code/.git
git init
git add .
After, I added a .gitignore file inside the .git folder as suggested in https://stackoverflow.com/a/12021580/209824.
The final step was to restart Xcode.

Using Git with an existing Xcode project

I am trying to figure out how to use git in my project workflow, and I have an existing Xcode project that I want to put into the repository. I think I have the repository set up correctly under organizer, but the Source Control menu is grayed out.
Apparently, it's easy to do if you start a new project, but how do I import an existing project with snapshots and everything?
I'm using Xcode 4 and git 1.7.4
Also, if there are any good walkthroughs on git configuration and best practices, that would be nice. I'm a little late to the game, so anything that can get me up to speed would be cool.
GitHub has some very good git tutorials at help.github.com.
to do the initial setup of a repository, open up a terminal window, and CD to the project directory. once there, type
git init
git add .
git commit -m "Initial commit"
Restart Xcode.
The repository should now be set up, and you will be able to manage it in xcode 4.
Xcode 7 (and 8)
If you were starting a new project you would just check Create Git repository during the setup. (Then skip down to the Commit part below.)
But it you are working with an existing project, go to Xcode > Preferences... > Source Control and check the Enable Source Control box.
Then in the main Source Control menu choose Create Working Copy....
(If you get a "Please tell me who you are" error the see this question/answer or one of the other linked questions there.)
When that has finished, make any change to one of your Xcode project files. Then go back to the Source Control menu and choose Commit.
And write a commit message and click the Commit button. (If the commit button is disabled, then make any minor change to your project and try again.)
In Github sign in and create a new repository.
Call it whatever you want, but don't add a README or .gitignore or license yet. You can add those things later. Doing so now will make the syncing more difficult.
Copy the link to your repository.
Go to Source Control > your branch name > Configure.
Click the Remotes tab > "+" button > Add remote....
Enter the github repository name and paste in the address.
After adding the remote, click Push in the Source Control menu. Enter your github user name and password. That's it. You project should be copied to github now.
(I had some trouble getting my username and password accepted at first. If that happens to you go to Xcode > Preferences... > Accounts > your new repository. Enter your user name and password there and then try the Push again.)
You can add a README and other files, but if you do it from the web, you will have to do Source Control > Pull in Xcode before you con commit other changes.
Now any time you make changes in Xcode, all you have to do is Commit and Push.
I learned this method mostly from here.
See also
The Basics of Git and GitHub
How to add a .gitignore file for Swift in Xcode
I just went through the process of doing this for several projects, and ran into some issues. Here was my process, mostly pieced together from the other answers on this page/site. Order is very important here
Open terminal and cd into the directory containing the .xcodeproj file
git init
In finder enter the newly created .git folder (in the same directory as the .xcodeproj file). Find info/exclude, open and add these lines, .DS_Store and xcuserdata/
Not sure if this is needed, but I used terminal to cp info/exclude over to a .gitignore file
git add .
git commit -m "Initial commit"
Now to get XCode to actually see the repo. In the project organizer, you first have to delete the project from the Projects tab. Then simply re-open the project to get it back. This will detect the GIT repository just created
In the repositories tab of the organizer I then branch off the master branch/switch into whatever version I'm working on.
Hopefully this helps someone without being too redundant. What now seems simple was definitely a challenge for someone new to GIT with existing projects
Check out my post on this topic Setting up a git repository in XCode for a pre-existing project. The above is correct, but it will include UserInterfaceState in your changes as you commit and this could be annoying because this file updates everytime you do anything in xcode, even if it is as simple and navigating through files or folders in your project.
if your XCODE 7 is not connecting with existing GIT repository. Try following
xcrun git config --global user.email your#email.com
xcrun git config --global user.name "your name"
Newer versions of Xcode simplify adding git to an existing Xcode project. Open your project in Xcode and choose Source Code > New Git Repositories. A sheet opens.
Select the checkbox next to the project and click the Create button to add git to the project.
Note:Specially for Xcode 11
CD to project directory using terminal
git init
git add .
git commit -m "Initial commit"
After this restart the Xcode and choose Source Control Navigator and then select the master and right click then choose option "Create Remote"

Resources