I am trying to figure out if this is even possible but i’d like to, at runtime (not in the editor) query the bundle identifier of the app. Basically the game i’m working on has 4 versions that are all essentially the same save a few different variables within the app itself (aka some locked stuff, etc)… 2 for iphone and 2 for ipad. What i was thinkin of doing is to check the current bundle identifier and turn things on/off based on that.
Is that even possible? Is there an easier way to setup the build process so i can check something ahead of time and then flag it appropriately prior to going into xcode? Like an if def or something? These builds are ALL separate builds. So i do have do it x4… little annoying right now.
I don’t think so, at least not that i’m aware of. I can definitely find the device “type” which i’m doing for other stuff… but since i have 2 versions on the same device i need to be able to discern those easily enough at runtime… i’m just trying to eliminate the need to make 4 completely unique sets of functions for each platform and instead just check against the app name or bundle id.
You’ll have to use a plugin. Here’s the C# code we use for accessing the bundle version at runtime. It can easily be modified to get whatever bundle value you need.
Thank you for the plugin. I’ll try that out and I guess try to make one for the Android side as well. Still seems very ridiculous to need to create a plugin to access a key component of an application run-time.
FWIW, my workaround for this was to just create a build script that sets a few game properties including bundleID so I could access them at run-time easily, and is platform independent this way.
Example:
[MenuItem("FizzPow/Build Game", priority = 96)]
private static void BuildGame()
{
//find my app setting object & set some stuff to be accessible at run-time
AppSettings[] appSettings = Resources.FindObjectsOfTypeAll<AppSettings>();
appSettings[0]._bundleID = PlayerSettings.bundleIdentifier;
...
BuildPipeline.BuildPlayer(...);
}
If you want to have access to the bundleIdentifier, productName etc… at runtime, and much more features, like handling multiple version of your game to different builds, I’ve created Advanced Builder, available right here: Unity Asset Store - The Best Assets for Game Making
“Returns application identifier at runtime. On Apple platforms this is the ‘bundleIdentifier’ saved in the info.plist file, on Android it’s the ‘package’ from the AndroidManifest.xml.”