What does this command 'xcode-select --switch /Applications/Xcode.app' do? - ios

I had a problem installing cocoapods flipper-glog so found out this solution to run:
this command xcode-select --switch /Applications/Xcode.app.
But what does this command actually do?

Many command-line tools require access to functionality that is actually hidden inside Xcode itself. xcode-select points to the copy of Xcode where that functionality is located.
If you say in the Terminal
cd /Applications/Xcode.app/Contents/Developer/usr/bin; ls
you will see some of the tools in question. For instance, if a cocoa pod needs to compile some code, it needs gcc which is located inside that directory within Xcode. Similarly make is in there (that's probably the main thing that flipper-glog needed).

Related

Command PhaseScriptExecution failed with a nonzero exit code - using CocoaPods

I'm getting the following error when building my project: Command PhaseScriptExecution failed with a nonzero exit code.
This is what I have in my [CP] Embed Pods Frameworks:
I've also done a pod deintegrate and pod install but these frameworks continue to show in red:
I'm on Xcode Version 12.4 and my mac has an Apple M1 chip. Any thoughts as to what I could do to resolve this error?
Clearing the Excluded Architectures solved the issue. I originally had arm64 and x86_64 excluded.
Did you solve your issue?
I got the one of solutions.
First of all, you have to delete the files which are red of iOS, Frameworks . They don't exist anymore, so you shouldn't include them to archive.
then clean up your builds.
(click Xcode -> product -> clean build folder)
go to archive.
(click Xcode -> product -> archive)
If you don't use M1, then you have to exclude architectures "arm64".
That's it.
Hope it works.
clear all files inside Library/Developer/Xcode/DerivedData/
List item clean & build again from xcode
if you're using nvm make sure you don't have another globally installed version of Node/npm.
If you aren't sure whether or not you have a global version, go to your bash_profile/zshrc and comment the three nvm initialization lines (export NVM_DIR="$HOME/.nvm" [...]), then open a new terminal and do node --version, if it still finds something it means that you have a global version somewhere, and you can find its path with which node.
In my case I'm using Homebrew, and I had a global version of Node that I wasn't even aware coming from the yarn formula, I discovered it after running brew uses --installed node. I went ahead and uninstalled yarn using brew uninstall --force yarn, which automatically uninstalled its node/npm dependency, then uncommented the nvm initialization lines, and then I reinstalled yarn using nvm's npm with npm i -g yarn, and now everything works.
Another way, after installing node via brew install node RUN sudo ln -s /opt/homebrew/bin/node /usr/local/bin/node
restart xcode and try to build again.

Carthage requires git 2.3.0 or later

I am using charts library and trying to run the demo. Before running I have to install the dependencies using Carthage. I goto project folder location and type in terminal:
carthage update
I got the below error:-
Carthage requires git 2.3.0 or later.
How to install Carthage decencies and run the above said demo.
Select Command Line Tools to the latest version of Xcode.
Xcode -> Preferences -> Locations -> Command Line Tools
Open Preferences shortcut : Command + comma ⌘ + ,
It seems like you have used another Xcode version since last time. You should set command line tool again by running the following in terminal:
sudo xcode-select -s <path to Xcode>/Contents/Developer
for example:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Not sure if this will help, but I ran into the same issue and found out that xcodebuild is using a different Xcode that I installed.
so you can probably double check which Xcode you are using:
xcode-select --print-path
Here is the original post that helped me solving this issue:
Change Carthage Swift version
It seems you have to install new version of git.
brew install git
It could say "Target /usr/local/bin/git
already exists. You may want to remove it". I didn't want to remove it and decided only to overwrite:
brew link --overwrite git
It helped me with the same issue. I hope it will help to someone else.

Change Carthage Swift version

Is it possible to change Carthage Swift version used to build the frameworks?
I'm trying to migrate my project to swift 3 (on Xcode 8 beta), and the third party libraries are the only thing that stops my project from compiling.
While using specific branches for swift 3, Carthage throws errors about the new Swift syntax.
Any help will be appreciated!
Carthage uses the command line tool xcodebuild to build the frameworks. The version of Xcode used by the command line system is determined by the value selected by the tool xcode-select
Usage: xcode-select [options]
Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example,
xcodebuild) as well as the BSD development commands (such as cc and make).
Options:
-h, --help print this help message and exit
-p, --print-path print the path of the active developer directory
-s <path>, --switch <path> set the path for the active developer directory
--install open a dialog for installation of the command line developer tools
-v, --version print the xcode-select version
-r, --reset reset to the default command line tools path
It needs to point to the Developer SDK directory, so you can use --print-path to check where it's currently pointing.
xcode-select --print-path
/Applications/Xcode.app/Contents/Developer
Then to change it just run sudo xcode-select --switch <path-to-beta-xcode>/Contents/Developer
There is a bug report on Carthage's GitHub about XCode 8 and broken compatibility. You may want to follow that issue's thread on their repo:
https://github.com/Carthage/Carthage/issues/1440
Another related reported issue in Carthage's repo is: https://github.com/Carthage/Carthage/issues/1445

CMake installation

I installed CMake (on ios), and it seemed like the installation was completed.
However, when I type
cmake -version
I get
-bash: cmake: command not found
Is there a need to set up CMake before using it?
Assuming you're talking about OS X, not iOS: CMake is installed, but not in the PATH in your shell. You can add it via something like:
PATH=$PATH:/Appications/CMake.app/Contents/bin
Then the cmake command will work on the command line.
You can edit the file ~/.bashrc to set your PATH this way every time you open the command line, instead of needing to do it manually each time.
https://en.wikipedia.org/wiki/PATH_(variable)
you can open CMake with GUI in Launchpad, and click the "tools" - > "How to Install For Command Line Use" menu, you'll find ways to solve it
The previous answer pointing to /Applications/CMake.app/Contents/bin is correct but you can go one step further.
If you run
/Applications/CMake.app/Contents/bin/cmake-gui --install
Then it will link the executables into /usr/local/bin.

Cocoapods terminal setup 'edit' command not found?

I am attempting to setup an installation using Cocoapods for my iOS Xcode project.
cocoapods.org
When I get to the point where I need to edit my Podfile, it doesn't work. I attempt to execute the command edit Podfile in the correct directory, but I get:
-bash: edit: command not found
I'm not exactly sure what to do and performing that line is pretty vital to getting cocoapods working correctly.
I have tried restarting terminal and my computer as well with no luck.
Bit of a strange one from the Cocoapods documentation there, as there is no edit command built into OS X as far as I'm aware. They probably just intend that example to mean 'edit with your favourite text editor', or it could be that they're using TextWrangler's commandline tool (see below). Here are some alternatives you could try, however...
Open the Podfile with TextEdit
open -a TextEdit Podfile
This will open up your Podfile with TextEdit. Replace 'TextEdit' with the name of some other app if you prefer.
Set up SublimeText or TextWrangler to work from the command line
Both of the popular text editors SublimeText and TextWrangler have the option of installing command-line executables.
TextWrangler asks you on first launch whether you want to install them, and will then do it automatically. For Sublime Text you need to run the following command:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
(You may need to change the path to the application in there depending on whether you have ST 2 or 3 installed)
Depending on which editor you use, you'll have two possible commands you can use:
subl Podfile - open your Podfile with SublimeText
edit Podfile - open your Podfile with TextWrangler
Use a Terminal editor
Finally, for the more advanced user, you could use a terminal-based editor, such as Vim or Nano. Nano is easier to get started with, and is fine for small edits like this. Just run nano Podfile from the Terminal.

Resources