Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 通用汽车公司发布的Xcode 6编译版_Ios_Xcode_Swift - Fatal编程技术网

Ios 通用汽车公司发布的Xcode 6编译版

Ios 通用汽车公司发布的Xcode 6编译版,ios,xcode,swift,Ios,Xcode,Swift,我刚下载了Xcode 6的GM版本,它不会编译,但有以下错误: Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 关于如何解决这个问题有什么想法吗?更改 func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath

我刚下载了Xcode 6的GM版本,它不会编译,但有以下错误:

Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
关于如何解决这个问题有什么想法吗?

更改

func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!  


我认为真正的问题是错误太多了,所以编译只会告诉你一个混乱的错误代码

func afunc() {
    class AClass() {
    }
    let ac = AClass()
    //....
}
但是您可以随时打开每个源代码文件,在那里您可以找到详细的错误信息和正确的建议


祝你好运

我的案例有点不同,它涉及枚举和选项。为了简单起见,让我们定义

enum Animal {
    case Dog
    case Cat
}

func exampleAction(animal: Animal) {}

exampleAction(.Cat)
它会正常运行。然而,当我将参数设置为可选时,错误开始出现。因此,此代码不起作用:

func exampleAction(animal: Animal?) {}

exampleAction(.Cat)
为了使它工作,我必须在方法调用中添加显式的枚举名。因此,以下代码再次起作用:

exampleAction(Animal.Cat)
我必须将我的“优化级别”更改为无[-0none]

目标>生成设置>Swift编译器>优化级别。

可能是相同的问题

我也遇到了同样的问题,然后我使用git checkout旧版本来查找导致问题的提交,并尝试查找关键问题代码。我的关键问题代码是这样的

func afunc() {
    class AClass() {
    }
    let ac = AClass()
    //....
}

在Swift优化中,其他代码可能会出现同样的问题,而Swift编译器不会告诉您确切的位置。这一定是苹果的错误。

就我而言,我改变了3个位置:

目标>生成设置>Swift编译器>

  • 优化级别。
    • 调试:无[-Onone]
    • 分布:最快[-O]
    • 发布:最快[-O]
当我更改just Debug时,会出现诸如“源代码工具包崩溃…”之类的错误
这个参数组合,对我来说非常好

发生此错误的原因有很多,因此这是一个调试提示。您可能希望尝试在命令行中使用
xcodebuild
。它会告诉你哪些文件是罪魁祸首的细节

要执行此操作,请打开终端并转到项目文件夹。到达后,输入

xcodebuild -project YourProject.xcodeproj -scheme YourScheme
或者如果你在工作区工作

xcodebuild -workspace YourProject.xcworkspace -scheme YourScheme
您可能会看到弹出许多消息,但在输出的最后,您应该会看到导致崩溃的特定文件。回到XCode,进入这些文件,开始使用一些Swift语法,看看发生了什么。在我的例子中,它与setAttributeString函数有关,但我看到其他人在这方面有问题!还有


希望这能让你朝着正确的方向前进。

转到文件夹:Users/user/Library/Developer/Xcode/DerivedData

并清除所有文件

然后清理分析,


这对我来说是工作。

我认为发生这种情况的原因很多,我遇到的就是这种情况,希望能对你有所帮助

dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) ){ [weak self] in

        // ...
        dispatch_async(dispatch_get_main_queue()) { [weak self] in

            // ...
            return

        }
    }
在上面的代码中,只需删除名为“捕获列表”的“[weak self]”即可删除编译器错误。它对我有用

dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) ){ [weak self] in

        // ...
        dispatch_async(dispatch_get_main_queue()) {

            // ...
            return

        }
    }

xCode版本是6.1.1

我有以下代码显示版本中的构建错误

if myValue > 5 { myValue = 5.0 }
if myValue < 0 { myValue = 0 }
演示:


Xcode版本6.1(6A1052d)。在调试中正常生成。向Apple Bug Reporter提交了罚单。

只是为了说明这一点:每当我将
[unowned self]
放在一个块中的一个块中时,就会出现此错误,如下所示:

lazy var someVar: SomeType = {
    self.successBlock = {[unowned self] in
        // ...
    }
}()
button!.setTitleColor(.whiteColor(), forState: UIControlState.Normal)
解决方案是将
[unowned self]
仅放在最顶层块。对于块中的块,似乎自动处理对self的无主引用


当然,我只能通过@Maxwell的答案首先找到这个麻烦的文件来发现这个错误:

将我的案例添加到这里。每当我用[unowned self]标记闭包时,我就得到了所描述的错误,但从未在闭包本身中引用过self

例如:

        request.startWithSuccess({ [unowned self] (req: CBRequest!, object: AnyObject!) -> Void in

            if let result = object["result"] as? [NSObject: AnyObject]
            {
                popup.type = result["email"] == nil ? AuthPopupType.Signup : AuthPopupType.Login
            }
            else
            {
                println("WARNING: Malformed response for kCBCheckUniquenesPath request.")
            }

            }, failure: { (req: CBRequest!, err: NSError!) -> Void in

                println("ERROR: Failure response for kCBCheckUniquenesPath request.")
        })

通过遵循@maxvel的建议,我知道了这一点 max()和min()函数在发布模式下编译失败。我用我自己的函数替换了它,如下所示

//Swift compiler seems to failing to compile default min and max functions in release 
//mode hence writing my own
//
func maximum<T: Comparable> (one: T, other: T) -> T {
    if one > other {
        return one
    }
    else {
        return other
    }
}

func minimum<T: Comparable> (one: T, other: T) -> T {
    if one < other {
        return one
    }
    else {
        return other
    }
}
//Swift编译器似乎无法在发行版中编译默认的min和max函数
//因此我自己写
//
func最大值(一个:T,另一个:T)->T{
如果一个>另一个{
返回一个
}
否则{
返回其他
}
}
func最小值(一个:T,另一个:T)->T{
如果一个<另一个{
返回一个
}
否则{
返回其他
}
}

在我的例子中,这个错误是由不正确的(UTF8)引起的;
通过将文件内容复制粘贴到新文件中来解决此问题。

如果您使用的是某些应在早期iOS版本中使用的API,则可能会导致生成失败。
例如:如果您使用UI\u USER\u INTERFACE\u IDIOM()而不是UIDevice.currentDevice().userInterfaceIdiom来标识设备类型,您将在没有任何提示的情况下获得此生成错误。

由于编译器的优化,许多人都有此问题(包括我)。我不认为关闭优化是一个正确的解决方案——我希望我的代码能够尽可能快地运行。 手动重新运行xcodebuild没有任何好处,因为它在没有优化的情况下也运行了xcodebuild

但是-错误屏幕显示swiftc命令失败:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -target arm64-apple-ios8.0 -incremental -module-name SpaceCats -O -sdk /Applic...
-O
有优化标志

我在projects目录中重新运行了整个命令(根据上面的xcodebuild建议),在所有细节中,我发现了以下错误:

{
"kind": "finished",
"name": "compile",
"pid": 10682,
"output": "Bitcast requires both operands to be pointer or neither\n  %228 = bitcast i8* %227 to %VSs20UnsafeMutablePointer, !dbg !1322\nBitcast requires both operands to be pointer or neither\n  %324 = bitcast i8* %323 to %VSs20UnsafeMutablePointer, !dbg !1322\nBitcast requires both operands to be pointer or neither\n  %411 = bitcast i8* %410 to %VSs20UnsafeMutablePointer, !dbg !1322\nBitcast requires both operands to be pointer or neither\n  %498 = bitcast i8* %497 to %VSs20UnsafeMutablePointer, !dbg !1322\nLLVM ERROR: Broken function found, compilation aborted!\n",
"exit-status": 1
}
如果希望它转到文件而不是屏幕,请在末尾添加“2>文件名”


然后,我必须在文件中找到pid(10682),以查看它正在编译什么。我手动运行该pid的命令,它给出了特定文件的错误。然后是修复代码。

我看到了很多原因。我的答案不是一个通用的解决方案,只是增加了另一个案例,为这个错误提供了证据。在我的例子中,它设置了一个按钮的标题,如下所示:

lazy var someVar: SomeType = {
    self.successBlock = {[unowned self] in
        // ...
    }
}()
button!.setTitleColor(.whiteColor(), forState: UIControlState.Normal)
与此相反:

button!.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)

Maxwell的解决方案给出了最接近的提示。

在Xcode 6.4中编译此Swift 2.0语法时遇到此错误:

print(字符串,appendNewline:true)

回到
enum UIUserInterfaceIdiom : Int {
    case Unspecified
    case Phone // iPhone and iPod touch style UI
    case Pad // iPad style UI
}
 if UIDevice.currentDevice().userInterfaceIdiom == .Phone {

}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {

    if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
        return .AllButUpsideDown
    } else {
        return .All
    }
}