运行ibtool时Xamarin.IOS异常:对象不能为nil(key:family)

时间:2016-08-18 14:51:36

标签: c# iphone xcode xamarin xamarin.ios

我在尝试构建解决方案时遇到了一个奇怪的错误: 运行ibtool时出现异常:*** setObjectForKey:object不能为nil(key:family)

我用谷歌搜索了但是这个问题没有答案,只是问题......也许值得一提的是我使用Visual Studio Community 2015,我在Mac上安装了最新的Xcode,我有一个更新的iPhone 5s连接到Mac。 Mac上的操作系统是El Capitan(10.11.4)。

我认为这个问题主要来自我的故事板,起初我在尝试为两个视图之间的按钮创建一个segue时出现此错误。我删除了它,它像往常一样工作,现在我在这个项目中得到了同样的错误,这不是由于segue。

如果我排除故事板,我可以毫无困难地构建解决方案,但由于缺少故事板,我无法在iPhone上运行该应用程序。

任何人都知道问题可能是什么?如有必要,以下是错误日志:

Severity    Code    Description Project File    Line    Source  Suppression State
Error       Exception while running ibtool: *** setObjectForKey: object cannot be nil (key: family)
Backtrace:
  0   __exceptionPreprocess (in CoreFoundation)
  1   objc_exception_throw (in libobjc.A.dylib)
  2   -[__NSDictionaryM setObject:forKey:] (in CoreFoundation)
  3  0x00000001181c6b41 (in IDEInterfaceBuilderCocoaTouchIntegration)
  4  0x000000011814ee00 (in IDEInterfaceBuilderCocoaTouchIntegration)
  5  0x000000011814d775 (in IDEInterfaceBuilderCocoaTouchIntegration)
  6  0x000000011815f133 (in IDEInterfaceBuilderCocoaTouchIntegration)
  7  0x000000011815eeac (in IDEInterfaceBuilderCocoaTouchIntegration)
  8  0x000000011815ec66 (in IDEInterfaceBuilderCocoaTouchIntegration)
  9  0x000000011815d934 (in IDEInterfaceBuilderCocoaTouchIntegration)
 10  0x00000001181cb205 (in IDEInterfaceBuilderCocoaTouchIntegration)
 11  0x00000001181ccce7 (in IDEInterfaceBuilderCocoaTouchIntegration)
 12   -[IBDocumentCompiler invokeWhileUsingSourceAsIntermediateDocument:] (in IDEInterfaceBuilderKit)
 13   -[IBDocumentCompiler invokeWithIntermediateDocumentOfTargetRuntime:alwaysCopy:block:] (in IDEInterfaceBuilderKit)
 14  0x00000001181cc40a (in IDEInterfaceBuilderCocoaTouchIntegration)
 15  0x00000001181b8b4d (in IDEInterfaceBuilderCocoaTouchIntegration)
 16   -[IBStoryboardSceneCompilationGroup compilationResultsForCompilationUnits:options:returningErrors:] (in IDEInterfaceBuilderKit)
 17   -[IBStoryboardDocumentCompiler compileUnitsFromCompilationGroups:filter:options:errors:] (in IDEInterfaceBuilderKit)
 18   __78-[IBStoryboardDocumentCompiler compileContentsOfStoryboardWithOptions:errors:]_block_invoke (in IDEInterfaceBuilderKit)
 19   IBWithAutoInvalidationPool (in IDEInterfaceBuilderKit)
 20   -[IBStoryboardDocumentCompiler compileContentsOfStoryboardWithOptions:errors:] (in IDEInterfaceBuilderKit)
 21   -[IBStoryboardDocumentCompiler internalCompileWithOptions:error:] (in IDEInterfaceBuilderKit)
 22  0x00000001181b8f5e (in IDEInterfaceBuilderCocoaTouchIntegration)
 23   __57-[IBStoryboardDocumentCompiler compileWithOptions:error:]_block_invoke (in IDEInterfaceBuilderKit)
 24   -[IBDocumentCompiler invokeWithIntermediateDocument:] (in IDEInterfaceBuilderKit)
 25   -[IBDocumentCompiler invokeWithIntermediateDocumentOfTargetRuntime:alwaysCopy:block:] (in IDEInterfaceBuilderKit)
 26   -[IBStoryboardDocumentCompiler compileWithOptions:error:] (in IDEInterfaceBuilderKit)
 27   +[IBDocumentCompiler compileContentsOfDocument:options:error:] (in IDEInterfaceBuilderKit)
 28   __47-[IBDocument compiledPackageWithOptions:error:]_block_invoke (in IDEInterfaceBuilderKit)
 29   -[IBDocumentAutolayoutManager ignoreAutolayoutStatusInvalidationDuring:] (in IDEInterfaceBuilderKit)
 30   -[IBDocument compiledPackageWithOptions:error:] (in IDEInterfaceBuilderKit)
 31   -[IBDocument compileAndWriteToPath:withOptions:error:] (in IDEInterfaceBuilderKit)
 32  0x000000010ceb52da (in ibtoold)
 33  0x000000010ceb10e7 (in ibtoold)
 34  0x000000010ceb36ab (in ibtoold)
 35  0x000000010ceb75c8 (in ibtoold)
 36  0x000000010ceb7c5a (in ibtoold)
 37  0x000000010ceb7b2d (in ibtoold)
 38  0x000000010cea695b (in ibtoold)
 39  0x000000010ceb71c3 (in ibtoold)
 40  0x000000010ceb6274 (in ibtoold)
 41   start (in libdyld.dylib)  FridgeMe.iOS            Build   

编辑:我删除了我的第二个视图控制器并创建了一个全新的视图控制器,这似乎解决了这个问题。仍不确定导致问题的原因,但如果有人知道我真的想知道这是否会发生这种情况。

编辑2:一旦我在另一个(新)视图控制器上添加了一个按钮,就会出现错误。它还指的是关于没有代码的按钮的运行时错误(我认为是在故事板上添加按钮时创建的)。看图像。 Seems like the code for the button isn't generated properly.

我希望这可以为遇到此问题的其他人提供一些帮助。我仍然有点卡住,因为我试图手动复制关于按钮的所有内容(当然更改它的名称)从我的工作视图控制器到新的,但我似乎没有让它工作。

我在ViewControllerCreate.designer.cs中添加了以下内容:

UIKit.UIButton BtnCreateAccount { get; set; }

void ReleaseDesignerOutlets()
{
    if (BtnCreateAccount != null)
    {
        BtnCreateAccount.Dispose();
        BtnCreateAccount = null;
    }
}

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

我得到了同样的错误。

在分析了代码main.storyboard之后,我发现,在我的情况下,如果按钮或其他控件有类似的错误,则跳转错误: < fontDescription key =" fontDescription"命名=" HelveticaNeue"的pointsize =" 17" />

家庭字体是问题,请尝试更改 < fontDescription key =" fontDescription"类型="系统"的pointsize =" 17" />或者只是删除de line。

此致 马塞洛

答案 1 :(得分:0)

我不确定以下代码是否对您有所帮助。

internal class CustomUIView : UIView
{
    internal CustomUIView(IntPtr value) :base(value)

    {

    }
}   

示例:

UIView view = new CustomUIView(IntPtr.Zero);

请参阅更多信息here