Xcode: Command not found - xcode

I have installed Xcode on my MacBook.
I checked that I have the XCode command line tool also installed as shown below:
I need to use Xcode command to install some dependencies, so I opened my terminal and run the command:
But I get Xcode: Command not found error. Why? How to get rid of this issue?

Okk, if you're trying to install the AWS ELastic beanstalk CLI (you're coming from EB CLI Installer on Github here)
then the line Xcode openssl zlib readline refers to all the packages that are prerequisites to the installation and not a command that you should run.
In short use:
brew install openssl
brew install zlib
brew install readline
And make sure Xcode is installed through which g++ if you get /usr/bin/g++
you're all set and you can proceed to the following steps

Related

Error Message "Xcode alone is not sufficient on Sierra"

I'd like to install openCV to vectorize image, but there's a series error message regarding Xcode and Ruby.
First, I use terminal to install openCV, brew install opencv.
Then, I got error message indicating that the system doesn't like my ruby version.
/usr/local/Homebrew/Library/Homebrew/brew.rb:12:in `<main>':
Homebrew must be run under Ruby 2.3! You're running 2.0.0. (RuntimeError)
So, I want to upgrade my ruby. I followed several update strategy from this post. First ruby upgrade trial: brew link --overwrite ruby & brew unlink ruby && brew link ruby and get
Error: No such keg: /usr/local/Cellar/ruby
Then second ruby upgrade trial: brew upgrade ruby and see the following error message.
Error: Xcode alone is not sufficient on Sierra.
Install the Command Line Tools:
xcode-select --install
This error message means I need to install Xcode which I already install. So, I check my Xcode status with code-select -p and get /Applications/Xcode.app/Contents/Developer which means I am fine.
I saw a comment regarding where you install python could be a big issue. Quote from the source:
If you see /usr/local/bin/python3 then you are correctly using the Homebrew version of Python. If the output is instead /usr/bin/python3 then you are incorrectly using the system version of Python.
I check which python3 and get
/Users/******/anaconda3/bin/python3
Could this be the problem? How can I change system version to local?
Let me explain this myself so people won't make the same mistakes.
When I saw the last line of the error message
Error: Xcode alone is not sufficient on Sierra.
Install the Command Line Tools:
xcode-select --install
My thought was: I already have Xcode why the system ask me to "reinstall" it. However, thanks for #SamiKuhmonen # Beartech #patrick kuang suggestion, I search a page (in Mandarin). xcode-select --install does not reinstall the whole Xcode. It means install some missing command line tools which is required by installing Ruby.
Trying to install k8s package via brew , I just got the same issue a while ago saying in the terminal :
Error: Xcode alone is not sufficient on Sierra.
Install the Command
Line Tools: xcode-select --install
You need to download *.dmg file; named Command Line Tools (macOS x.x.x) for XCode N . Search on it here : https://developer.apple.com/download/more/ . You must have developer account.
Then, congrats! 🎉
update for 2019
macOS Mojave 10.14.5
Use Xcode10.2 for macOS 10.14
I had the same issue in my Macbook Pro on Sierra. Apart from updating Xcode from the App Store, I also installed the command line utilities using the xcode-select --install command.
After the update steps, brew commands started working fine. I also updating my OS during this time.
I got the same message despite having Xcode and the command line tools already being installed a long time ago and updated numerous times.
I think it is the Apple way of telling you that Xcode command line tools need to be updated, as the App Store showed me the below:
After executing the xcode-select --install command, the update disappears from the App Store, which means they are exactly the same thing.
I had the same problem. I installed 'Command Line Tools for XCode' (choose appropriate version) from https://developer.apple.com/download/more/ and restarted my terminal. Issue resolved :)

"xcrun: error: active developer path… does not exist, use xcode-select --switch" when trying to run git. How to fix?

I have been trying to instal the Git on my mac, But every time I use the command $git --version.
I get the following error
xcrun: error: active developer path ("/Volumes/Xcode/Xcode.app/Contents/Developer") does not exist, use xcode-select --switch path/to/Xcode.app to specify the Xcode that you wish to use for command line developer tools (or see man xcode-select)
I have already installed the Xcode on my mac for iOS App development.
I am not sure what this error is trying to say.
My case:
I removed XCode. JetBrains integration with git - breaks. Found this error in terminal.
My soltuion:
I don't want to download XCode to restore PyCharm. So I ran:
sudo xcode-select --reset
So from discussion in the comments above, it seems the right fix here is just to run the command /usr/bin/xcode-select -switch once (i.e., run it with the full path to the executable, rather than just as xcode-select) with /Applications/Xcode.app/Contents/Developer/ as the argument:
sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer
After running that once, everything should work as expected from then on.
sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools
and reboot your computer.
Try this below answer. It's worked for me.
Open your Xcode Preferences,
--> Select Locations
--> Select your specific Xcode version in Command Line Tools
It was easier for me to let Xcode pick the install location of Command Line Tools for me, instead of the other way around. After downloading the .xip file from the Apple Developer downloads page, expanding the compressed contents, and installing Xcode.App, I was able to open it using Spotlight.
And open preferences:
And select my Command Line Tools under "Locations".
You can install git via the brew package manager for Mac. I recommend installing software this way since it's a great way to manage your installed packages in one place. For example, you can do brew update to get a list of the latest package updates, or brew upgrade to upgrade all of your software installed through brew.
To install brew, open a terminal window and run:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Update your brew packages with brew update
Install git with brew install git
I had installed git, then returned to a terminal window open prior to the installation. I try running command git --version and this raised error message below. To resolve, I ran command source /etc/profile in same terminal window. BTW, terminal window is inside my Webstorm and my end goal is to git init and setup git for my new reactjs project. Happy coding!
The error:
xcrun: error: active developer path ("/Volumes/Xcode/Xcode.app/Contents/Developer") does not exist, use \`xcode-select --switch path/to/Xcode.app\` to specify the Xcode that you wish to use for command line developer tools (or see \`man xcode-select\`)

how to install libX11 on OSx 10.9?

I am trying to install ROOT (cern.root.ch). When I run ./configure , I get a message that libX11 is missing and must be installed.
I did some research and found that I need to install
) XQuartz (I already have the latest version.)
) Command line tools in Xcode.
I tried installing Command Line Tools from apple's developer website. The installation goes through smoothly but how do I know whether it has been installed? I still get libX11 missing error with root's configure command.
I also tried xcode-select --install and it once went through smoothly and then later again gives error saying this package is no longer maintained - or something of that sort.
I understand I may have multiple installations... But I am still facing the problem of not having libX11 and not being able to install ROOT.
Thanks,
Hershal.
This link and the one referenced in it suggests you use homebrew (brew) to install it
$ ruby <(curl -fsS https://raw.github.com/mxcl/homebrew/go)
$ brew doctor
Remember to add the Homebrew directory to your PATH by adding the directory (found with brew --prefix) to your .bashrc, .zshrc or whatever shell file you’re using (.bashrc is the OS X default). We’ll also add the XQuartz binaries to the PATH in case anything needs them in the future.
export PATH=/usr/local/bin:/opt/X11/bin:$PATH
Start a new Terminal session to pick up the changes.
Now that Homebrew is installed, we can use it to install the required dependencies. Each may take some time as Homebrew generally compiles from source.
$ brew install gfortran # Fortran compiler
$ brew install python # Python interpreter
$ brew install pcre # Regular Expressions library
$ brew install fftw # Fast Fourier Transforms
$ brew install cmake # Cross-platform make
install root
$ brew tap homebrew/science
$ brew install --with-cocoa root
You don't say whether you have installed XCode as well as the commandline tools but I think you will need it

Installing openCV 2.4.2 on Mac OS X 10.9 (Mavericks)

I'm trying to install openCV 2.4.2 (not the newest version but stable version compatible with newer OS X according to several sources) on Mac OS X 10.9 (Mavericks). I have tried installing from source and using homebrew but neither works. I get the following error when I try installing it:
build Marieke$ make
[ 25%] Building CXX object modules/ts/CMakeFiles/opencv_ts.dir/src/precomp.cpp.o
In file included from /users/Marieke/Downloads/OpenCV-2.4.2/modules/ts/src/precomp.cpp:1:
In file included from /users/Marieke/Downloads/OpenCV-2.4.2/modules/ts/src/precomp.hpp:2:
In file included from /users/Marieke/Downloads/OpenCV-2.4.2/modules/ts/include/opencv2/ts/ts.hpp:40:
/users/Marieke/Downloads/OpenCV-2.4.2/modules/ts/include/opencv2/ts/ts_gtest.h:1657:13: fatal error:
'tr1/tuple' file not found
# include <tr1/tuple> // NOLINT
^
1 error generated.
make[2]: *** [modules/ts/CMakeFiles/opencv_ts.dir/src/precomp.cpp.o] Error 1
make[1]: *** [modules/ts/CMakeFiles/opencv_ts.dir/all] Error 2
make: *** [all] Error 2
I don't know how to solve this and I have tried several things already (I do now have newest versions of Xcode, cmake, ffmpeg, faac, faad, qt, ...) so if anybody can help me, that would be much appreciated, thanks!
Run the following commands assuming you have brew installed.
brew tap homebrew/science
brew install opencv
Use macports. Once you install macports, just run
sudo port install opencv
at the command prompt.
This other stackoverflow question is mostly correct for how to start using the macports version of opencv in Xcode.
Here are some more up-to-date instructions for using the macports version of OpenCV from Xcode 5:
Create a new Xcode project as OS X Application -> Command Line Tool, etc.
Click the target in the upper left
Click the Build Settings tab
Scroll down to (or search for) the Search Paths section
Under User Header Search Paths add /opt/local/include
Click the Build Phases tab
Click Link Binary with Libraries
Choose the required libraries from /opt/local/lib
At least, add libopencv_core.dylib
If you want pre-set command-line arguments, go to Product -> Scheme -> Edit Scheme (⌘<)
Click the Run tab on the left
Click the Arguments tab
Enter arguments into Arguments Passed on Launch
Done!
You can try to install opencv from homebrew, I met the same problem with cmake in my 10.9 and finally I found the solution from Chris Muktar. Here are the steps:
Make sure xcode-select --install Xcode command line tools 5.0.1 are installed.
Install python using brew - brew install python.
pip update
pip install numpy
brew linkapps
Add export PYTHONPATH=/usr/local/Cellar/opencv/2.4.6.1/lib/python2.7/site-packages:$PYTHONPATH to .bash_profile in your home directory
brew install opencv
In the last step I came across the Error: No available formula for opencv. In this case, you should first run the command brew tap homebrew/science.
Good Luck
This may be related to the current issues with Qt on Mavericks.
See: https://github.com/mxcl/homebrew/pull/23793
I'd try installing the current patched homebrew keg for qt, and then installing opencv:
brew update
brew uninstall opencv
brew uninstall qt
brew install -v https://raw.github.com/cliffrowley/homebrew/patched_qt/Library/Formula/qt.rb --HEAD
brew install opencv
Caution to the wind: the qt build took me about an hour to complete
Thanks for the answers!
I ended up with the following solution: I added #define GTEST_USE_OWN_TR1_TUPLE 1 to ts_gtest.h. Probably not the prettiest solution but I don't need gtest for anything else so it works for me.
You could disable ts module in CMakeCache.txt file:
//Include opencv_ts module into the OpenCV build
BUILD_opencv_ts:BOOL=OFF
I mean that there is no reason to modify existing code.
I think you really need to do a configuration and that is it.
I tried your problems and I think steps are as follow:
open terminal in mac
in the terminal, check you have cmake and ccmake. If not, please type "brew install cmake"
go to your downloaded opencv folder, make a new folder by typing "mkdir build", then "cd build"
in this build folder, check you have gcc and g++ installed.
now, doing configuration by type "ccmake .. -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++", type "c" first for configuration then exit by "e" then "g" for generating!
you should be in terminal again now! then please type "make"
type "sudo make install", and now the opencv is installed, check it by type "brew list", and you should see the opencv there
type "brew linkapps"
do a test if you have python, by typing "import cv", and it should be working!

Unable to get MacPort functionality after installing Xcode 4.3

I am having trouble getting MacPorts to function properly. I just installed OSX Lion 10.7.3 I downloaded and installed MacPorts first, and then after reading the requirements, I downloaded Xcode4.3 from the App Store, and then installed it. I launched Xcode and it looks to be operational and functional. However when I attempted to port with MacPorts, it gave me this error message(excerpt):
Warning: xcodebuild exists but failed to execute
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
I followed the advice from:
How do i install additional packages for Xcode on OSX Lion to allow MacPorts to work
and installed command_line_tools_for_xcode from the Preferences within Xcode. I closed Xcode, and again got the errors:
$ sudo port install libsocketsPassword:
Warning: xcodebuild exists but failed to execute
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
---> Computing dependencies for libsockets
---> Dependencies to be installed: openssl zlib
---> Extracting zlib
Error: Couldn't determine your Xcode version (from '/usr/bin/xcodebuild -version').
Error:
Error: If you have not installed Xcode, install it now; see:
Error: http://guide.macports.org/chunked/installing.xcode.html
Error:
Error: Target org.macports.extract returned: unable to find Xcode
Error: Failed to install zlib
Log for zlib is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_zlib/zlib/main.log
Error: The following dependencies were not installed: openssl zlib
Error: Status 1 encountered during processing.
I am uncertain where to go next with this. How do i trouble shoot my Xcode and MacPort interface?
In theory this should work if you have Xcode4.3 installed (in /Applications):
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/
(And you've installed the optional command line tools)
Everything will start working fine after installation of "Command Line Tools for Xcode" package.
You can get it from here: https://developer.apple.com/downloads/index.action#
Please see the MacPorts migration instructions for Xcode 4.3.
The instructions are pretty involved. You need to run xcode-select to set a new tools path, update developer_dir in macports.conf (as described by Henk Poley), re-install MacPorts (ouch), and finally uninstall and re-install all of your ports (double ouch).
Edit: libpvx still wouldn't install after the above. Two extra steps were required:
sudo ln -s /Developer /
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs /SDKs
YMMV if you have different ports installed!
Also in /opt/local/etc/macports/macports.conf change the line with developer_dir to point to / instead of /Developer.
After
sudo xcode-select -switch /Applications/Xcode.app
I also had to run
sudo xcodebuild -license
and accept the licence
Here is a solution that has worked for me:
Install Command Line Tools for Xcode
Xcode -> Preferences -> Downloads
Help MacPorts find the right Xcode folder
sudo /usr/bin/xcode-select -switch /Applications/Xcode.app
Create symbolic links for clang compilers as they now live elsewhere
sudo ln -s `which clang` /Applications/Xcode.app/Contents/Developer/usr/bin/
sudo ln -s `which clang++` /Applications/Xcode.app/Contents/Developer/usr/bin/
Try using trunk, there's no release supporting Xcode 4.3 yet.
Setting the developer path in /opt/local/etc/macports.conf works for me,
developer_dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
since most of the compilers are stored there now instead of /usr/bin under Developer.
None of this works for me. Wait for macports to release a new version that officially supports XCode 4.3+
sudo mv /usr/bin/xcodebuild /usr/bin/xcodebuild.old
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild /usr/bin/xcodebuild
Starting with Xcode 4.3, the command-line build tools are not installed by default. Launch Xcode, open the Preferences, and go to the Downloads tab. From there you should have an option to install the command-line tools.
You can also download them from the web here: https://developer.apple.com/downloads/index.action
Disclaimer: I haven't installed Xcode 4.3 yet. I have only read about it on the web.
As of 27/2/2012, the official suggestion from MacPorts seems to be to not use XCode 4.3 and instead use 4.1 through 4.2.1, which can be downloaded from Apple.
There is a bug ticket which might be useful to follow the evolution of this.
Incidentally, and as reported in my comment #11 in that bug report, I am able to build ports without warnings by using the 2 most sane-looking suggestions found in this question: sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer and changing developer_dir in /opt/local/etc/macports/macports.conf to /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
I have macports installed without admin/root privileges, so I was unable to test the xcode-select answers. However, I observed that Pall Melsted's answer worked, but not initially. What I found out was that I had not accepted the Xcode 4.5 license agreement!
If you have just installed Xcode for the purposes of macports, and you haven't accepted the Xcode license yet, you might get the error presented by the original post. When I checked my Xcode version using /usr/bin/xcodebuild -version, I was given the prompt to read and accept the license. After doing so, and after having made the changes suggested by Pall to the macports.conf developer_dir, it all works now.
As alternative: you can make downgrade of Xcode to 4.2.1 version. DMG of Xcode 4.2.1 placed here: https://developer.apple.com/downloads/index.action
After this MacPorts became works fine for me.
This is fixed in MacPorts 2.0.4.
To upgrade:
Download MacPorts 2.0.4 from the install site or run sudo port selfupdate.
Run the MacPorts migration described here to reinstall all ports. This is painful but required to get back to a working state.
You should definitely run sudo xcode-select -switch /Applications/Xcode.app like everyone here says, that'll fix many problems, but certainly not all.
Afaik, all the remaining problems exist within the configuration information for various packages. You might simply reinstall MacPorts as described in the migration instructions, but I found another solution.
You should begin finding all effected port files using commands like grep /Developer/ ..., after executing sudo bash and cd /opt/local naturally.
You should identify all effected ports by using port provides ..., which I piped through sed and sort | uniq. You could simply reinstall all these ports using either port -n upgrade --force ... or separate port uninstall ... and port install ... commands.
I recommend using one large port -n upgrade --force ... command to avoid duplicate rebuilds of dependencies, using the separate uninstall and install commands afterwards.
There are of course various ports for which /Developer exists only inside text config files, meaning you can fix them manually with sed -i -e 's/\/Developer//g' ..., but you cannot do so with binaries obviously.
I'm afraid you must at minimum rebuild all your Python and Perl installations, making this upgrade an ideal time to clean out packages that depend upon older versions, ala python26 and perl5.8.
There are several technically effected ports I decided against rebuilding like fuse4x-kext, who contained /Developer inside Library/Extensions/fuse4x.kext/Contents/MacOS/fuse4x but hasn't prevented sshfs from working correctly.
I had initially installed xcode 3.2.2, after which I installed 4.3. When I ran the xcode-select, I still got the same error about no xcode project in /Applications. I then dug into the /usr/bin/xcodebuild script and found out that this was working correctly, and another instance of xcodebuild (the one installed with xcode 4.3, not the one in /usr/bin) was being run and returning the error:
xcodebuild: error: The directory /Applications does not contain an Xcode project.
It seems the /usr/bin/xcode-select does not work for xcode 4.3, (it's compiled so you can't really see why it's not working). Strings doesn't give any clues. Good thing osx has strace.. oh wait.
Anyways, the best I could do was modify /opt/local/etc/macports.conf
and uncomment the line containing the path to the xcode installation. That seems to fix my problem for the most part.

Resources