我尝试在iPhone SE上运行我的应用程序,并且在0__abort_with_payload文件中收到SIGABRT错误。我不知道这是什么。
dyld`__abort_with_payload:
0x10057425c <+0>: mov x16, #0x209
0x100574260 <+4>: svc #0x80
-> 0x100574264 <+8>: b.lo 0x10057427c ; <+32>
0x100574268 <+12>: stp x29, x30, [sp, #-0x10]!
0x10057426c <+16>: mov x29, sp
0x100574270 <+20>: bl 0x100573698 ; cerror_nocancel
0x100574274 <+24>: mov sp, x29
0x100574278 <+28>: ldp x29, x30, [sp], #0x10
0x10057427c <+32>: ret
->箭头所在的位置,是我收到称为Thread 1: signal SIGABRT
将应用程序加载到手机上后,它会打开并冻结在启动屏幕上。
编辑:该应用程序在Xcode模拟器中运行正常,但在实际手机上模拟时冻结在启动屏幕上。 编辑:GameScene.swift代码:
//
// GameScene.swift
// Game
//
// Created by student on 12/3/18.
// Copyright © 2018 student. All rights reserved.
//
import SpriteKit
import GameplayKit
class GameScene: SKScene {
var player = SKSpriteNode()
var goal = SKSpriteNode()
var danger = SKSpriteNode()
override func didMove(to view: SKView) {
player = self.childNode(withName: "player") as! SKSpriteNode
player.physicsBody?.isDynamic = true
goal = self.childNode(withName: "goal") as! SKSpriteNode
let border = SKPhysicsBody(edgeLoopFrom: self.frame)
border.friction = 0
border.restitution = 1
self.physicsBody = border
if player.position == danger.position {
player.position = CGPoint(x: 0, y: 550)
} else if player.position == goal.position {
print("Good Job!")
}
addSwipeGestureReconizers()
startGame()
}
func addSwipeGestureReconizers() {
let gestureDirections: [UISwipeGestureRecognizer.Direction] = [.right, .left,. up,. down]
for gestureDirection in gestureDirections {
let gestureReconizer = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipe))
gestureReconizer.direction = gestureDirection
self.view?.addGestureRecognizer(gestureReconizer)
}
}
@objc func handleSwipe(gesture:UIGestureRecognizer) {
if let gesture = gesture as? UISwipeGestureRecognizer {
switch gesture.direction {
case .up:
player.physicsBody?.applyImpulse(CGVector(dx: 0, dy: 0))
player.physicsBody?.applyImpulse(CGVector(dx: 0, dy: 110))
print("Swiped up")
case .down:
player.physicsBody?.applyImpulse(CGVector(dx: 0, dy: 0))
player.physicsBody?.applyImpulse(CGVector(dx: 0, dy: -110))
print("Swiped down")
case .right:
player.physicsBody?.applyImpulse(CGVector(dx: 0, dy: 0))
player.physicsBody?.applyImpulse(CGVector(dx: 110, dy: 0))
print("Swiped right")
case .left:
player.physicsBody?.applyImpulse(CGVector(dx: 0, dy: 0))
player.physicsBody?.applyImpulse(CGVector(dx: -110, dy: 0))
print("Swiped left")
default:
print("No such gesture")
}
}
}
func startGame() {
player.position = CGPoint(x: 0, y: 550)
}
override func update(_ currentTime: TimeInterval) {
// Called before each frame is rendered
}
}
ViewController代码:
//
// GameViewController.swift
// Game
//
// Created by student on 12/3/18.
// Copyright © 2018 student. All rights reserved.
//
import UIKit
import SpriteKit
import GameplayKit
class GameViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
if let view = self.view as! SKView? {
// Load the SKScene from 'GameScene.sks'
if let scene = SKScene(fileNamed: "GameScene") {
// Set the scale mode to scale to fit the window
scene.scaleMode = .aspectFill
// Present the scene
view.presentScene(scene)
}
view.ignoresSiblingOrder = true
view.showsFPS = true
view.showsNodeCount = true
}
}
override var shouldAutorotate: Bool {
return true
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
if UIDevice.current.userInterfaceIdiom == .phone {
return .allButUpsideDown
} else {
return .all
}
}
override var prefersStatusBarHidden: Bool {
return true
}
}