Git ignore xcodeproj file - xcode

I am setting up a team project under git source control, and all members of the team will be using different IDE-s. The project is a basic command line application written in C. Personally I want to work within Xcode7, but I have a problem with the xcodeproj file (or folder) which is also being committed. I dont want this, since other team members dont work with Xcode and this xcodeproj file just does a mess when they checkout. I just want to be able to commit my regular source files to git and nothing else. What should I do? If the answer is .gitignore file, how should it look?

Just add these two lines to .gitignore:
*.xcodeproj/
DerivedData/
The first line excludes the Xcode project directory. The second excludes the default directory created for object files and other build data.

Related

Exclude appsettings.json file from GitHub Repo

I have an existing Visual Studio project file (appsettings.json) that contains sensitive data that I do not want to publish to GitHub.
A repository is not currently created but I would like to create one without including the appsettings.json file.
I know that I can use the .gitignore file to exclude files after the initial push, but at this point the sensitive file would already have been pushed.
Moving forward, I can create the repository from the start of the project, but how should this be handled for an existing project without a repository?
I know that I can use the .gitignore file to exclude files after the initial push
Actually, you can use it before the initial push, even before the initial add to the index.
Simply create in VSCode a .gitignore at the root folder of your project, with as a content:
/.vscode/appsettings.json
(assuming this setting file was created automatically in the .vscode/ folder of your VSCode workspace for this project)
Then add and commit: you won't see that file in your first commit, than you can then push.
In visual studio,
Goto the solution explorer
Right click the file you want to git ignore
Goto "Git"
Then select "Ignore and untrack item"
I did the above to my appsettings.json and this is the entry i found in the .gitignore at the end of the file.
/MyProject.WebApi/appsettings.json
Here, "MyProject.WebApi" is inside the main directory.

In my iOS Xcode project, files added to .gitignore are still persisting and being updated in the project.pbxproj file

GoogleService-info.plist, Development.xcconfig, and GlobalVariables.swift have all been added to the projects .gitignore file.
Upon cloning the project from GitHub, all of the ignored files in the setup folder are greyed out.
The files should not be contained in git, as developers are to create them upon cloning the repo, add their own private keys (based on their own firebase backend), in order to do local development.
Issue #1:
Currently, the ignored files still appear (but greyed out), and developers must first delete the files, before recreating them. (this is due to the ignored files still persisting in the project.pbxproj file).
Issue#2:
The deletion & recreation of the files causes a change to the projects' project.pbxproj file, specificically, the files are recreated in project.pbxproj with a different fileRef number.
Issue#3:
Merge conflicts due to different fileRef numbers:
If two developers both clone the repo, both delete the 'greyed out' files and recreate them, the recreated files will have a different fileRef in the project.pbxproj file.
Each developer will have to perform an additional commit to account for the changes in the project.pbxproj file, and upon pushing the code to the remote repository, there will be a merge conflict in the project.pbxproj file.
The goal of adding the files to .gitignore was to keep each developers added code secrets out of git (Which it is still currently accomplishing).
However, is there a way to ensure that files added to .gitignore are also kept out of the ```project.pbxproj`` file?
Goals:
1) The files in .gitignore should not appear in the Setup folder upon cloning.
2) The creation of the files that have been added to .gitignore should not be added to the project.pbxproj file at all
3) Developers should effectively be able to clone the repository and create the setup files without any changes occurring in Git.
Any feedback on how to accomplish this is appreciated in advance.
To Clarify:
The files added to .gitignore are properly being ignored by git, the issue is that the created files are still being added to the project.pbxproj and persisting there, where they ideally should not be.

Dereferences a xml file from xcode

I made a huge mistaking in renaming my xml file from xcode and I'm not sure how to fix it. My app has a feature that reads all local xml files built with the project. So now it is reading 2 of the same xmls with different names.
I tried deleting the file, added it back in, and Dereferencing it but no luck. I also made sure to delete my app and re building the project. When I do a full system scan for the xml file nothing pops up. The xml file is currently in the Trash.
Another issue might have been with the svn remote server but I tried svn rm --delete filename and it said the file does not exist. ( I tried the project directory as well as a few other sub directories).
Is there a way to Dereference/delete the file from the project?

Xcode 4 project: utility to clean up pbxproj file?

I have an Xcode 4 project with 2 targets, one for iPhone and one for iPad. If I click on the iPad target and try to go to Build Settings Xcode 4 crashes:
Encountered multiple assertions. First assertion was: ASSERTION FAILURE in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-269/Xcode3Sources/XcodeIDE/Frameworks/DevToolsBase/pbxcore/FileTypes/../PBXFileType.m:594
Details: filename should be a non-empty string, but it is nil
Obviously the pbxproj file has a bad reference in there somewhere -- likely caused by the many manual merges I've been forced to do by git. Is there some way to clean up the pbxproj file so it works correctly again or to tell which line is causing the problem?? I'd really really prefer not to have to recreate the project from scratch.
I tried gorbster's method with no success (though it has solved similar problems for me in the past).
I went into my project.pbxproj file (inside the .xcodeproj package for the project) and found two lines that looked a little suspicious, both of the form:
53A45F8F138FE6F40077017F /* (null) in Resources */ = {isa = PBXBuildFile; };
I deleted the lines, and voilĂ : I can access my build settings for this target again.
No idea how they got in there in the first place. I would guess something to do with a faulty merge under SVN.
Ran into the same issue this morning after pulling a colleague's merge.
I was able to fix this with the following:
Close Xcode
Open the .xcodeproj package in Finder
Delete the project.xcworkspace file/package
Open the xcuserdata folder and delete your user-specific .xcuserdatad folder.
Re-Open Xcode and project
I lost some minor user preferences (file and tab history, etc), but can now click all (9) of my targets without issue. Turns out my colleague was on an earlier version of Xcode, but I'm not sure if this contributed to the IDE crashing.
Ben Mosher found the solution.
And yes it is due to SVN merge problem.
As we working in team with SVN the error occur often so I wrote a bash script:
#!/bin/bash
sed "/(null) in/d" project.pbxproj > tmp_project.pbxproj
mv tmp_project.pbxproj project.pbxproj
Try the following steps while your Xcode is closed.
Go to your {YOUR_PROJECT}.xcodeproj file in finder.
Right click on the {YOUR_PROJECT}.xcodeproj file.
Choose Show Package Contents ... this will open the contents in another Finder screen.
Open file project.pbxproj and search for all lines having string "(null) in"
Delete all lines having (null) in ... no worries.... delete confidently.
Save your file.
Now open your project using Xcode and try to open the Build Settings tab... hopefully your problem will be solved.
Thanks,
Mohamed.
Right click your .xcodeproj file and "Show Package Contents".
Then open project.pbxproj file with TextEdit and duplicate.
Save duplicate file anywhere with same name and extension. (project.pbxproj)
And replace with the old file.
In case you also tried the remove (null) reference lines and deleting the user-specific .xcuserdatad folder, and those did not work, here is a potential solution. FYI... This was experienced on Xcode 7.3.1 .
Here is the scenario I faced:
I experienced this issue that was triggered by having "twin" branches in a git repo... (i.e. one branch BRANCH_A is a development branch with some features not due for release, and another that had the same commits except for the new features, call it BRANCH_B).
The development work flow is as follows: start with BRANCH_B, create a commit branch CHANGE_C, make changes and commit, then checkout BRANCH_A, create a commit branch, then cherry-pick changes from CHANGE_C. BRANCH_A is tracking BRANCH_B in this way, with its additional feature files.
In my case, (for some reason during rebasing on co-worker changes from the remote that BRANCH_B tracks, the project file for BRANCH_B got corrupted.
In this case, the solution is to save a copy of the project file for BRANCH_A (which is good and compiles), then checkout BRANCH_B, and replace its project file with the copy.
Initially, it will not compile, until all references to the feature files (from BRANCH_A) are removed from Target's Build Phases > Compile Sources.
Works great.

How can I remove files from a QtCreator project

Might be a very newbie question, but I can't find a way to remove files from my projects in QtCreator. Thanks!
If your project is generated from CMake, the file list is determined by the CMakeLists.txt file, and you cannot add or remove files manually from the source tree in QtCreator. Especially if your CMakeLists file specifies the glob operator for a project's file list, you must manually remove the files from disk and re-run CMake from within QtCreator by going to Build->Run CMake (QtCreator 3.3.0). This will update the file list but also regenerate the project (cbp) file - re-running CMake outside of QtCreator will not update the project file and you will have ghost entries of deleted files showing up in the source tree if you deleted them from disk.
Right-click the file you want to remove, and choose "Remove File..."
Checking the "Delete file permanently" check box will delete the file, otherwise it will just be removed from the project.
Find your project file .pro in qt creator or other text editor
Find the file/folder name you want to remove in the .pro file
Delete all the files you want to remove
save and close the project
Reload the project
DONE
Could not find one-touch action as in Eclipse to delete a class:
1) Press right click on the file/class, and then choose "remove file..."; (u can tick "permanently" to remove from HDD if you like).
2) Do it to .CPP and .H files.
3) Then check in your .pro file the class are not there anymore.
Note: Some compilers will keep searching for this file/class in compilation. Just delete the compilation directory and compile again.
If you mess up like me and accidentally add a lot of files to the qml.qrc, it might help to know that these are listed in the actual qml.qrc file which you can edit to remove these files.
I also run into this problem.
I wanted to remove a header file.
But remove action in context menu was disabled I didn't know why.
The file name was qtextdocument.h.
I wanted to change the name to textdocument.h.
I tried to do various ways, but the filename was strictly fixed.
My removal procedure was as follows:
I dare to add an empty file to the file directory (in header file directory).
Anyway, I set the file name as textdocument.h when Qt Creator asked me to set the filename.
A confirmation warning popped up.
(Qt Creator cannot add the file automatically, we must add the file name to CMakeTextLists.txt)
I changed the filename in CMakeTextLists.txt from 'qtextdocument.h' to 'textdocument.h' in the row of set(PROJECT_SOURCES).
Finally, the update was confirmed. 'qtextdocument.h' was removed and the name is changed to 'textdocument.h'.
If you only want to remove a file, only you have to do is to delete the filename when you are in step 3.
After updating the project tree, the actual file is in your computer.
If you want to delete the file completely, you select file system and remove the file, not from project.
I don't know why, but in the case of filesystem mode, remove action is enabled.
So I might & should have told you that you select "filesystem mode" and remove the file at the first time...
(Sorry I have found out this fact later.)
Both of the two ways, I think we must rewrite the contents of CMakeTextLists.txt.
I also run into the case , the update removed the filename as soon as I deleted the filename from CMakeTextLists.txt.
I believe this case I directly make a file in the actual directory. On the contrary, above case is the files are added from Project menus.
go directly delete the project folder from your hdd.
For Linux, edit ~/.config/QtProject/QtCreator.ini
Under [ProjectExplorer], delete the project name and its corresponding configuration file from the following two lists:
RecentProjects\DisplayNames
RecentProjects\FileNames
e.g., given the following
RecentProjects\DisplayNames=proj1, proj2, proj3
RecentProjects\FileNames=<proj1_dir>/CMakeLists.txt, <proj2_dir>/proj2.pro, <proj3_dir>/proj3.pro
to delete proj1 from the qtcreator startup page, edit the above two lists as
RecentProjects\DisplayNames=proj2, proj3
RecentProjects\FileNames=<proj2_dir>/proj2.pro, <proj3_dir>/proj3.pro

Resources