Xcode中的链接器错误? [英] Linker error in Xcode?

查看:188
本文介绍了Xcode中的链接器错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在模拟器上运行我的应用程序时,我遇到了一个奇怪的错误。该错误在以下代码/文件中。 (我不确定它叫什么):

 架构i386的未定义符号:
_main,引用自:
隐式条目/主要可执行文件的启动
ld:未找到体系结构的符号i386
clang:错误:链接器命令失败,退出代码1 (使用-v查看调用)

上面的错误有两部分以红色突出显示; _ main,引用自:链接器命令失败,退出代码1(使用-v查看调用)



我以前从未遇到过此错误。因此,我无法解决它。这是我的代码,以防万一有必要:

  class ViewController:UIViewController {

override func viewDidLoad (){
super.viewDidLoad()

}

覆盖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 ,w,x,y,z]

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

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

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


}

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

let score = scoreForWord(newWord)

返回true
}
}

请包括对这个错误的意义的解释。

解决方案

几个月前我已经发生了这个错误消息。您的库不支持模拟器。你需要运行在实际的设备上而不是模拟器。




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.

这篇关于Xcode中的链接器错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆