I have a Xcode project for a mac app that contains another project for a helper app to launch the main app at login. Is there a way I can base the bundle identifier of the helper app off of the main app with a project variable like ${PRODUCT_NAME}
but something like ${ROOT_PRODUCT_IDENTIFIER}
?
So the main app's bundle identifier would be:
com.mydomain.app
and the helper app's bundle identifier would be:
${ROOT_PRODUCT_IDENTIFIER}.Helper
→ com.mydomain.app.Helper
My goal with this is to create a really easy to use generic launch at login helper app that any mac app can use, I've got it working in this repo but it requires a couple values to be changed: https://github.com/kgn/LaunchAtLoginHelper
I'm afraid the variable you're looking for doesn't exist, have a look here or here
But I can think of one workaround by creating your own environment variable, which isn't difficult. In order to achieve what you want, create a build script for your main project that extracts the identifier and saves it to an environment variable.
Go to your main project's target and click on Add Build Phase -> Add Run Script. In the shell box that appears, type this in:
ROOT_PRODUCT_IDENTIFIER_PLIST=`/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" $INFOPLIST_FILE`
export ROOT_PRODUCT_IDENTIFIER=`eval echo $ROOT_PRODUCT_IDENTIFIER_PLIST`
Now go to your helper's project and reference $(ROOT_PRODUCT_IDENTIFIER) in its plist/build settings.
Remember to add your main project as a dependency for the latter, so that variable is always set by the time its needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With