What's wrong with AssetBundles Build Pipeline & Conditional Compilation?
Hello there!
 Here's an interesting situation:
 
 I have a project with a modular structure. I've added the Mobile Notifications package to implement local push notifications. I have a module that implements iOS logic, and a module with implementation for Android. Modules swapped using conditional compilation depending on the target platform. 
 It looks like this:
 #if UNITY_EDITOR
     injectionBinder.Bind<INotificationsController().To<NotificationsControllerMockup>();
 #elif UNITY_ANDROID
     injectionBinder.Bind<INotificationsController().To<NotificationsControllerAndroid>();
 #elif UNITY_IOS
     injectionBinder.Bind<INotificationsController().To<NotificationsControllerIOS>();
 #endif
 Everything work perfectly until I build AssetBundles:
 BuildPipeline.BuildAssetBundles(AssetBundlesDirectory, options, target);
I get several errors like this:
 error CS0234: The type or namespace name 'Notifications' does not exist in the namespace 'Unity' (are you missing an assembly reference?)
So the conditional compilation works fine in the Editor, but for AssetBundles something goes wrong. I thought the thing is in usings, so I put controller implementations in separate namespaces:
 #if UNITY_EDITOR
   injectionBinder.Bind<INotificationsController>().To<Modules.Notifications.Impl.NotificationsControllerMockup>();
 #elif UNITY_ANDROID
   injectionBinder.Bind<INotificationsController>().To<Modules.Notifications.Impl.Android.NotificationsControllerAndroid>();
 #elif UNITY_IOS
   injectionBinder.Bind<INotificationsController>().To<Modules.Notifications.Impl.IOS.NotificationsControllerIOS>();
 #endif
 Doesn't work. 
 The only thing that works is when I wrap the whole class body with #if:
 #if UNITY_ANDROID
 
 using System;
 using Modules.Config.Api;
 using Modules.Notifications.Api;
 using Unity.Notifications.Android;
 
 namespace Modules.Notifications.Impl.Android
 {
     public sealed class NotificationsControllerAndroid : INotificationsController
     {
         ...
     }
 }
 #endif
 Any idea how it's resolvable besides wrapping the whole NotificationsControllerAndroid bonus in a #if? Many thanks!
Your answer
 
 
             Follow this Question
Related Questions
Open GL ES 2.0 ArKit 0 Answers
Editor regulary broken by unity packages compilation error 0 Answers
Extremely slow building of AssetBundles 0 Answers
Multiple .dll files missing, right after installing Unity 0 Answers
Dependent compilation for diferent users 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                