Search Unity

unity publish iOS archive failed use of undeclared identifier in unitynotificationmanager.m

Discussion in 'iOS and tvOS' started by MrMajorThorburn, Jun 13, 2021.

  1. MrMajorThorburn

    MrMajorThorburn

    Joined:
    Dec 15, 2014
    Posts:
    89
    Trying for the first time to publish my app into iOS via Mac XCode and during Archive generation I got a Failed message and the above error.
    Item missing is
    UNAuthorizationStatusProvisional

    Did I miss something from the
    Publishing for iOS - Unity Learn
    Steps?

    Tried: adding definition of this as a BOOL in the associated h file did not resolve the "not defined" error message. Doing a find in project only found my definition and the line where the error occurred. I am lost now. :)
     
    Last edited: Jun 19, 2021
  2. rfadeev

    rfadeev

    Joined:
    Oct 1, 2013
    Posts:
    21
    Hi,

    The problem is most probably because you are using Xcode 9 or earlier. This is a bug in Unity's mobile notifications package which has iOS code compatible only with Xcode 10 or later. They use API unsupported in Xcode 9 here and this causes the compilation error you are observing.

    To fix it for your setup, go to
    UnityNotificationManager.m
    in Xcode and change
    Code (CSharp):
    1. if (authorizationStatus == UNAuthorizationStatusProvisional)
    to
    Code (CSharp):
    1. if (authorizationStatus == (UNAuthorizationStatus)3)
    You will need to do that every time you export Xcode project from Unity.

    For a long term fix, you can either update Xcode version or write build postprocessing script to change
    UnityNotificationManager.m
    automatically.

    Hope that helps!
     
    Last edited: Sep 5, 2021
  3. MrMajorThorburn

    MrMajorThorburn

    Joined:
    Dec 15, 2014
    Posts:
    89
    Thank you that explains a lot for me.
    I also came a cropper with the app store minimal requirements so submitting and app for an older version is now blocked by those requirements so I have gone with xcode 12.