I am still wrestling with this problem in the actual package.
If you'd like to see the exact code, it's on GitHub at: https://github.com/InvadingOctopus/octopuskit/blob/develop/Sources/OctopusKit/Components/Input/Touch%20Gestures/OctopusGestureRecognizerComponent.swift
(please overlook transgressions like not using 2-letter prefixes and #if
instead of @available
..I'll get around to it :)
To reproduce, please create an iOS Single View App, add the OctopusKit package on the develop branch, and modify ViewController.swift:
import UIKit
import GameplayKit
import OctopusKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
print(GKComponent.self)
print(OctopusComponent.self)
print(UIGestureRecognizer.self)
print(UITapGestureRecognizer.self)
print(UIGestureRecognizerDelegate.self)
print(OctopusGestureRecognizerComponent.self) // EXC_BAD_ACCESS (code=1, address=0x0)
print(OctopusGestureRecognizerComponent<UITapGestureRecognizer>.self)
}
}
-
The peculiar thing is, it does not crash if I copy that class from the package and paste it verbatim inside ViewController.swift! (and rename it to avoid conflicts.)
-
It also does not crash if I comment out all override
s in OctopusGestureRecognizerComponent
(excluding the init
). Even a single override
brings back the crash.
-
It does not crash if I inherit from GKComponent
instead of OctopusComponent: GKComponent
In the Debug Console, I get this:
(lldb) po OctopusGestureRecognizerComponent.self
GenericCache(0x7fff89d01460): cyclic metadata dependency detected, aborting
error: Execution was interrupted, reason: signal SIGABRT.
The process has been returned to the state before expression evaluation.
Other things that I tried but did not help:
- Other Linker Flags:
-all_load
- Compilation Mode: Whole Module
- Adding
print
for every type that I think could be involved, in both the package and the client project.
- There was a type in the package with the same name as the package (
OctopusKit
). Renaming that type did not help.
Trace
(lldb) thread backtrace
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x00007fff5132ba49 libswiftCore.dylib`_swift_initClassMetadataImpl(swift::TargetClassMetadata<swift::InProcess>*, swift::ClassLayoutFlags, unsigned long, swift::TypeLayout const* const*, unsigned long*, bool) + 1337
frame #1: 0x0000000109744ea4 Bweh`type metadata completion function for OctopusGestureRecognizerComponent at <compiler-generated>:0
frame #2: 0x00007fff51332ced libswiftCore.dylib`swift::MetadataCacheEntryBase<(anonymous namespace)::GenericCacheEntry, void const*>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) + 285
frame #3: 0x00007fff51329767 libswiftCore.dylib`swift_getGenericMetadata + 1527
frame #4: 0x0000000109742dfc Bweh`type metadata accessor for OctopusGestureRecognizerComponent at <compiler-generated>:0
frame #5: 0x00000001096b3b7f Bweh`type metadata accessor for OctopusGestureRecognizerComponent<UIGestureRecognizer> at <compiler-generated>:0
* frame #6: 0x00000001096b3704 Bweh`ViewController.viewDidLoad(self=0x00007fadd7c080c0) at ViewController.swift:21:15
frame #7: 0x00000001096b3d7b Bweh`@objc ViewController.viewDidLoad() at <compiler-generated>:0