2016-11-16 18 views
2

モジュールへの相互参照でセグメンテーションフォルトを解決しようとしています。この仕事をする方法を知らない。以下のエラー部分:セグメンテーションフォールト:11 - モジュールへのクロスリファレンス

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

答えて

12

更新:

それは私の答えが間違っていることが判明した問題で深い表情をした後。

サブクラスAugmentedRealityViewではなくネストされたクラスであるため、コードをコンパイルする必要があります。

実際の問題は私にとってコンパイラのバグのようです。

あなたはSwift Compiler変更することで問題を解決することができます - Fast, Whole Module OptimizationからOptimization Levelを代わりにNone


オリジナル回答:

あなたはクラスから継承しようとしています(AugmentedRealityView)、クラスが定義されているモジュールの外側からはマークされていますpublicfinal

public final class AugmentedRealityView: UIView { 
} 

open class WorldObjectBasedAugmentedRealityObject: AugmentedRealityView { 
} 

finalは、一般的に、このクラスから継承する禁じます。

publicモジュールがクラス内で(Swift3で)定義されているサブクラス化を許可します。

(Swift3に新)openを使用して、それが中に定義されているモジュールの外部からクラスのサブクラス可能なを作るために:

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.

+0

オープンについてはわかりませんでした。ありがとうございました。 (投票された) –

+0

そして、それはうまくいった、ありがとう:)。これは常にネストされたクラスをエクステンションの中に組み込むのは悪い設計ですか?それらがモジュールの内部でしか見えないのなら、これは大丈夫ですか? –

+0

実際には、モジュール内の拡張モジュールの中にこのようなオープンクラスを持つ場所がたくさんあり、それらを別のモジュールで継承しています。しかし、この問題だけが原因です。何故ですか?例えば、私はpublic final class WebServiceを持っています:OperationQueueとその拡張モジュールの拡張WebService {open class RequestOperation:Operation {}} 同じ状況ですが、うまく動作し、別のモジュールで継承できます。 –

0

私はこの質問が古いことを知っていますが、私はちょうど同じエラーに遭遇しましたR:私の場合は

Segmentation fault: 11 - Cross-reference to module 

ソリューションは、(それはあなたのプロジェクトのために可能かどうもちろん)Use Legacy Swift Language Versionを無効にすることでした。

0

このエラーは、同じフレームワークの2つの異なるバージョンを同時に参照している場合に発生します。これは、コードがライブラリで使用されているバージョンとは異なる別のSwiftバージョンを使用している場合に発生します。

Google ARで使用されているものと同じバージョンのSwiftを使用してください。

enter image description here

+0

古い質問ですが、Google ARではなく、自分で開発していたARエンジンでした。非常にクールな作業をしましたが、Apple ARKitは押し込んだ:) –

関連する問題