Wow, thank you eskimo, that is really helpful!I opened the console, and it turned out that the log did is different from the crash report.Here is what I got:*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named MTKView because no class named MTKView was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target)'Now that is kind of odd. Because if during attached debug run, it works, then why would MTKView not found during detached runs. I feel while this indicates that it is related to an instance of MTKView, it is more related to the app lifecycle, as how each items are initiated during the launch stage.Here is a excerpt of the view controller, which is derived from the GameViewController from the iOS Game template in Xcode.import UIKit
import MetalKit
class GameViewController: UIViewController {
private var renderer: Renderer! // Renderer is a custom class that manages
// renderings inside pathTracingView
@IBOutlet weak var pathTracingView: MTKView!
@IBOutlet weak var sceneTableView: UITableView!
@IBOutlet weak var inspectorTableView: UITableView!
// Other members...
override func viewDidLoad() {
super.viewDidLoad()
guard let mtkView = pathTracingView else {
print("View of Gameview controller is not an MTKView")
return
}
// Select the device to render with. We choose the default device
guard let defaultDevice = MTLCreateSystemDefaultDevice() else {
print("Metal is not supported")
return
}
mtkView.device = defaultDevice
mtkView.backgroundColor = UIColor.black
guard let newRenderer = Renderer(metalKitView: mtkView) else {
print("Renderer cannot be initialized")
return
}
renderer = newRenderer
renderer.viewController = self
renderer.view.isPaused = true
sceneTableView.delegate = self
sceneTableView.dataSource = self
sceneTableView.reloadData()
inspectorTableView.delegate = self
inspectorTableView.dataSource = self
inspectorTableView.reloadData()
renderer.mtkView(mtkView, drawableSizeWillChange: mtkView.drawableSize)
mtkView.delegate = renderer
}
// Other methods...
}
Post
Replies
Boosts
Views
Activity
Yes. That is exactly the case.To run:Set Launch option to Automatic, for the Run build.Run from Xcode.It works on physical device.To crash, flow 1:Set Launch option to Manual (Wait for executable to be launched), for the Run build.Launch the app from iPhone home screen.The crash happens, and Xcode catches it at the AppDelegate declaration, so nothing useful.To crash, flow 2:When the app is loaded to the device with either option in the Launch setting, disconnect the device from Xcode.Launch the app from iPhone home screen.The app crashes.
Thank you eskimo! The steps you provided in the last message really helped. Now the app does not seem to crash in detached mode anymore.I am very curious the mechanism behind the solution that resolved the issue by manually adding the MetalKit framework to the build target, and choosing Do Not Embed (it showed up as the default when I added the framework). Are there similar cases that this method may be useful for other system frameworks?My understanding is, and please correct me if I'm wrong, that now I am explicitly specifying that this target requries MetalKit framework, and asking the tool not to embed it to the app. So when actual devices are running the build, are they using whatever compatible versions of the framework from iOS on that device?
Here is one additional note I think I could mention, in case it is helpful for the situation.Currently, the official Xcode relase, which is the one I am using on my Mac, is 11.3.1. And the target choice in Deployment Info is at its maximum of 13.2. And there is no 13.3 in the drop down. However, my devices are running the official release of 13.3.1 (I don't think I am able to downgrade the OS make it match that supported by Xcode). And interestingly, I don't see any warning about target version is lower than device, when the app runs on device. I am not clear if this may have partially caused some issue.
Yes, I would love to submit a bug report for the team to take a look at. One quick question, what do you mean by "post your bug number"? Is it supposed to be generated after I compose and send the bug report?