Bigfoot11
Bigfoot11

Reputation: 921

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.

Upvotes: 1

Views: 102

Answers (2)

Nurdin
Nurdin

Reputation: 23883

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.

enter image description here

Upvotes: 1

Jeremy Huddleston Sequoia
Jeremy Huddleston Sequoia

Reputation: 23623

This means that the file that implements your main() function isn't being linked into your executable.

Upvotes: 0

Related Questions