4

I want to integrate the Aviary SDK Objective-C library into Monotouch project. I use 'Monotouch Binding Project' template for this. I have built the DLL (Thanks smart people!) The project is compiled and run on the simulator.

However I can NOT show the main Aviary view and the following code

            this.afPhotoEditor = new AFPhotoEditorController(UIImage.FromFile("Images/site.jpg"));
            AFDelegate afDelegate = new AFDelegate(this);
            this.afPhotoEditor.Delegate = afDelegate;
            this.PresentModalViewController(this.afPhotoEditor, true);

returns the error:

Unhandled Exception: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: Cannot create an NSPersistentStoreCoordinator with a nil model
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr_bool (intptr,intptr,intptr,bool)
  at MonoTouch.UIKit.UIViewController.PresentModalViewController (MonoTouch.UIKit.UIViewController modalViewController, Boolean animated) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIViewController.g.cs:261 
  at TestAviary.FirstViewController.<ViewDidLoad>m__0 (System.Object , System.EventArgs ) [0x00028] in /Users/mahmood1/Projects/AviaryBinding/TestAviary/FirstViewController.cs:61 
  at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:30 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29 
  at TestAviary.Application.Main (System.String[] args) [0x00000] in /Users/mahmood1/Projects/AviaryBinding/TestAviary/Main.cs:17 
[ERROR] FATAL UNHANDLED EXCEPTION: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: Cannot create an NSPersistentStoreCoordinator with a nil model
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr_bool (intptr,intptr,intptr,bool)
  at MonoTouch.UIKit.UIViewController.PresentModalViewController (MonoTouch.UIKit.UIViewController modalViewController, Boolean animated) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIViewController.g.cs:261 
  at TestAviary.FirstViewController.<ViewDidLoad>m__0 (System.Object , System.EventArgs ) [0x00028] in /Users/mahmood1/Projects/AviaryBinding/TestAviary/FirstViewController.cs:61 
  at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:30 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29 
  at TestAviary.Application.Main (System.String[] args) [0x00000] in /Users/mahmood1/Projects/AviaryBinding/TestAviary/Main.cs:17 

It seems this error (Cannot create an NSPersistentStoreCoordinator with a nil model) is linked with resource bundle what Aviary SDK requires to add.

From Aviary iOS Setup Guide:

4. Copy resources

Make sure AviarySDKResources.bundle is included in your target's "Copy Bundle Resources" build phase.

So I added this bundle via 'Add Existing Folder..' menu item in MonoDevelop.

Sources are placed here >>> http://www.axifile.com/en/71EC96914A

It includes 2 projects:

  • AviaryBinding (MonoTouch Binding Project)
  • TestAviary

Thank you!

Shturman
  • 85
  • 5
  • Just an idea, have you tried opening the bundle (I think it is "Show Contents", I'm on windows right now) and pulling out all the resources inside it? You could just add them all to your project in MonoDevelop. – jonathanpeppers Jun 08 '12 at 00:18
  • Thanks for advice. Yes bundle opens and I can get all files from it. But I tried many combination - No luck. I don't know what can cause this error. Maybe Aviary iOS can't be integrated with MonoTouch. Is it possible? OR MonoTouch can bind ANY ObjC Library? – Shturman Jun 08 '12 at 06:31
  • Shturman, can you share your (now working) solution with everyone? – Paul Knopf Apr 26 '13 at 15:10
  • Anyone create a binding for the new 3.0 release? Given the new app store rules we have to have it to go into the store. – Rick Apr 29 '13 at 17:22
  • 1
    Found 3.0 binding at:https://github.com/theonlylawislove/MonoTouch.Aviary Thanks! – Rick May 03 '13 at 15:46

1 Answers1

0

Per Jonathan.Peppers comment:

Adding most files like this to your project with Build Action of Content will solve the issue.

Community
  • 1
  • 1
Shturman
  • 85
  • 5