projectGenerator
projectGenerator copied to clipboard
Revisiting absolute path in macOS and Xcode. Fs and machine agnostic project generation.
Hi,
macOS, Xcode
Through years I have avoided projectGenerator both as it did not handle absolute paths as well as everybody has (don't we 😄 ) clean project templates ready. Revisited it yesterday (used projectGenerator of_v0.9.8_osx_release against current oF master branch) to see how it handles absolute paths. It still generates relative paths in some places, but is easily find-replace correctable now.
To correct it:
- Let us assume situation where absolute
OF_PATH
is/symlinks/oF/openFrameworks
. In my case it is actually symlink to/abs/path/to/openFrameworks
(this is the way I manage working on same project on different machines (project is synced via cloud services), all machines have same symlinks, although/abs/path/to/openFrameworks
differ among them). - In projectGenerator settings openFrameworks path is set to
/symlinks/oF/openFrameworks
before generating project (or real absolute path) - Project mySketch is generated wherever on filesystem.
- After project mySketch is generated following changes (change relative paths to absolute) have to be made manually so that mySketch can be freely moved across file system (or in my case across machines). 4 changes across 2 files for project with no addons.
mySketch/Project.xconfig
// ...
OF_PATH = /symlinks/oF/openFrameworks
// ...
#include " /symlinks/oF/openFrameworks/libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
// ...
mySketch/mySketch.xcodeproj/project.pbxproj
// ...
<string>/symlinks/oF/openFrameworks/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj</string>
// ...
<string>/symlinks/oF/openFrameworks/libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig</string>
// ...
mySketch/mySketch.xcodeproj/project.pbxproj
When addons are chosen to be included in the project they also get relative paths in mySketch/mySketch.xcodeproj/project.pbxproj
for links to sources (code and header files) as well as OTHER_LDFLAGS
and HEADER_SEARCH_PATHS
. For example <string>../../../../symlinks/oF/openFrameworks/addons/ofxGui/src</string>
. (Checkbox to enable copying addons to mySketch/addons
and link against them, not linking against global oF addons dir, is yet another topic).
(mySketch/config.make
and mySketch/makefile
also have relative paths there, but it is not applicable to Xcode).
I quickly looked at projectGenerator source, but it is not so easy to follow.
Maybe somebody currently working in it (@arturoc seems active lately 😄 ) can point where to look
https://github.com/openframeworks/projectGenerator/blob/master/ofxProjectGenerator/src/projects/xcodeProject.cpp#L378 ?
https://github.com/openframeworks/projectGenerator/blob/master/frontend/index.js#L113 ?
/ or solve it in the 2 files (mySketch/Project.xconfig
and mySketch/mySketch.xcodeproj/project.pbxproj
) mentioned ? Note that I am using v0.9.8 which is the suggested way.
Thanks!
can you check first that this still is the case with the nightly builds? the project generator in 0.9.8 is about 2 years old already so this might have been fixed in that time.