Search code examples
macosxamarinxamarin-studioxamarin.mac

Xamarin Studio can't see XIBs in shared project for macOS


I'm using an approach described here for my app.

Currently, I was able to setup such structure for Android and iOS platforms. In general, I have the global core (.NET lib), platform specific core (platform specific Class Library), and some extension (platform specific Class Library). The problem appears when I try to configure in same way structure for macOS platform. I was able to create platform specific class Library with components that should be reused in apps (for now this is just 1 class with the xib file). But, when I want to use this package in macOS target I got runtime error specific to macOS platform:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[NSNib _initWithNibNamed:bundle:options: ] could not load the nibName: MainView in bundle (null).'

That's strange, because I set up in same way structure for iOS app, and within the iOS target, it's work just great: all source files, xib files, resources are visible and could be freely used from the package. Note: I found few issues like described above and some solutions that could resolve this blocking point:

  1. rename xib file - doesn't work
  2. put xib file in rootDir - doesn't work
  3. make sure that BuildAction for file is "InterfaceDefinition" - doesn't work (it always set to InterfaceDefinition)
  4. recreate files - doesn't work
  5. clean all, remove file, reboot, create new - doesn't work
  6. put files in resource dir - doesn't work
  7. force include into package - doesn't work
  8. check that class in VB is correct - doesn't work (was always correct)
  9. check Xcode folder with autogenerated files - doesn't work (in general all files was always there, few times autogenerated h and m files were missed -> I receive another error, but when manually create them -> I faced again with such error)
  10. manually specify bundle for resource - doesn't work (this is strange because for iOS lib all resources are available within the null (main) bundle) - I try to explicitly specify bundle - doesn't work.

So, how to prepare class library within some source files, xib, other resources, so it can be freely accessed from any project that uses this package? Or maybe some steps described above was incorrect?


Solution

  • According to Chris Hamonds from Xamarin Forum here is the answer:

    I believe this is a bug we've fixed but is not in the latest builds in our channel. I can reproduce with our Alpha build but installing a build from: https://jenkins.mono-project.com/view/Xamarin.MaciOS/job/xamarin-macios-builds-master/