Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Faddah Wolf
12,811 Pointsfatal error: unexpectedly found nil while unwrapping an Optional value (lldb) in Build A Simple App in Swift for iOS
hi,
i continue to have problems between what seems so easy in the videos for the instructor and what i actually experience in Xcode.
my set-up: iMac 27" 2010 model, intel i7 2.8 GHz processor, 16 GB of RAM, the latest Mac OS X 10.10 Yosemite with all possible updates and Xcode 6.1 installed, with all the Xcode 6.1 Command Line Tools.
i'm on one of the final steps in the Build A Simple iPhone App with Swift for iOS, the Deploying To A Device > App Icons and Launch Screens section of the module. the code i am using is the downloaded code from the module and the app icons are from the downloaded assets in the module.
when i attempt to build for my iPhone 5 with the latest iOS 8.1, with has been properly added as a test device and given apple certification, as per previous steps, the build on the iPhone fails with —
fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)
and a huge, inner debugging screen comes up, here is an excerpt from that with the relative debugging call pointed out with a >>
—
0x2017f0: mov r0, r11
0x2017f4: blx 0x34ec98 ; swift_release
0x2017f8: mov r0, r11
0x2017fc: blx 0x34ec98 ; swift_release
>> 0x201800: trap Thread 1: EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xe7ffdefe)
0x201804: mov r0, #0x0
0x201808: cmp r5, #0xd800
0x20180c: str r0, [sp, #52]
0x201810: str r0, [sp, #48]
0x201814: blo 0x201844 ; Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> () + 232
on my iPhone 5 with the latest iOS 8.1, it simply freezes on the launch "Did you know?" smash screen the teacher in the video had us create, never goes beyond the launch splash screen to the app.
if i try and run it in a simulator instead of my live iPhone 5 iOS device, it trips up the same fatal error issue, only on this section of the code in the ViewController.swift —
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var funFactLabel: UILabel!
@IBOutlet weak var funFactButton: UIButton!
let factBook = FactBook()
let colorWheel = ColorWheel()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
>> funFactLabel.text = factBook.randomFact()
} Thread 1: EXC_BAD_INSTRUCTION(code=EXC_I386_INVOP, subcode=0x0)
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func showFunFact() {
var randomColor = colorWheel.randomColor()
view.backgroundColor = randomColor
funFactButton.tintColor = randomColor
funFactLabel.text = factBook.randomFact()
}
}
this never happened in stepping through the previous sections of this Build A Simple iPhone App with Swift module with this exact same code. what is going on here??
can anyone please help me here in getting this fixed and running on my iOS device? thank you in advance.
best,
— faddah wolf portland, oregon, u.s.a.
4 Answers

Pasan Premaratne
Treehouse TeacherCan you post your code to Github with a link to the repo so I can look through your entire project?

Faddah Wolf
12,811 Pointshello Pasan Premaratne !
thank you for getting back to me so quickly. so yes, i have set-up the GitHub repo for you on the FunFacts code from your “Build A Simple iPhone App with Swift” where i was seeing this, fatal error, here.
Please keep in mind —
- i didn't do much of anything with this code, it was the downloaded from Treehouse code from this latest section of your “Build A Simple iPhone App with Swift” module. All I did was add the also downloaded from Treehouse App Icons graphic assets.
- this happened with mac os x 10.10 Yosemite, with all current updates, and Xcode 6.1 with the Xcode 6.1 Command Line tools.
please let me know what you find on this. thank you for your responsiveness here.
best,
— faddah wolf portland, oregon, u.s.a.

Pasan Premaratne
Treehouse Teacherhey Faddah Wolf
It looks like some point between when you downloaded the project files from the video and when you ran it, the funFactLabel in your viewController file lost reference to the object in Interface Builder.
I double checked that this issue wasn't automatically happening when you downloaded the project files and it isn't so it probably happened by mistake.
I made you a little video to show how to quickly solve the issue. You will need to full screen it to see it clearly.
Hope this helps!

Faddah Wolf
12,811 Pointsgreat video and normally i would say, that would be it — however, that won't do it for me. remember this problem i was having, here? — [Getting an error in Xcode 6.0.1 when trying to connect the button in iOS-Swift - Build A Simple iPhone App With Swift].(https://teamtreehouse.com/forum/getting-an-error-in-xcode-601-when-trying-to-connect-the-button-in-iosswift-build-a-simple-iphone-app-with-swift "Treehouse forum post by faddah: “Getting an error in Xcode 6.0.1 when trying to connect the button in iOS-Swift - Build A Simple iPhone App With Swift.”").
that is all still happening for me, unfortunately.
i still don't get the connecting dots to connect between line number margin of the ViewController.swift code in the Xcode Assistant Editor and the Main.storyboard. and if i try and draw connections between Label or Button elements in Main.storyboard and drop them in the code and fill out the pop-up, when i click "connect" on the pop-up button, i still get the error: “(!) Could not insert new action connection: Could not find any information for the class named ViewController.” even though i'm right in the ViewController.swift file in the Assistant Editor.
and i still have not gotten any response that would help with that from my post at the Apple Developer forum.
and yes, i have deleted the Users > [User Name] > Library > Developer > Xcode > Derived\ Data folder, several times. i even have the WatchDog app for mac os x with Xcode to wipe that info for me every time i exit Xcode or when i do a command to do it manually for me.
so i don't know what to do here. maybe re-download the code from the Treehouse site for your module and try again?
thank you for responding and trying to help, it is much appreciated, in any case.
best,
— faddah wolf portland, oregon, u.s.a.