Search code examples
iosobjective-cplistwatchkitxcode-6.2

User-Defined settings for WatchKit


I am using User-Defined settings (for example CustomAppBundleId) to change bundle identifier for different configurations. In the app’s plist file I set CFBundleIdentifier to ${CustomAppBundleId}. For Release configuration I use bundle:

com.yourcompany.${PRODUCT_NAME:rfc1034identifier}

and for AdHoc I use:

com.yourcompany.adhoc.${PRODUCT_NAME:rfc1034identifier}

Now I added WatchKit Extension and WatchKit App. For WatchKit Extension bundle identifier I can use the same approach. I also have to change WKAppBundleIdentifier to match the bundle identifier in the WatchKit App. Again, I could use User-Defined settings. Now the last bit is WatchKit App. Unfortunately WatchKit App doesn’t have an option to add User-Defined settings but I need to set the right values for CFBundleIdentifier and WKCompanionAppBundleIdentifier (that is equal to CustomAppBundleId in the app). Is there any way I can do it? Or should I use different approach?


Solution

  • Define your "User-Defined" variables in project's Build Settings rather than in target's. That way you will have the same user defined variables automatically available (inherited) in WatchKit Extension and App target.


    Btw make sure you have the latest Xcode 6.3 from the App Store. This version (and most recent Xcode 6.3 beta 4) already allow you to define custom "User-Defined" in Build Settings).

    Previous versions were simply missing "Build Settings" tab in WatchKit App target, but if you were brave enough, you could have modify those manually in plain text editor :-)