Xcode targets with GIT - ios

Today I created a new target in my iOS app to make a rebrand of the app.
Now I see in Git that it shows some files from the original target(.pbxproj, .xcsheme, .plist) as missing, but that is supposed to happen (I assume).
My question is, what do I do with these files?
Just commit them as missing or is it better to set the files to ignore?
Currently I am working alone on this project but that might change in the future.
Thanks

Related

project.pbxproj is always tagged as modified in git

I'm having some problems with xcode, with disappearing linked libraries, etc.
After some research, it seems that my project.pbxproj file has been completely changed in between two commits, and I'm trying to restore an older version. However, and it has been some time now, my project.pbxproj is always flagged by git as modified. I've always figured it was XCode modifying the file at the same time I was modifying some things in the GUI. However, for the first time, git is keeping me from merging, or reverting, due to changes to this file. I can't gitignore it as it contains vital information necessary to build my project.
It gets weirder, though, as the file is indeed always in a modified state. I just tried booting my mac with absolutely no app open, no IDE, not xcode, and just opening a terminal, to clone my project in a newly created folder. After cloning, if I just cd into the folder and git status, the file is flagged as modified.
Is this behavior normal? Have people experienced issues with this file and git? Can i revert my project.pbxproj to an older state, and is it safe to do so? Are there some git configurations that I can use to better handle this file?
My project isn't native, I'm using the react-native framework
The file project.pbxproj is constantly changing since it contains information about the structure and configuration of the project, linked frameworks and more.
i found that adding *.pbxproj binary merge=union in my .gitattributes fixed 95% of my merge problems in that file, there is always one rare case where the union fails and you end up with bad closing brackets, but is usually easy to find and fix it manually.
I've understood what was my problem and I'll expose it here, then leave it to moderation to see if it is relevant, as this situation might happen to other people.
I have, months ago, changed my package name on Xcode, removing some capital letters, as an application of my understanding that packages names shouldn't include capital letters. The name went from com.mycompany.MyApp to com.mycompany.myapp. As a result, XCode deleted the MyApp.xcodeproj folder and created a myapp.xcodeproj folder (I think it was automated, but can't be sure, as this happened a few months ago).
All went well in this regard, except git kept trace of both folders in the repository. Whenever I would clone my repository, I would get a myapp.xcodeproj folder, but git would still consider there was both myapp.xcodeproj and MyApp.xcodeproj in the repository.
This led to git comparing different files in local and remote, therefore systematically considering this file as modified, even if it was just committed, or even pushed. Git always was comparing the current version of the file with one that was 2 months old. The behavior was erratic, as the myapp folder was always flagged as modified, and actually modifying it would flag MyApp folder as modified as well.
Hope this might help someone someday.
I'll answer my own questions:
Is this behavior normal? Absolutely not
Have people experienced issues with this file and git? Yes, human merging of this file is difficult and I wouldn't recommend it. To avoid having to do so, Javier Rivarola's answer as well as this question might help you
Can i revert my project.pbxproj to an older state, and is it safe to do so? You will lose the configuration you've done after that, but the file stays valid
Are there some git configurations that I can use to better handle this file? see second question

Get lost Xcode binary from archive in organizer?

Alright, so I had been having issues with this and never resolved them, finished my app and published it before this caused major problems -
I have pods installed for my Xcode project so I had been working off a workspace. I had always backed up in the past by copy pasting my project folder then renaming, however more recently something happened that cause every change to my workspace to affect all previous versions.
I tried everything - saving to external hard drive, github, etc but I just ended up going on working on the workspace and making sure I didn't screw anything up. Along with this issue whenever I clicked on the Xcode project that is in the project folder, none of my new code would be there.
That Xcode project version was from several months back and the only way to see my new code was to click on the workspace. I asked a question about this but no one had an answer.
A week ago I finished the app, archived and uploaded to App store. It is now published, however I want to update so today I went to my workspace and the project file above the pods file was RED meaning not there.
I have no idea why this would have happened. Dragging the Xcode project i the folder to the workspace again, just runs the very old version.
I need to get my binary back and solve this problem. Im desperate. I have this:
One of the export options is save for development and such.. Is there a way to get my binary back from this archive? How can I fix this problem?

Xcode project renamed and now it is lost

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.

Is there any better way to rename an XCode project than the given one?

The given version is described here: How do I rename a project in Xcode 5?
But, as you can see from the following screenshot^, not everything gets renamed, and if one opens package contents, directory names etc. to try to manually change all the references, the project is broken afterwards, so you have to keep the old project name for sub directories etc., which granted is not a massive problem, but is intensely irritating, and I'm not enjoying being intensely irritated at work.
^ apologies for a screenshot, but there's too much information in it to transcribe to written text. Top two-thirds of screenshot is XCode project, bottom third a Finder window.
Renaming projects in xcode in one of the most annoying things in iOS development. I assume you want to rename your app. I faced this problem once and figured out a simple, clean way to do it.
Go back to the point where everything worked.
Open project in xcode and click on the project icon in the project structure( first file)
Go to the info tab
Search for Bundle Name. Most probably it will automatically be set to $(PRODUCT_NAME) which is a shell variable that will set your app name the same as the project name.
Set it to whatever you want your app name to be
Done
Notes :
If you use custom URL Schemes this might produce an error when redirecting.
ALWAYS git or some other SVN in your projects. This will come in handy in this kind of situations

Xcode Archives a Previous Version

This question seems related to XCode Build and Archive for Enterprise Distribution builds old archive but the answers have not worked for me;
We have an iOS application that is distributed using the Enterprise Distribution method. This has been updated regularly for the past year by issuing a new IPA and having users delete and reinstall the app. Lately when I archive and distribute the app it installs correctly, but it is a previous version from a few days ago with none of the recent changes. These are things as simple as text labels and alerts with the wrong text.
I've done everything I can think of, including:
Confirming it builds and runs correctly in the simulator and when building directly to an iPhone. Everything works great in these cases.
Cleaning the project.
In the Organizer, deleting all archives and removing the project.
Manually deleting the DerivedData folder.
Renaming the IPA and updating the distribution plist to ensure that the file isn't somehow being cached on the web server.
Deleting the entire project and doing a fresh checkout from SVN.
Even when I do all of these things together, so that I've completely removed the project from my computer and Xcode and re-archived it with a fresh checkout of the source files, it still archives an outdated version. Where could this be coming from? Should I just reinstall Xcode completely?
Since you have deleted and checked that your build files are clean from old rubbish, I would have a look at the actual source files and the project and make sure you are actually making your changes on the right place.
Right click on the files that you are working on in your project and select "Show in Finder" and see where they are actually located. Maybe they are in a different location than you would expect?
Do the same with the files under "Compile Sources" in your target, and make sure they are the same files and at the same location as the ones you have been editing.
It could be that if you at some point has fiddled around with your files and projects that you actually imported the wrong files and that you are editing different files than the ones included in your build. It happened to me once, I had to re-import lots of files to my project to get it working again.
The network was caching it! The wireless network in my office is serving up a cached version of the IPA from yesterday, while an external network downloads the latest copy just fine. It's embarrassing that I never thought to check this, but I suppose the solution is often obvious in hindsight.
Thanks to Jake and Mike for the suggestions; I'm sure they will be helpful to others who come across this question.

Resources