A single project can contain multiple targets; the currently active target determines how your project is built. This topic describes how to build the target using the Xcode IDE and also documents the build steps using the command line.
Select the target to be built in the Active Target drop-down menu in the toolbar. Choose Build from the Build menu or click the Build and Go button in the toolbar. To view the results of your build, choose Build Results from the Build menu in the Xcode toolbar.

To build an individual file and not the entire project, select the file under the target and then choose Compile from the Action drop-down menu in the toolbar.
You can change the compilation order of the files in an Xcode target. This is especially useful for compiling Fortran sources that define modules (producing .MOD files). These can, in turn, be used by Fortran sources that use the modules. To re-order the files listed under a target's Compile Sources build step, click a source and drag it before or after other compilations.
You can also use the xcodebuild utility to build a target. This utility uses the project settings in the Xcode IDE to build target projects from the command line. If you have previously configured your Xcode project to build with the Intel compiler, xcodebuild will invoke that compiler from the command line. The basic steps are as follows:
Check that the Xcode project is configured to use the Intel Fortran compiler.
Launch a terminal window by selecting Finder>Applications>Utilities>Terminal.
Change directories to the directory containing the Xcode project file.
If you have multiple versions of Xcode, use the xcode-select utility to verify the current Xcode version.
Issue an xcodebuild command similar to the following:
xcodebuild -project test2.xcodeproj -target testapp -configuration
Debug
To run the program, type the following:
./build/Debug/testapp
For more information, refer to the xcodebuild man page.
To build a 64-bit executable from within the Xcode IDE, edit the executable's target to change the Architectures setting to x86_64 (you may need to manually enter this selection). This produces a 64-bit binary for Intel® 64 architecture.
The Intel Fortran Compiler generates code solely for Intel architectures.
If you select more than one architecture in your build configuration, a universal binary containing the executables for all the selected architectures is created.
For example, for the Release configuration, if you set the architecture property to the value i386 x86_64, then binaries for both the IA-32 and Intel® 64 architectures are created and put into the executable.
To select an architecture, use the Architectures setting in the Architectures category at the very top of the list of Build properties.
To build a binary executable from HelloWorld.f90:
PROGRAM HelloWorld
IMPLICIT NONE
#if defined( __i386__)
#define _PLATFORM_ "IA32"
#elif defined(__x86_64__)
#define _PLATFORM_ "Intel(R) 64"
#else
#define _PLATFORM_ "????"
#endif
WRITE( *, * ) "Hello, ", _PLATFORM_, " World"
END PROGRAM HelloWorld
The steps are as follows:
Invoke
the compiler with the -m32 option and generate
the object file HelloWorld_32:
ifort -m32 -o HelloWorld_32 HelloWorld.f90
Invoke
the compiler with the -m64 option and generate
the object file, HelloWorld_64:
ifort -m64 -o HelloWorld_64 HelloWorld.f90
Use the lipo
utility to create the universal executable HelloWorld
from the two object files:
lipo -create -arch i386 HelloWorld_32 -arch x86_64 HelloWorld_64 -output
HelloWorld
To confirm that your process generates the correct result for both architectures, run the file utility on your universal binary:
file HelloWorld
HelloWorld: Mach-O universal binary with 2 architectures
HelloWorld (for architecture i386):Mach-O executable i386
HelloWorld (for architecture x86_64): Mach-O 64-bit executable x86_64
The compiler defines the __x86_64__ macro on Intel® 64 architecture only. So, if you execute the universal binary, hello, on a system based on Intel® 64 architecture, the output will be:
Hello, Intel(R) 64 World
On a system based on IA-32 architecture, the output of the program will be:
Hello, IA32 World