Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suddenly getting compiler crash "arrayForceCast" in Swift XCode beta 6

Tags:

swift

After upgrading to xcode beta 6, the compile is suddenly exploding cryptically on me. I get no inline messages of any kind, just this error in the build log.

Undefined symbols for architecture i386:
  "__TFSs15_arrayForceCastU___FGSaQ__GSaQ0__", referenced from:
      __TFC9MyProj6NavBar5stackfS0_FCSo20CDVInvokedUrlCommandT_ in NavBar.o

I managed to trace it down to this line of code, which worked fine on beta 5.

// A dictionary of String keys and arrays of NavBarItem instances as values.
var stacks: [String:[NavBarItem]] = [:]

func stack(cmd: CDVInvokedUrlCommand) {
    let stackName: String = cmd.arguments[0] as String

    if let stack = stacks[stackName] {

        // When I comment this line out I get a clean compile.
        navBar.setItems(stack, animated: false)

    }
}

My only guess is that it doesn't like be converting from a swift array to an NSArray somehow. Any ideas?

like image 209
Alex Wayne Avatar asked Aug 18 '14 23:08

Alex Wayne


3 Answers

I got this error even with the new version of Beta6 that was release hours after the bad one got pulled.

There are some significant changes in Beta 6 and looks like Xcode is getting confused. A full clean didn't work either.

I've solved this and other similarly illegible errors by deleting the contents of the Derived folder. You can find where that folder is located by going to Preferences > Locations.

The default path is: /Users/[your username]/Library/Developer/Xcode/DerivedData

like image 56
Paul Ardeleanu Avatar answered Oct 23 '22 15:10

Paul Ardeleanu


Launch Organizer and then hit the Delete button as shown below. Rebuild and the error will go away.

enter image description here

like image 5
RawMean Avatar answered Oct 23 '22 15:10

RawMean


I had the error. Sometimes Xcode has such problems. But with the app 'Watchdog' (available in the App Store), it did never happen again.

So Watchdog also solved this error for me. I think it did the same as @Paul Ardeleanu did manually.

Link to Mac App Store

like image 1
Binarian Avatar answered Oct 23 '22 17:10

Binarian