2

I've an Xcode iOS project with two targets. Each of these targets includes a third target which is an iOS Extension (Widget). Is there a way to update the Widget build settings based on the choosen build target?

I've already setup some pre-actions in the Xcode target build scheme to update the Info.plist file of the Widget with the parent bundle identifier:

# BundleIdentifier
bundleIdentifier=${PRODUCT_BUNDLE_IDENTIFIER}
# Widget Identifier
widgetIdentifier="WidgetName"
# updating BundleIdentifier in widget InfoPlist
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $bundleIdentifier.$widgetIdentifier" "${SRCROOT}/${widgetIdentifier}/ConfigFiles/Info.plist"

My two main targets bundle identifiers are com.company.firstname and com.company.secondname. As you can see, I was able to update the Info.plist of the Widget, specifically the CFBundleIdentifier key. Can i do something similar to this to update the build settings parameter of the Widget Product Bundle Identifier? I need to update the Widget build settings to be something like com.company.firstname.widgetname or com.company.secondname.widgetname based on the current target.

matt
  • 515,959
  • 87
  • 875
  • 1,141
Andrea Corsini
  • 197
  • 1
  • 9
  • @matt can you provide some code to set an environment variable via script as you said? – Andrea Corsini Feb 18 '19 at 21:47
  • 2
    Check out using a different build scheme for each build. That will allow you to define your bundle identifier as a build setting without having to use scripts. – Mike Taverne Feb 18 '19 at 22:08
  • I'm looking for a way to edit project.pbxproj particularly the Build Settings values for Other Linker Flags (Debug) – nodebase Sep 28 '21 at 19:20

0 Answers0