Tagged: Xcode Toggle Comment Threads | Keyboard Shortcuts

  • Jay Versluis 11:11 pm on March 16, 2013 Permalink | Reply
    Tags: Xcode   

    Categories: iOS ( 222 )

    What is an Exception Breakpoint 

    Sometimes Xcode just throws an error message that isn’t very helpful. That’s usually when we have to try and figure out why something didn’t go the way we expected it. Other times however, Xcode tells us very clearly which element it isn’t happy with – we fix it and our app progresses. Why can’t it always be that way?

    Well that’s because at those unhelpful times, Xcode is technically picking up an “exception”, but it tries to continue to run the programme. That’s when we end up with an error message which isn’t related to the actual problem.

    An Exception Breakpoint can help. It’s something we can set and therefore force Xcode to stop when the problem occurs, not several lines later. Here’s how we do it:

    • with the Navigator pane open, select the 6th tab from the left (the Breakpoint Navigator)
    • at the bottom left, click the plus sign to add a breakpoint
    • from the context menu select Add Exception Breakpoint
    • leave all default values and hit Done

    Next time Xcode will not try to be heroic and keep going. Instead, expect a more helpful error message.

    Screen Shot 2013-03-16 at 23.03.17

    Also check out: https://developer.apple.com/library/ios/#recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html





     
  • Jay Versluis 11:53 pm on March 6, 2013 Permalink | Reply
    Tags: Xcode   

    Categories: iOS ( 222 )

    Hilarious Xcode Error Message 

    Xcode_iconI’ve been working on an iOS App recently which deals with several date methods. Usually when something goes wrong Xcode displays very dry messages such as “Array out of bounds” or something rather unhelpful (like the complete stack output with no clue as to what actually went wrong).

    I was accidentally passing nil into an NSDateComponents method – and instead of crashing (which is what I would have expected), Xcode displayed this super funny message in the log console:

    [__NSCFCalendar components:fromDate:toDate:options:]:

    toDate cannot be nil

    I mean really, what do you think that operation is supposed to mean with a nil toDate?

    An exception has been avoided for now. A few of these errors are going to be reported with this complaint, then further violations will simply silently do whatever random thing results from the nil.

    It made me smile 🙂

    (More …)





     
  • Jay Versluis 1:29 pm on February 24, 2013 Permalink | Reply
    Tags: accidental outlet, Xcode   

    Categories: iOS ( 222 )

    How to fix “this class is not key value coding-compliant” after accidentally adding an IBOutlet instead of an IBAction 

    It has happened to us all: you’re in a storyboard, you’re using the Assistant Editor, you want to control-drag from a button into your code and create an action.

    But sadly you forget to select “Action” from the drop down menu and instead create an outlet.

    No biggie you think, deleting the outlet code. You go back and create the action properly, run the app… and get an error message such as this one:


    *** Terminating app due to uncaught exception ‘NSUnknownKeyException’, reason: ‘[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key badAction.’

    Yikes! Unless you’re using Version Control, there is no way to undo adding that bad outlet. So you ask yourself: Will I have to start from scratch, or is there a way to fix your app?

    Yes this is fixable – all we need to do is examine our storyboard file in Source Code mode, then find the problem and eliminate it. Here’s how you do it:

    • With the left pane open (Navigation Inspector, showing all your files), select your storyboard and right click/control click to bring up the context menu. Select View as Source Code

    badAction1

    This will allow you to see what the storyboard actually looks like in XML. Hit Option+F to bring up the Find in Context menu. Now search for whatever is causing you a headache, then delete the entire line. Make sure the opening and closing brackets are selected too.

    In my case, all this needs to go:

    <outlet property="badAction" destination="4R8-F9-Xhb" id="8xN-t2-22c"/>

    badAction2
    You may see more than one occurrence of your action in this file – we only want to get rid of the “outlet”reference here. If you delete all occurrences it’s not a big problem, but you will have to re-connect your actions to the code later.

    Once you’re done, run the app again and all should be fine.

    To display the storyboard in the visual editor again, just control-click the file file again, and select “Open as – Interface Builder, iOS Storyboard”.





     
    • Chris 6:48 am on July 25, 2013 Permalink | Reply

      Genius! This really helped me! Thanks a lot! Enthusiasm!

    • Apfel 10:11 am on November 17, 2014 Permalink | Reply

      Thanks!!

  • Jay Versluis 10:26 pm on January 4, 2013 Permalink | Reply
    Tags: Xcode   

    Categories: iOS ( 222 )

    When Xcode 4.5 suddenly stops running your app on a device (could not launch app) 

    I’ve had this problem that Xcode 4.5 would run my app fine in the simulator, but didn’t do so anymore on the device. Something about the “derived data folder was not found”. I checked, it was definitely there.

    Then I found this post on Stackoverflow to show some suggestions: http://stackoverflow.com/questions/11456312/xcode-suddenly-stopped-running-project-on-hardware-could-not-launch-xxx-app

    This solution worked for me – Thanks Dhilip: http://dhilipsiva.blogspot.in/2012/07/xcode-could-not-launch-app-no-such-file.html





     
  • Jay Versluis 4:07 pm on December 23, 2012 Permalink | Reply
    Tags: , , , Xcode   

    Categories: How To ( 30 )

    How to use Xcode with a remote Git server 

    Xcode_iconImagine you’ve created a project in Xcode with a local Git repository. Now you’d like to put this online so that others can collaborate with you. How do you do that?

    This has been puzzling me for a while, and there doesn’t seem to be a clear documentation on this subject – so I’ve decided to take some notes as I figured it out. Here are step by step instructions on how to make it work.

    All we need is a server running Git and SSH credentials to that server to get started.

    (More …)





     
    • Jaro 12:56 pm on April 2, 2013 Permalink | Reply

      But what if I dont wish to make a new bare repository. Instead I wish to use the local .git file that is here: /%PROJECT FOLDER%/.git ?

      • Jay Versluis 2:16 pm on April 2, 2013 Permalink | Reply

        Hi Jaro,

        In that case, just head over to the Xcode Repository browser (in the Organizer) and click the little plus icon on the bottom left. You can add a local repository there.

c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel