External Build Projects
Stay organized with collections
Save and categorize content based on your preferences.
External make files can be used with Xcode, using an External
Build System project template. These files can be modified to take advantage
of Xcode project settings, such as the build type and location, while still
useful when used separately.
Create an External Project
To create a new external build project, in Xcode select the New->New Project...
dialog, then select the External Build System template. Put the project in
the same directory as the target Makefile.
Add Xcode Build Settings
When invoking an external build, Xcode defines environment variables for its
build settings.
These settings define where build files are created, as well as compiler and
linker flags. We use Make's conditional directives
to modify the build when it is invoked by Xcode.
Here's an example, where the variables being set (such as BUILD_DIR) can be
whatever name you want, while the conditionals use the environment variables
Xcode set:
ifdef CONFIGURATION_BUILD_DIR
# In Xcode build
BUILD_DIR = $(CONFIGURATION_BUILD_DIR)/build
ARCHFLAGS = $(ARCHS:%=-arch %)
SDKFLAGS = -isysroot $(SDKROOT)
else
# In command-line build
BUILD_DIR = $(HOME)/build
ARCHFLAGS =
SDKFLAGS =
endif
ifdef OPTIMIZATION_LEVEL
DEBUGFLAGS := $(DEBUGFLAGS) -O$(OPTIMIZATION_LEVEL)
endif
ifdef OTHER_CFLAGS
DEBUGFLAGS := $(DEBUGFLAGS) $(OTHER_CFLAGS)
endif
# Workaround for iPhoneSimulator SDK's gcc bug
ifdef EFFECTIVE_PLATFORM_NAME
ifneq ($(EFFECTIVE_PLATFORM_NAME), -iphonesimulator)
WARNINGS := $(WARNINGS) -Wreturn-type
endif
endif
J2OBJCC_FLAGS = $(WARNINGS) $(SDKFLAGS) $(ARCHFLAGS) $(DEBUGFLAGS)
J2OBJCC = $(J2OBJC_DIST)/j2objcc $(J2OBJCC_FLAGS)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eXcode can be used with external Make files using the External Build System project template.\u003c/p\u003e\n"],["\u003cp\u003eXcode build settings such as build type and location can be utilized within Make files using conditional directives.\u003c/p\u003e\n"],["\u003cp\u003eMake files can be adapted to function effectively both within Xcode and independently.\u003c/p\u003e\n"],["\u003cp\u003eThis setup allows for greater control and flexibility in building projects using j2objc.\u003c/p\u003e\n"]]],[],null,["# External Build Projects\n\nExternal [make files](/j2objc/guides/using-j2objc-with-make) can be used with Xcode, using an External\nBuild System project template. These files can be modified to take advantage\nof Xcode project settings, such as the build type and location, while still\nuseful when used separately.\n\nCreate an External Project\n--------------------------\n\nTo create a new external build project, in Xcode select the New-\\\u003eNew Project...\ndialog, then select the External Build System template. Put the project in\nthe same directory as the target Makefile.\n\nAdd Xcode Build Settings\n------------------------\n\nWhen invoking an external build, Xcode defines environment variables for its\n[build settings](http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html).\nThese settings define where build files are created, as well as compiler and\nlinker flags. We use Make's [conditional directives](http://www.gnu.org/software/make/manual/make.html#Conditionals)\nto modify the build when it is invoked by Xcode.\n\nHere's an example, where the variables being set (such as BUILD_DIR) can be\nwhatever name you want, while the conditionals use the environment variables\nXcode set: \n\n ifdef CONFIGURATION_BUILD_DIR\n # In Xcode build\n BUILD_DIR = $(CONFIGURATION_BUILD_DIR)/build\n ARCHFLAGS = $(ARCHS:%=-arch %)\n SDKFLAGS = -isysroot $(SDKROOT)\n else\n # In command-line build\n BUILD_DIR = $(HOME)/build\n ARCHFLAGS =\n SDKFLAGS =\n endif\n\n ifdef OPTIMIZATION_LEVEL\n DEBUGFLAGS := $(DEBUGFLAGS) -O$(OPTIMIZATION_LEVEL)\n endif\n\n ifdef OTHER_CFLAGS\n DEBUGFLAGS := $(DEBUGFLAGS) $(OTHER_CFLAGS)\n endif\n\n # Workaround for iPhoneSimulator SDK's gcc bug\n ifdef EFFECTIVE_PLATFORM_NAME\n ifneq ($(EFFECTIVE_PLATFORM_NAME), -iphonesimulator)\n WARNINGS := $(WARNINGS) -Wreturn-type\n endif\n endif\n\n J2OBJCC_FLAGS = $(WARNINGS) $(SDKFLAGS) $(ARCHFLAGS) $(DEBUGFLAGS)\n J2OBJCC = $(J2OBJC_DIST)/j2objcc $(J2OBJCC_FLAGS)"]]