GM release of Xcode 6 compile

前端 未结 21 2251
难免孤独
难免孤独 2020-12-02 15:37

I just downloaded the GM release of Xcode 6 and it won\'t compile with this error:

Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault         


        
相关标签:
21条回答
  • 2020-12-02 16:11

    A lot of people have this issue (me included) due to the optimisation on the compiler. I don't consider turning off the optimisation a correct resolution - I want my code optimised to run as quick as it can.

    re-running xcodebuild manually didn't do any good as it ran it without the optimisations as well.

    However - the error screen gave me the swiftc command that was failing:

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

    The -O there is the optimise flag.

    I re-ran this whole command in the projects directory (as per xcodebuild recommendation above) and amongst all the details I found the error below:

    {
    "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
    }
    

    If you want it to go to a file instead of the screen, add " 2>filename" to the end.

    I then had to find the pid (10682) in the file to see what it was compiling. I ran the command for that pid manually and it gave me the error for the specific file. Then it comes down to fixing the code.

    0 讨论(0)
  • 2020-12-02 16:12

    I think the real problem is there are too many errors, so the compile tell you only a confused error code.

    But you can always open the every source code file, in there you can find the detail error information and correct advice.

    Good luck!

    0 讨论(0)
  • 2020-12-02 16:13

    This error can happen for numerous reasons, so this is meant to be a debugging hint. You may want to try using xcodebuild in the command line. It will give you details as to what files are the culprits.

    To do this, open Terminal and go to your project folder. Once there, type in

    xcodebuild -project YourProject.xcodeproj -scheme YourScheme
    

    or if you're working in a workspace

    xcodebuild -workspace YourProject.xcworkspace -scheme YourScheme
    

    You may see A LOT of messages pop up, but at the very end of the output you should see the specific files that are causing the crash. Back in XCode, go into those files and start playing with some of the Swift syntax to see what's going on. In my case, it had to do with the setAttributeString function, but I've seen other people have issues with ! and ?.

    Hopefully that will get you headed in the right direction.

    0 讨论(0)
  • 2020-12-02 16:13

    I had to change my "Optimization Level" to None[-0none]

    Target > Build Settings > Swift Compiler > Optimization Level.

    0 讨论(0)
  • 2020-12-02 16:14

    My case was a little bit different and it involves enums and optionals. For the simplicity lets define

    enum Animal {
        case Dog
        case Cat
    }
    
    func exampleAction(animal: Animal) {}
    
    exampleAction(.Cat)
    

    It will run OK. However as soon as I made the argument optional the error started to appear. So this code won't work:

    func exampleAction(animal: Animal?) {}
    
    exampleAction(.Cat)
    

    To make it work I had to add explicit enum name in the method call. So the following code worked again:

    exampleAction(Animal.Cat)
    
    0 讨论(0)
  • 2020-12-02 16:15

    To add my case here. I got the described error whenever I mark the closure with [unowned self], but never reference the self in the closure itself.

    For example:

            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.")
            })
    
    0 讨论(0)
提交回复
热议问题