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.
This error happens when you are referencing 2 different version of a same Framework at the same time. This can be the case when your code is using a different Swift version than one used by the library.
Try to use the same version of Swift than the one used by Google AR.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With