简体   繁体   中英

Linker error in Xcode?

I am getting a weird error when I attempt to run my app on the simulator. The error is within the following code/file. (I am unsure of what it is called):

Undefined symbols for architecture i386:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)   

There are two parts of the error above that are highlighted in red; "_main", referenced from: and linker command failed with exit code 1 (use -v to see invocation) .

I have never encountered this error before. Therefore, I am unable to fix it. Here is my code in case it is necessary:

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()

}

@IBOutlet weak var strWordValue: UILabel!
@IBOutlet weak var strInputField: UITextField!


func textFieldShouldReturn(textField: UITextField) -> Bool{
    textField.resignFirstResponder()

    let word = textField.text
    let score = scoreForWord(word)

    return true
}

var TextField: UITextField!

        private let alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

func valueOfLetter(letter: Character) -> Int
{
let letterString = String(letter).uppercaseString
let index = find(alphabet, letterString)

return index != nil ? index! + 1 : 0
}

func scoreForWord(word: String) -> Int
{
    let characters = Array(word)
    return characters.reduce(0) { sum, letter in sum + self.valueOfLetter(letter) }


}

  func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool
  {
let currentWord = textField.text as NSString
let newWord = currentWord.stringByReplacingCharactersInRange(range, withString: string)

let score = scoreForWord(newWord)

return true
}
}

Please include an explanation of what this error(s) mean.

This error message already happen to me a few of months ago. Your library not supported for simulator. You need to run on actual device instead of simulator.

在此处输入图片说明

这意味着实现main()函数的文件未链接到可执行文件中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM