Search Unity

How to use PlayerSettings.bundleIdentifier in final build?

Discussion in 'Getting Started' started by jshrek, Mar 12, 2015.

  1. jshrek

    jshrek

    Joined:
    Mar 30, 2013
    Posts:
    220
    So I have the following in one of my scripts:
    Code (CSharp):
    1. string bID = PlayerSettings.bundleIdentifier;
    When I first tried to use it, I got the following error:
    Code (csharp):
    1. error CS0103: The name `PlayerSettings' does not exist in the current context
    In order to get rid of this error, I needed to add the following at the top of the script:
    Code (CSharp):
    1. using Unity.Editor;
    This works great in the Editor, but when I try to build for iOS I get the following error:
    Code (csharp):
    1. error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    So I tried wrapping it like this:
    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using UnityEditor;
    3. #endif
    Still works in Editor just fine, but when I try to build for iOS I still get the following same error.

    I have searched forum but cannot figure out how to get around this.

    Thanks
     
  2. jshrek

    jshrek

    Joined:
    Mar 30, 2013
    Posts:
    220
    bump ... anybody?
     
  3. Deleted User

    Deleted User

    Guest

    Application.bundleIdentifier
     
  4. jshrek

    jshrek

    Joined:
    Mar 30, 2013
    Posts:
    220
    No that does not work:
    Assets/Scripts/GameController.cs(85,47): error CS0117: `UnityEngine.Application' does not contain a definition for `bundleIdentifier'
     
  5. jshrek

    jshrek

    Joined:
    Mar 30, 2013
    Posts:
    220
  6. Deleted User

    Deleted User

    Guest

    what version of Unity do you use?
     
  7. jshrek

    jshrek

    Joined:
    Mar 30, 2013
    Posts:
    220
    4.6.3p3
     
  8. jshrek

    jshrek

    Joined:
    Mar 30, 2013
    Posts:
    220
  9. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,203
  10. jshrek

    jshrek

    Joined:
    Mar 30, 2013
    Posts:
    220
    It seems strange to me that you have the ability to access something from the Unity Editor only and that it cannot be accessed from script when running on any platform!

    Anyways I will check out that BundleVersionChecker. Thanks for pointing me to it @Ryiah
     
  11. jshrek

    jshrek

    Joined:
    Mar 30, 2013
    Posts:
    220
    @Ryiah Yes I was able to modify it and get the bundle id as well as the version, so it works good.

    The only minor issue I ran into was that you have to close Unity completely and restart it in order for the old file to be overwritten.

    Thanks
     
  12. ElegantUniverse

    ElegantUniverse

    Joined:
    Sep 13, 2018
    Posts:
    78
    i had same issue , i solved it with 'Application.identifier' , attention you have to use Application.identifier instead of Application.bundleIdentifier.
     
  13. Sohaib_techverx

    Sohaib_techverx

    Joined:
    Aug 15, 2019
    Posts:
    16
    Hi,

    will Application.identifier work for both iOS and Android?