Exclude scripts from webgl build

Hi,

When building a WebGL project, we found that firebase doesnt work. We learned that we could use the JS version to make firebase work, however we still want to use firebase for our non webgl version. By having scripts that import firebase causes our build to webgl to fail, so we were wondering if there is a way to exclude scripts that include firebase to not be built for webgl builds.

We saw that there are assembly definitions but we havent been able to get them to work, since we still want all scripts to know about each other. Is there another way to do this?

Thanks for the help,
Jon

Assembly definition files is for sure the proper solution to your problem. Additionally you can use scripting symbols to make code run on one platform and not another. See also Unity - Manual: Conditional compilation

E.g. for your Firebase initialization you could do something like this:

void Start()
{
#if UNITY_ANDROID || UNITY_IOS
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
  var dependencyStatus = task.Result;
  if (dependencyStatus == Firebase.DependencyStatus.Available) {
    // Create and hold a reference to your FirebaseApp,
    // where app is a Firebase.FirebaseApp property of your application class.
       app = Firebase.FirebaseApp.DefaultInstance;

    // Set a flag here to indicate whether Firebase is ready to use by your app.
  } else {
    UnityEngine.Debug.LogError(System.String.Format(
      "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
    // Firebase Unity SDK is not safe to use here.
  }
});
#endif
}

in general I would recommend to create a wrapper class that holds an implementation for the platform, to avoid to many scripting symbol checks everywhere. This would be achieved with the locator pattern: Service Locator · Decoupling Patterns · Game Programming Patterns