Chris Creates
Chris Creates

Reputation: 11

Error: Namespace "iOS" does not exist in Unity.Notifications

I added

using Unity.Notifications.Android;
using Unity.Notifications.iOS;

to my script.

VisualStudio says everything is fine, the intellisense sees fields from both namespaces fine, and I'm able to run in the editor fine.

But then when I try to build for Android to test of my phone, it says the namespace iOS does not exist in Unity.Notifications.

If I remove all iOS code it builds fine.

Upvotes: 0

Views: 2933

Answers (1)

derHugo
derHugo

Reputation: 90779

Well it makes totally sense that the according namespace only exists on a certain target platform. It doesn't sound like a big surprise that a namespace called iOS is not included in a build for Android and viceversa..

Have a look at Platform depended compilation

and remove according code blocks using #if preprocessors

#if UNITY_IOS
    using Unity.Notifications.iOS;
#elseif UNITY_ANDROID
    using Unity.Notifications.Android;
#endif

...

#if UNITY_IOS
    <Code for IOS>
#elseif UNITY_ANDROID
    <Code for Android>
#endif

They did probably exactly the same wrapping the entire namespaces in such preprocessors in order to exclude them on the according target platforms.

Upvotes: 3

Related Questions