可能的捆绑问题 - 无法使用nil模型创建NSPersistentStoreCoordinator

时间:2012-06-06 15:02:52

标签: binding xamarin.ios monodevelop nsbundle aviary

我想将Aviary SDK Objective-C库集成到Monotouch项目中。我使用'Monotouch Binding Project'模板。 我已经构建了DLL(感谢聪明的人!)该项目是在模拟器上编译和运行的。

但是我无法显示主要的Aviary视图和以下代码

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

返回错误:

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 

似乎此错误(无法创建具有nil模型的NSPersistentStoreCoordinator )与资源包链接,Aviary SDK需要添加。

来自Aviary iOS Setup Guide

4. Copy resources

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

所以我通过MonoDevelop中的“添加现有文件夹..”菜单项添加了这个包。

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

它包括2个项目:

  • AviaryBinding(MonoTouch绑定项目)
  • TestAviary

谢谢!

1 个答案:

答案 0 :(得分:0)

Jonathan.Peppers条评论:

将大多数此类文件添加到Build Action Content的项目中将解决此问题。