gpt4 book ai didi

ios - 段错误 : 11 - Cross-reference to module

转载 作者:搜寻专家 更新时间:2023-10-31 08:11:47 27 4
gpt4 key购买 nike

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

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

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

具有空类的项目: https://dl.dropboxusercontent.com/u/40968624/Hypno.zip

最佳答案

更新:

深入研究问题后发现我的回答是错误的。

您的代码应该可以正常编译,因为您不是 AugmentedRealityView 的子类,而是一个嵌套类。

对我来说,实际问题看起来像是编译器错误。

您可以通过将 Swift 编译器 - Optimization Level 更改为 Fast, Whole Module Optimization 而不是 None< 来解决此问题:


原答案:

您正在尝试从定义该类的模块外部的类 (AugmentedRealityView) 继承,但它被标记为 publicfinal:

public final class AugmentedRealityView: UIView {
}

open class WorldObjectBasedAugmentedRealityObject: AugmentedRealityView {
}

final 一般禁止继承此类。

public 允许从定义该类的模块中(在 Swift3 中)进行子类化。

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

open class AugmentedRealityView: UIView {
}

open class WorldObjectBasedAugmentedRealityObject: AugmentedRealityView {
}

要了解更多信息,请阅读 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.

关于ios - 段错误 : 11 - Cross-reference to module,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40632924/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com