Is it necessary to close Xcode project when installing pods? - xcode

Let's say I want to install firebase pod, I add it to Podfile, next I have to run pod install at the terminal, is it necessary to close the project?

If you have the .xcodeproj file open, yes. You need to close it and then open the new .xcworkspace file after cocoa pods has done its thing.
If you have a workspace already you theoretically don't need to close it but I generally do to keep Xcode from being grumpy.

Related

Cocoapods No Source Files After Install

I did a straightforward pods install into an existing Xcode project. When I open the xcworspace file, all I see is:
What I see in when I open xcodeproj is:
How can I fix this so I can see all my folders when opening xcworspace?
You can't have both the project AND the workspace open in Xcode at the same time.
Go into Xcode, close both the workspace and the project, then only open the .xcworkspace file and you will be able to click the disclosure triangle next to the xcodeproj and list those files in the file IDE along the left side.

Multiple targets for project in xcode

I am using xcode 7.3.1. After pod update, it's showing multiple project target in the project having same details without any change. How can I fix this? If I delete any one of these, xcode crashes and when we reopen even the other option comes in red and we dont have any project.
Have you tried to delete the workspace file and the pod directory, and re-launch a pod install ? The workspace file does not hold any important information to be retained in CocoaPods.
If you have the same problem after regenerating, it means there is an error in the Pod file.

Can I delete the xcodeproj after pod install?

I know that I have to use the .xcworksapce file after I did pod install.
But today, I accidentally opened the .xcodeproj file and the whole project broke! And the problem described in this question occurred.
So I want to delete the .xcodeproj file so that I will never break my project by opening it by accident. Can I do that? I didn't try it because I'm afraid I will break my project again.
No, you can't. In fact the xcworkspace file use xcodeproj file of you project.
The purpose of the xcworkspace file is to make the merge between your project (and its xcodeproj) and the Cocoapods projects (and its Pods.xcodeproj).
EDIT:
If you want to move your xcodeproj to a subfolder (to avoid mistakes), you just have to update your podfile and add:
xcodeproj 'subfolder/yourproject.xcodeproj'
Then, delete your xcworkspace, and do a pod install.
Be careful: this works only if your Workspace contains just your project and the pods.

I can't use Cocoapods to update Podfile

I wanted to open app(UAAppReviewManagerExample),but this demo uses CocoaPods, so I wanted to update Podfile, but it failed. It asks me to find my another app's xcodeproj file in my Mac. What should I do?
You are opening wrong file, You have to open xcodeworkspace and not xcodeproj.
Also check whether instead of deleting files from project, have you deleted the files of dependency from pods. Because according to image you sent, Xcode is unable to find the files on your system, but it is getting an update request from podfile.

Source Control - Discard all changes deleted my xcworkspace and I can't fix it

I was trying to undo changes on my project to the last committed Source Control state, however when I pressed 'Discard all changes' weird behaviour happened.
The first time some of the files reverted whilst others didn't. So I pressed the button again and a blurb popped up saying something about needed to re-save the 'xcworkspace'. I pressed okay and half my files disappeared from the xcode file list on the left, really random files that hadn't been edited at all. So I decided to press revert again to see if I could get back to my original state, and now all my files have disappeared from the xcworkspace. So my screen now looks like this:
I have tried restoring the files from my trash (as this is where random ones have appeared) but the workspace is never restored. I use MapBox so I have 2 projects building in to 1 workspace, but the podfile will now not install.
Can anyone give me advice on how to get this back to it's original state as I have been trying for a few hours but can't find any information.
I felt horrible when I did this. I really thought I had to rebuild everything over again. Luckily, it was easy to repair.
Xcode removed all the "non-essential" files. This includes your Podfile (and if applicable, GoogleService-Info.plist).
To Repair:
Go to Terminal and create a Podfile in your project folder $ pod init
Update your Podfile with the pods you need
Run $ pod install
(4.) To re-generate the GoogleService-Info.plist file, go to your console.firebase.google.com > Settings > Project Settings > Download the latest config file for the appropriate project iOS app and save to your local project folder. Your workspace should recognize the file in the Project Navigator list.
Once you open your workspace, select new Scheme and everything should be back to normal.
To avoid future regressions:
Go to Terminal
git add -A
to add the pod files, then
git commit -m "Save pod files"
to save pod files. I believe git from Xcode ignores the pod and scheme files.

Resources