分段错误:11 - 对模块的交叉引用 [英] Segmentation fault: 11 - Cross-reference to module

查看:61
本文介绍了分段错误:11 - 对模块的交叉引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过交叉引用模块来解决分段错误.不知道如何使这项工作.以下部分错误:

<代码>1.从/Users/damiandudycz/Library/Developer/Xcode/DerivedData/Hypno-azmcjycezcoqnfauqcbgimvipjyj/Build/Intermediates/Hypno.build/Debug-iphonesimulator/Hypno.build/Objects-normal/x86_64/WorldialObjectBased2. 反序列化 'WorldObjectBasedAugmentedRealityObject' (ClassDecl #12)3. 反序列化 decl #31 (XREF)4. 对模块AugmentedReality"的交叉引用... 增强现实视图...在模块AugmentedReality"的扩展中... 目的5. 在 <invalid loc> 加载AugmentedRealityView"的成员时6. 反序列化 'init' (ConstructorDecl #5)7. 反序列化 decl #33 (XREF)8. 模块UIKit"的交叉引用... UIView... 在里面... 类型 (UIView.Type) ->(CGRect) ->界面视图

当我对一个类进行子类化时会出现问题,该类是其他模块中某物的子类.而其他模块中的这个类继承自 UIView.我准备了一个空"的项目版本——我删除了大部分文件和定义,只剩下空类和模块.有人可以帮我解决这个问题吗?问题出现在 GoogleARObject 类中 - 当这个类被删除或评论时,它会编译.

带有空类的项目:


原答案:

您试图从定义类的模块外部继承一个类 (AugmentedRealityView),但它被标记为 publicfinal:

 public final class AugmentedRealityView: UIView {}打开类 WorldObjectBasedAugmentedRealityObject:AugmentedRealityView {}

final 一般禁止从这个类继承.

public 允许从定义类的模块中子类化(在 Swift3 中).

要使一个类可以从定义它的模块外部子类化,请使用 open(Swift3 中的新功能):

打开类AugmentedRealityView:UIView {}打开类 WorldObjectBasedAugmentedRealityObject:AugmentedRealityView {}

要了解更多信息,请阅读 这个

<块引用>

您可以通过在类定义(最终类)中的 class 关键字之前编写 final 修饰符来将整个类标记为 final.任何对 final 类进行子类化的尝试都会报告为编译时错误.

...

<块引用>

开放访问仅适用于类和类成员,它与公共访问的区别如下:

具有公共访问权限或更严格的访问级别的类只能在定义它们的模块内进行子类化.

具有公共访问权限或更严格的访问级别的类成员只能在定义它们的模块内被子类覆盖.

开放类可以在定义它们的模块中进行子类化,也可以在导入定义它们的模块的任何模块中进行子类化.

开放类成员可以被定义它们的模块内的子类以及导入定义它们的模块的任何模块内的子类覆盖.

I'm trying to resolve an Segmentation Fault with Cross-references to modules. Don't know how to make this work. Part of error below:

1.  While reading from /Users/damiandudycz/Library/Developer/Xcode/DerivedData/Hypno-azmcjycezcoqnfauqcbgimvipjyj/Build/Intermediates/Hypno.build/Debug-iphonesimulator/Hypno.build/Objects-normal/x86_64/WorldObjectBasedAugmentedRealityObject~partial.swiftmodule
2.  While deserializing 'WorldObjectBasedAugmentedRealityObject' (ClassDecl #12) 
3.  While deserializing decl #31 (XREF)
4.  Cross-reference to module 'AugmentedReality'
... AugmentedRealityView
... in an extension in module 'AugmentedReality'
... Object
5.  While loading members for 'AugmentedRealityView' at <invalid loc>
6.  While deserializing 'init' (ConstructorDecl #5) 
7.  While deserializing decl #33 (XREF)
8.  Cross-reference to module 'UIKit'
... UIView
... init
... with type (UIView.Type) -> (CGRect) -> UIView

Problem occurs when I'm subclassing a class that is a subclass of something from other module. And this class in other module inherits from UIView. I have prepared an "empty" project version - I deleted most of the files and definitions, only empty classes are left and modules. Could someone help me with this? Problem shows in class GoogleARObject - when this class is deleted or commented it compiles.

Project with empty classes: https://dl.dropboxusercontent.com/u/40968624/Hypno.zip

解决方案

Update:

After having a deeper look in the issue it turns out that my answer is wrong.

Your code should compile fine, as you do not subclass AugmentedRealityView but a nested class.

The actual issue looks like a compiler bug to me.

You can workaround the issue by changing the Swift Compiler - Optimization Level to Fast, Whole Module Optimization instead of None:


Original Answer:

You are trying to inherit from a class (AugmentedRealityView) from outside the module the class is defined in, but it is marked public and final:

public final class AugmentedRealityView: UIView {
}

open class WorldObjectBasedAugmentedRealityObject: AugmentedRealityView {
}

final forbids to inherit from this class in general.

public allows to subclass from within the module the class is defined in (in Swift3).

To make a class subclass-able from outside the module it is defined in, use open (new in Swift3):

open class AugmentedRealityView: UIView {
}

open class WorldObjectBasedAugmentedRealityObject: AugmentedRealityView {
}

To learn more, read this

You can mark an entire class as final by writing the final modifier before the class keyword in its class definition (final class). Any attempt to subclass a final class is reported as a compile-time error.

...

Open access applies only to classes and class members, and it differs from public access as follows:

Classes with public access, or any more restrictive access level, can be subclassed only within the module where they’re defined.

Class members with public access, or any more restrictive access level, can be overridden by subclasses only within the module where they’re defined.

Open classes can be subclassed within the module where they’re defined, and within any module that imports the module where they’re defined.

Open class members can be overridden by subclasses within the module where they’re defined, and within any module that imports the module where they’re defined.

这篇关于分段错误:11 - 对模块的交叉引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆