QGIS Xcode Project
Developer Notes

Sources

• Adding sources and other files and folders to the project.

Always use Relative to Project reference type.

Cmake files can't be used to dynamically generate source lists in the Xcode targets.  Any additions and deletions of source files in the cmake configuration must be manually mirrored in the Xcode project.

• Layout

Configuration Files - Xcode config files.  dependency config, system target, core moc lists set here.
Sources - standard Qgis sources
generated - intermediate sources generated by bison, flex, moc, uic, rcc in script phases.  Subfolders will start empty of files, and contents appear red in the project until generated.

• Custom Rules

- moc

source file names matching: *.h
script: $QTMOC $QT_CXXFLAGS -o "$DERIVED_FILES_DIR/moc_$INPUT_FILE_BASE.cpp" "$INPUT_FILE_PATH"
with output files: $(DERIVED_FILES_DIR)/moc_$(INPUT_FILE_BASE).cpp

- qrc

sources: *.qrc
script: $QTRCC -name $INPUT_FILE_BASE -o "$DERIVED_FILES_DIR/qrc_$INPUT_FILE_BASE.cpp" "$INPUT_FILE_PATH"
output: $(DERIVED_FILES_DIR)/qrc_$(INPUT_FILE_BASE).cpp

- ui

do ui generation in a script phase because:

	- Xcode will attempt to process generated *.h with moc rule
	- parallel processing might not finish ui's before a cpp source needs it

plugins need a user-defined setting to set the TARGET_PLUGINDIR of the plugin.

• Header paths

- to access ui headers in qgis_gui from other targets:

"$(TARGET_TEMP_DIR)/../qgis_gui.build/DerivedSources"

Targets

There is no way to conditionaly compile whole targets, or individual sources.  So fo now, all conditional sources are required.  Conditional targets must be built manually.

Linked libraries can be conditionalized in the config file.

Sources can be conditionalized inside the source, with one big #ifdef block.

Another possibility is to indirectly add sources in a script phase as generated - copy the true source if condition true, dump dummy empty source if false.  The target always compiles the generated source.  Wouldn't work for whole targets, as bogus binary is generated.

Targets can be destructive (most are) - for example, everything is built directly into the application bundle, which is really the domain of the Qgis.app target.  This simplifies packaging for optional plugins.  This means that if just the app target is cleaned, all link and copy phases of all other targets must be redone.

The app target must be built last.  This is so that the Qt bundling phase install_name_tool step will get all built libraries and plugins.  Also, the bundled and stripped-of-headers Qt frameworks would interfere with building all other targets.

libqgispython must be in MacOS/lib.  Qgis attempts to load it dynamically, with a hardwired path.

Adding Providers and Plugins (C++)

1. Add sources to project

2. Duplicate provider or plugin template target and rename

3. Add sources to target

4. Edit target settings (make sure to change both Debug and Release configurations):

	a. Product Name
	b. Header Search Paths - add extra source folders needed, and config _INC vars
	c. Other Linker Flags - add config *_LIB vars as needed
	d. Preprocessor Macros - add extra defs if needed
	e. TARGET_PLUGINDIR - name of folder of plugin source

- William Kyngesburye
kyngchaos@kyngchaos.com
http://www.kyngchaos.com/