In my Xcode 4 installation, I only have 2 compiler options:
Apple LLVM compiler 3.0
GCC LLVM 4.2
In many Xcode examples I have seen that GCC 4.2 is shown as a third option, but this simply isn't there. I intentionally did a clean installation of XCode 4. Is there a standard method for adding GCC 4.2 if it's not already there? One of my projects requires that I use GCC (and not GCC LLVM), the other projects I am happy with GCC LLVM, so it's only an issue for that one.
Here is a way to enable compiling with gcc 4.2 in xcode 4.2. This is mostly done via command line so when you see lines starting with: [ 15:30 jon#MacBookPro / ]$, you need to open up Terminal.app and run the command that starts after the $.
No files or directories are removed or deleted in this process, so it is easy to undo if you need to compile with LLVM in the future.
Download - but do not install yet - xcode_4.1_for_lion.dmg or xcode_4.1_for_snow_leopard.dmg
Now, follow these steps to install Xcode 4.1 into /Developer-4.1:
Backup the working /Developer directory (where Xcode 4.2 is installed)
[ 15:30 jon#MacBookPro / ]$ sudo mv -v /Developer /Developer-4.2
Run the Xcode 4.1 installer using the default install location (/Developer)
Move the new Xcode 4.1 installation to /Developer-4.1:
[ 15:30 jon#MacBookPro / ]$ sudo mv -v /Developer /Developer-4.1
Move the Xcode 4.2 developer directory back to /Developer:
[ 15:30 jon#MacBookPro / ]$ sudo mv -v /Developer-4.2 /Developer
Edit the Xcode 4.2 GCC 4.2.xcspec file to get gcc 4.2 to show in the list of compiler options [1]:
[ 15:30 jon#MacBookPro / ]$ sudo vi "/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/GCC 4.2 (Plausible Blocks).xcplugin/Contents/Resources/GCC 4.2.xcspec"
Change lines 41 and 42 from this:
ShowInCompilerSelectionPopup = NO;
IsNoLongerSupported = YES;
To This:
ShowInCompilerSelectionPopup = YES;
IsNoLongerSupported = NO;
Backup the Xcode 4.2 iOS/Simulator Framework usr directories:
[ 15:30 jon#MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform/Developer/usr.backup
[ 15:30 jon#MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneSimulator.platform/Developer/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr.backup
Copy Xcode 4.1 iOS/Simulator Framework usr directories to Xcode 4.2:
[ 15:30 jon#MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform/Developer/usr
[ 15:30 jon#MacBookPro / ]$ sudo cp -rv /Developer-4.1/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr
Copy the gcc and info iOS SDK library directories from Xcode 4.1 to Xcode 4.2 [2]:
[ 15:30 jon#MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/gcc /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/gcc
[ 15:30 jon#MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/info /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/info
Compile using gcc-4.2!
This is a blog post I've written with a little more info about this process. Feel free to leave a comment on the blog if you run into any issues or have any questions.
[1] If opening from a command line (using something like vi, emacs, nano, etc) make sure to either enclose the path in quotes "/long path/with spaces/in it/file.xcspec" or escape the spaces /some/long\ path/with\ spaces/in\ it/file.xcspec
[2] This is necessary because the iPhoneOS.platform SDK has its own seperate /usr/lib directories but the iPhoneSimulator.platform SDK does not
Xcode 4.3 has a specific folder /Applications/Xcode.app/Contents/Developer/Toolchains.
Is there a way to add other tool-chains as AVR-gcc and PIC32-gcc?
Related
I am using Xcode command line tools instead of XCode app in my MAC.
When i use swift --version
I get Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51)
I cloned a project with
git clone https://github.com/apple/example-package-dealer.git
cd example-package-dealer
swift run Dealer
I gives me this error:
error: terminated(72): OLDPWD=/Users/sayansen/Work/EdgeAnalytics/Trial TERM_PROGRAM=Apple_Terminal PWD=/Users/sayansen/Work/EdgeAnalytics/Trial/example-package-dealer SHLVL=1 SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.9lwBmlYTAx/Listeners HOME=/Users/sayansen LIBRARY_PATH=/usr/local/lib __CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0 XPC_SERVICE_NAME=0 TMPDIR=/var/folders/kn/v4zm474x52n8zrycxs7nh5c40000gn/T/ LOGNAME=sayansen SHELL=/bin/bash TERM_PROGRAM_VERSION=433 _=/usr/bin/swift PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS CPATH=/usr/local/include SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk XPC_FLAGS=0x0 TERM=xterm-256color USER=sayansen LC_CTYPE=UTF-8 TERM_SESSION_ID=B285E686-2802-48C6-B8CE-03CA8F2314BF xcrun --sdk macosx --find xctest output:
xcrun: error: unable to find utility "xctest", not a developer tool or in PATH
I am not using XCODE.
I already did this:
sudo xcode-select -s /Library/Developer/CommandLineTools
But not helpfull.
How to solve this error without installing XCode?
Assuming you already have Xcode installed:
Start Xcode, select "Preferences -> Locations". Chances are that your Command Line Tools are not set. Select the suggested Xcode-tools location and you are done.
Additional:
You could check with:
xcode-select -p
which tools are set, mine showed:
/Library/Developer/CommandLineTools
After the location in the preferences was set, it showed:
/Applications/Xcode.app/Contents/Developer
(as it should)
Xcode -> Preferences (or command+,)
Locations tab -> Command Line tools section:
Select a tool there and you are done.
Just a wrong path, all the stuff still can be done w/o invoking GUI:
~/% sudo xcode-select -s /Library/Developer/CommandLineTools
~/% sudo xcode-select -p
/Library/Developer/CommandLineTools
~/% sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
~/% sudo xcode-select -p
/Applications/Xcode.app/Contents/Developer
The latest -s command fixes xcrun: error: unable to find utility "xctest" …
Alright guys, I posted a similar question and took it down because it wasn't specific enough so here I go. From the zip file of Freetype 2.6.5 I have not been able to create an Xcode project that will compile the library for iOS use, only for i386_64.
I tried the commands here but I don't get past the first commands the and I am getting this
FreeType build system -- automatic system detection
The following settings are used:
platform unix compiler cc
configuration directory ./builds/unix configuration rules
./builds/unix/unix.mk
If this does not correspond to your system or settings please remove
the file `config.mk' from this directory then read the INSTALL file
for help.
Otherwise, simply type
/Applications/Xcode.app/Contents/Developer/usr/bin/make' again to
build the library, or
/Applications/Xcode.app/Contents/Developer/usr/bin/make refdoc' to
build the API reference (this needs python >= 2.6).
cd builds/unix; \
./configure 'CFLAGS=-arch i386' /bin/sh: ./configure: No such file or directory make: *** [setup] Error 127
I also followed the instructions inside the cmakelists.txt that it comes inside the project but still nothing, I still get an xcode project for osx and not for IOS which is giving me a plethora of linking errors. Here is the instructions for your reference.
For an iOS static library, use
#
cmake -D IOS_PLATFORM=OS -G Xcode
#
or
#
cmake -D IOS_PLATFORM=SIMULATOR -G Xcode
I am not sure what else to do. Any help?
Here's an outline of the basic build process to compile the FreeType libaries for iOS:
Download the latest FreeType source code
Extract the archive and cd into the unarchived directory
Setup toolchain and export variables for the architectures desired (arm64, arm7, i386, x86_64)
Compile the source code and build the libraries
For example, the build commands for arm64 might look something like this:
$ export CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
$ iphoneos="7.0" # target version of iOS
$ ARCH="arm64" # architecture (arm64, arm7, i386, x86_64)
$ export CFLAGS="-arch ${ARCH} -pipe -mdynamic-no-pic -Wno-trigraphs -fpascal-strings \
-O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden \
-miphoneos-version-min=$iphoneos -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2 \
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
$ export AR="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar"
$ export LDFLAGS="-arch ${ARCH} -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
-miphoneos-version-min=7.0"
$ ./configure --host="aarch64-apple-darwin" --enable-static=yes --enable-shared=no
$ make
$ clean
It's a bit of work to construct the commands for each arch, but
fortunately there's a build
script
— which automatically downloads, extracts, and builds the latest FreeType (2.6.5 currently).
To run the script just use the following command in Terminal:
./build_freetype.sh
The resulting iOS libraries can be found in ~/Desktop/FreeType_iOS_Release when it completes.
I need to use gcc 4.2 with Xcode 4.2 for some older code. How do i get it to show
up. Xcode4.2 seems to have dropped support for it.
Thanks
Here is a way to enable compiling with gcc 4.2 in xcode 4.2. This is mostly done via command line so when you see lines starting with: [ 15:30 jon#MacBookPro / ]$, you need to open up Terminal.app and run the command that starts after the $.
No files or directories are removed or deleted in this process, so it is easy to undo if you need to compile with LLVM in the future.
Download - but do not install yet - xcode_4.1_for_lion.dmg or xcode_4.1_for_snow_leopard.dmg
Now, follow these steps to install Xcode 4.1 into /Developer-4.1:
Backup the working /Developer directory (where Xcode 4.2 is installed)
[ 15:30 jon#MacBookPro / ]$ sudo mv -v /Developer /Developer-4.2
Run the Xcode 4.1 installer using the default install location (/Developer)
Move the new Xcode 4.1 installation to /Developer-4.1:
[ 15:30 jon#MacBookPro / ]$ sudo mv -v /Developer /Developer-4.1
Move the Xcode 4.2 developer directory back to /Developer:
[ 15:30 jon#MacBookPro / ]$ sudo mv -v /Developer-4.2 /Developer
Edit the Xcode 4.2 GCC 4.2.xcspec file to get gcc 4.2 to show in the list of compiler options [1]:
[ 15:30 jon#MacBookPro / ]$ sudo vi "/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/GCC 4.2 (Plausible Blocks).xcplugin/Contents/Resources/GCC 4.2.xcspec"
Change lines 41 and 42 from this:
ShowInCompilerSelectionPopup = NO;
IsNoLongerSupported = YES;
To This:
ShowInCompilerSelectionPopup = YES;
IsNoLongerSupported = NO;
Backup the Xcode 4.2 iOS/Simulator Framework usr directories:
[ 15:30 jon#MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform/Developer/usr.backup
[ 15:30 jon#MacBookPro / ]$ sudo mv -v /Developer/Platforms/iPhoneSimulator.platform/Developer/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr.backup
Copy Xcode 4.1 iOS/Simulator Framework usr directories to Xcode 4.2:
[ 15:30 jon#MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/usr /Developer/Platforms/iPhoneOS.platform/Developer/usr
[ 15:30 jon#MacBookPro / ]$ sudo cp -rv /Developer-4.1/usr /Developer/Platforms/iPhoneSimulator.platform/Developer/usr
Copy the gcc and info iOS SDK library directories from Xcode 4.1 to Xcode 4.2 [2]:
[ 15:30 jon#MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/gcc /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/gcc
[ 15:30 jon#MacBookPro / ]$ sudo cp -rv /Developer-4.1/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/info /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/info
Compile using gcc-4.2!
This is a blog post I've written with a little more info about this process. Feel free to leave a comment on the blog if you run into any issues or have any questions.
[1] If opening from a command line (using something like vi, emacs, nano, etc) make sure to either enclose the path in quotes "/long path/with spaces/in it/file.xcspec" or escape the spaces /some/long\ path/with\ spaces/in\ it/file.xcspec
[2] This is necessary because the iPhoneOS.platform SDK has its own seperate /usr/lib directories but the iPhoneSimulator.platform SDK does not
So the full process for getting gcc 4.2 to work with a fresh install of Xcode 4.2 (non-iOS) is:
Install gcc 4.2
sudo port install apple-gcc42
Tweak Xcode so that gcc 4.2 appears as a compiler option, by editing the Xcode 4.2 GCC 4.2.xcspec file to get gcc 4.2 to show in the list of compiler options:
Open the xcspec file for editing:
sudo vi "/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/GCC 4.2.xcplugin/Contents/Resources/GCC 4.2.xcspec"
Change lines 41 and 42 from this:
ShowInCompilerSelectionPopup = NO;
IsNoLongerSupported = YES;
To This:
ShowInCompilerSelectionPopup = YES;
IsNoLongerSupported = NO;
Link the gcc 4.2 binary to the location that Xcode expects:
sudo ln -s /opt/local/bin/gcc-apple-4.2 /Developer/usr/bin/gcc-4.2
sudo ln -s /opt/local/bin/g++-apple-4.2 /Developer/usr/bin/g++-4.2
I explained the problem and workaround in this blog post, which condenses the information I found. Feel free to comment.
Thanks chown for sharing this! I struggled around half a day, but at the end it turned out, that I only needed a few steps to achieve my goal:
For everyone that just needs GCC-4.2 to compile apps (no iOS stuff) it's pretty easy:
You don't need to install anything just follow these few steps:
EDIT: If you don't have GCC 4.2 installed already (from an earlier version of Xcode, or manual install), follow the instruciotns from Sean DeNigris in the comments!
Follow step 3 from the original description:
Edit the Xcode 4.2 GCC 4.2.xcspec file to get gcc 4.2 to show in the list of compiler options.
Make Xcode find the compiler again:
ln -s /usr/bin/gcc-4.2 /Developer/usr/bin/gcc-4.2
Also make the linker available:
ln -s /usr/bin/g++-4.2 /Developer/usr/bin/g++-4.2
This works perfectly for me! But as I said it's just for non iOS products!
Simple and userful solution https://github.com/kennethreitz/osx-gcc-installer/
It automates the lists of the declaration on the stackoverflow
After i updated iPhone SDK to 4.1 I can no longer compile neither for Simulator or Device. I get the following message:
error: can't exec '/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2' (No such file or directory)
Solution for this?
Check to see if it is there and accessible, sudo ls -l /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2. Mine has these permissions: -rwxr-xr-x 1 root wheel 166128 Jul 26 15:05 /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2
Have you tried reinstalling yet?
I solved this by doing:
sudo cp /usr/bin/gcc-4.2 /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2
I had this happen to me. So for xcode 3.2.5:
gcc-4.2 is definitely installed by
the installer. ie:
ls /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g* =>
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.0
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2
Randomly linking in the gcc-4.2 from
the /usr/bin directory is just asking for trouble. That's not the gcc that is part of the xcode package - who knows if it is really the same version.
Reinstalling fixed it for me,
although I was finding that
particular install flakey.
I used to be able to run my application on my iPhone that was running 3.0. After I updated to 3.0.1 I get the error:
No Provisioned iPhone OS Device is Connected.
I followed Apple's guide in the terminal:
ln -s /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0\ \(7A341\) /
Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0.1
but that didn't help.
Make sure that you don't paste it into Terminal as you currently have it (and as Apple have it in their PDF). It should be one line, not two.
ln -s /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0\ \(7A341\) /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0.1
not
ln -s /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0\ \(7A341\) /
Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0.1
Allow you need to do is duplicated the folder at /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0\ \(7A341\) and rename it to 3.0.1