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.

• Generated sources

Xcode doesn't handle its dependency calculations well with intermediate sources created with custom rules (needed for bison, flex, moc, uic, rcc).  The result is excessive recompilation.  bison and flex need custom rules, though there are Xcode rules for those, because those don't handle C++ file extensions.

So, script phases are used instead and timestamps are compared manually in them.

• Adding core/gui/app moc sources

1. add source to moc_sources.xcconfig

2. build the moc target only

3. find the new moc source in the 'generated' subfolder in the project folder in the Finder.  Drag it into the project's corresponding 'generated/*' folder (remember to add relative to project).

4. add this source to the corresponding core/gui/app target

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 conditionalize 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.

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. Edit Generate Sources phase script
	- set QTUIC_FILES to names of ui files without extensions
	- set QTMOC_FILES to names of moc files without extensions
	- set QTRCC_FILE to name of qrc file without extension
	- set LIBNAME and DIRNAME
	- set LIBTYPE

4. if any of moc/uic/rcc have files to process:

	a. Build target (without sources) to generate sources.

	b. Drag folder created into project generated group (add as relative to project).

	c. add rm command to extra clean target script.

5. Add sources to target

6. Edit target settings:

	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

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