'"Undefined Symbol for architecture arm64"
Im new to swift programming. Im building a tic tac toe app for practice. when I want to run the app, the build fails with the error message:
Undefined symbols for architecture arm64:
"whoToPlay #1 (n: Swift.Int) -> Swift.Bool in Tik_Tak_to.PlayerAction.changeSymbol() -> Swift.String", referenced from:
Tik_Tak_to.PlayerAction.changeSymbol() -> Swift.String in PlayerAction.o
ld: symbol(s) not found for architecture arm64
clang: error:linker command failed with exit code 1 (use -v to see invocation)
Does somebody know how to fix this? I do this for like 2 weeks and this is my first question here so Im sorry if I forgot to add some information.
struct PlayerAction {
var turnNumber: Int = 1
var players = [Players(player: 1, symbols: "X"), Players(player: 2, symbols: "O")]
mutating func changeSymbol() -> String {
if whoToPlay(n: turnNumber) == true {
let symbolO = players[1].symbols
turnNumber += 1
return symbolO
} else {
let symbolX = players[0].symbols
turnNumber += 1
return symbolX
}
func whoToPlay(n: Int) -> Bool {
if n % 2 == 0 {
return true
} else {
return false
}
}
}
}
class ViewController: UIViewController {
@IBOutlet weak var A1: UIButton!
@IBOutlet weak var A2: UIButton!
@IBOutlet weak var A3: UIButton!
@IBOutlet weak var B1: UIButton!
@IBOutlet weak var B2: UIButton!
@IBOutlet weak var B3: UIButton!
@IBOutlet weak var C1: UIButton!
@IBOutlet weak var C2: UIButton!
@IBOutlet weak var C3: UIButton!
@IBOutlet weak var turnLabel: UILabel!
var playeraction = PlayerAction()
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func buttonPressed(_ sender: UIButton) {
if sender.currentTitle == nil {
sender.setTitle(playeraction.changeSymbol(), for: .normal)
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
