问题
I just updated to iOs10 on my test phone and XCode 8. I ran the code migration and was running tests succeessfully on my simulated devices.
However, once I started trying to test on my real device things stopped working smoothly. After running my Sprite Kit game for around 5 - 10 seconds it would crash and render the phone inoperable until I unplugged it from the computer. After I unplug it the game runs as normal and is still really smooth.
This are the startup notifications printed to the console:
2016-09-15 22:20:49.490959 AppName[411:38688] [DYMTLInitPlatform] platform initialization successful
2016-09-15 22:20:49.684189 AppName[411:38634] Metal GPU Frame Capture Enabled
2016-09-15 22:20:49.684758 AppName[411:38634] Metal API Validation Enabled
This is the error I receive after the app crashes when the phone is plugged in:
/BuildRoot/Library/Caches/com.apple.xbs/Sources/Metal/Metal-85.83/ToolsLayers/Debug/MTLDebugRenderCommandEncoder.mm:130: failed assertion `indexBufferOffset(12) + (indexCount(480) * 2) must be <= [indexBuffer length](960).'
(lldb)
回答1:
try to disable Metal verification by editing the scheme:
- (Command-Option-R)
- go to the Options tab.
- Set Metal API Validation to Disabled.
This worked for me...
回答2:
I can resolve this, unchecking "Debug executable" in the Scheme
回答3:
- Command-Option-R
- "Wait for executable to be launched"
- manual run
works for me from time to time.
来源:https://stackoverflow.com/questions/39519895/sprite-kit-app-crashes-when-run-on-real-device-and-plugged-into-computer