Xcode - 源文件中的字符无效(将“"”替换为“"”) [英] Xcode - Invalid character in source file (Replace " " with " ")

查看:268
本文介绍了Xcode - 源文件中的字符无效(将“"”替换为“"”)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Xcode(Swift)有疑问。有时当我写一个if语句。这样的事情:

I have a question about Xcode (Swift). Sometimes when I write an if statement. Something like this:

if(a == 2){
//do Sth
} else {
//do Sth
}

Xcode给我一个错误:源文件中的字符无效
我知道这不是什么大问题并通过点击修复它来修复但我希望
知道是什么问题。这对我来说没有意义......

Xcode throws me an error: "Invalid character in source file" I know it is no big deal and fixed by clicking on "Fix-it" but I want to know what is the problem. That doesn't make sense to me...

我的Xcode在7.2上,我正在使用Swift - 我不知道这是否只是一个Swift问题。

My Xcode is on 7.2 and I am using Swift - I don't know if this is just a Swift problem.

推荐答案

我是有这个问题。我解决它的方法是1)将您拥有的任何内容复制到Sublime Text或其他代码编辑器中并查看(您可能需要启用查看隐藏字符)。我的DC2中有一个代码,它是某种ASCII控制字符。对我来说,这是因为我把操场放到了手动执行中并绑定了一个键盘快捷键,它似乎每次使用快捷键执行时都会输入该控制字符。我只是更改了快捷方式并删除了ASCII字符,因为我能够在Sublime Text中看到它们。 (关于从左到右模式的OP评论中的链接没有任何意义,对我来说没有用。)

I was having this problem. The way I solved it is by 1) copying whatever you have into Sublime Text or another code editor and having a look (you may need to enable viewing hidden characters). Mine had a code in there DC2 which is some sort of ASCII control character. For me it was caused by the fact that I had put the playground into manual execute and bound a keyboard shortcut to it that seemed to be entering that control character every time I executed it using the shortcut. I just changed the shortcut and removed the ASCII characters as I was able to see them in Sublime Text. (The link in the comments to the OP concerning left to right mode made no sense and didn't work for me.)

这篇关于Xcode - 源文件中的字符无效(将“"”替换为“"”)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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