I came across an issue when working on the Android implementation of my Rise app using Visual Studio for Mac.
No, not Xamarin, Visual Studio! I made the switch to Visual Studio for Mac when it came out of preview mode a few days back. The apps are nearly identical, which is no coincidence. Microsoft bought Xamarin last year and built Xamarin Studio as a near clone of Visual Studio Community. I imagine now that Visual Studio for Mac is no longer in preview mode, Xamarin Studio will be phased out in favor of cross-mobile development under the company’s flagship IDE. Smart move, Microsoft!
I tried uninstalling and re-installing the package multiple times, and downgrading to a previous version. None of these worked. However, I finally figured out where I went wrong:
Packages on which shared classes depend must be imported into all platform-specific projects.
I had one project called
TheRiseAndroid and another called
TheRiseiOS, but I was only working on the Android version of the app. The iOS version was completely empty because I hadn’t started it yet. Between these projects is a
Shared folder that contains classes to be used on both platforms. These include classes that would be used to deserialize and serialize JSON files, so these classes used the
Newtonsoft.Json namespace. But because it wasn’t included in the iOS project, Visual Studio complained that I didn’t have a reference to the library. Except I did have a reference to the library. I just needed another reference within the empty, almost-forgotten iOS project. So yeah…I was stuck on this for a while.
Once I loaded the package into
TheRiseiOS, the errors disappeared! It seems like this would be a common problem considering how many shared Android and iOS projects there are in the Xamarin/Visual Studio universe, but I haven’t found any question-answer threads along these lines. Maybe this is totally obvious and not worth its own blog post. But feel free to leave a comment if this was useful to you!