Tagged: Xcode RSS Toggle Comment Threads | Keyboard Shortcuts

  • Ullrich 17:59 on 20. March 2012 Permalink | Reply
    Tags: , , Xcode   

    Tabs Don’t you hate tabs I mean the… 

    Tabs… Don’t you hate tabs? I mean, the idea is nice, saving bytes and stuff. But the world isn’t ready for them yet.

    Here’s our Xcode indentation settings:

    And here are two lines of shell script that will help you clean up your already messed up code base :)

    find ./ -iname '*.[hcm]' -type f -exec gsed -i 's/\t/    /g' {} \;
    find ./ -iname '*.[hcm]' -type f -exec gsed -i '/^[ \t]*$/! { s/[ \t]*$//g }' {} \;

    What they’ll do is, 1st of all replacing all existing tabs by four spaces. The second command takes care of trailing whitespace (but not in lines that only contain whitespace), because we also hate that! :-D

    All that require the GNU version of sed. OSX ships with the BSD version, so you need to install it via

    brew install gnu-sed
     
  • Ullrich 12:12 on 1. March 2012 Permalink | Reply
    Tags: , , Xcode   

    Missing your opendiff? 

    Since I Xcode 4.3 the opendiff terminal command didn’t work any longer.

    Here’s how I fixed it:

    sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer
     
  • Ullrich 13:05 on 15. February 2012 Permalink | Reply
    Tags: , , , Xcode   

    AppStore validation error on app icons (-19007) 

    
    

    Since upgrading to OS X 10.7.3 you see this Xcode build warning?

    Icon specified in the Info.plist not found under the top level app wrapper: Icon-72.png (-19007)
    iPad: Icon.png: icon dimensions (57 x 57) don't meet the size requirements. The icon file must be 72x72 pixels, in .png format (-19014)

    This is going to turn into an validation error as soon as you try to upload a new build to the AppStore™.

    Here’s the fix:

    Install a new version of the Application Loader. The download link is hard to find (hard to google), so here’s one for version 2.5.1 (most current when writing this article).

    The most current version can be found under “Manage your applications” in iTunesConnect.

     
  • toto 18:50 on 1. February 2012 Permalink | Reply
    Tags: , , Xcode   

    Debug broken code highlighting in Xcode 4 

    If you use Xcode 4 a lot this might have happened to you, too: Coloring and code completion fail and do not come back. Which makes working with Xcode almost impossible

    This happens when Xcode’s indexing process fails for some reason. This can be a header file is missing to code highlighting (which can be different from the compiler in some cases) or in some cases a bad #define. The problem is that it fails silently so you cannot fix it.

    After having this problem with a big project I stumbled onto the magic hint on Stack Overflow.  After you quit Xcode enter this into a shell:

    defaults write com.apple.dt.Xcode IDEIndexingClangInvocationLogLevel 3

    After this you should open the project and see messages like this:

    Xcode: IDEIndexingClangInvocation: Failed to save PCH file: /Users/user/Library/Developer/Xcode/DerivedData/Project-drsrrgaenperjadmqslqfxyqcqyt/Index/PrecompiledHeaders/Some-Prefix-cgepzuvkwimbsvcmqrbbpeoyhdpz_ast/Some-Prefix.pch.pth

    Looking through these messages will show you what goes on and might help you finding the problem.

    For me it was just copying header files from a framework on the place the Clang parser was looking for them.

     
  • Ullrich 09:14 on 14. October 2010 Permalink | Reply
    Tags: , , , , Xcode   

    Colliding Category Methods 

    After multiple years of Objective-C experience yesterday was the first time that we actually ran into problems with colliding methods in categories.

    Here’s the story (you may skip this part): The issue was, that we added a method -setParameters: to NSMutableURLRequest which takes a dictionary and set’s it as query string or multipart form body depending on the HTTP Method used for sending the request. This method sadly conflicted with a category on the same class defined in a library called OAuthConsumer which doesn’t take a dictionary as argument but rather an array of key-value pairs. Both categories we’re linked to our application as static libraries.

    The result was that our -setParameters: was called with an array although a dictionary was expected. We noticed the problem since NSArray is not responding to -allKeys. It could have gone would have not noticed the problem. Just imagine trying to debug a misbehavior when you’re looking at the wrong piece of code.

    The quintessence, and what basically helped us finding the issue is a environment variable named OBJC_PRINT_REPLACED_METHODS. Similar to NSZombieEnabled you set it in the Arguments tab of your executable info as variable set to environment. Just like this:

     
  • Ullrich 15:57 on 1. September 2010 Permalink | Reply
    Tags: , Framework, Mac, , Xcode   

    Embedded Frameworks 

    When embedding frameworks to your Mac app there might be problems of finding a header file. There are three things to check for:

    • The framework needs to have @executable_path/../Frameworks as Installation Directory in it’s build settings.
    • The app should include the following in its framework search path: “$(CONFIGURATION_BUILD_DIR)/$(CONTENTS_FOLDER_PATH)/Frameworks” (including the quotes!)
    • Also make sure to have a Copy Frameworks build phase and that your famework is added to it.
     
    • Ullrich 16:24 on 13. September 2010 Permalink

      When you’re importing the header files make sure to import them “framework style”:

      #import <TheFramework/TheHeader.h>

      If you still can’t find your framework headers make sure your target is actually linked against them.

  • Ullrich 11:21 on 10. May 2010 Permalink | Reply
    Tags: , Xcode   

    No 1 in (serious) series of coding style posts: Private methods

    Declaring private methods in a class extension (like an anonymous category) rather than a named category makes the compiler warn you when those methods aren’t implemented.

    # MyClass.h
     
    @interface MyClass : NSObject {
    }
    - (void)publicMethod;
    @end
     
     
    # MyClass.m
     
    #include "MyClass.h"
     
    @interface MyClass ()
    - (void)privateMethod;
    @end
     
     
    @implementation MyClass
     
    - (void)publicMethod;
    {
        NSLog(@"public");
    }
     
    - (void)privateMethod;
    {
        NSLog(@"very private");
    }
     
    @end
     
    • Gernot 12:55 on 20. July 2010 Permalink

      Also: With the new Runtime, you can declare private ivars in a class extension. The new Runtime is available on the iPhone since 3.0 (might be 3.1 I’m not sure now) and on the Simulator of XCode 4.

  • Ullrich 13:02 on 26. April 2010 Permalink | Reply
    Tags: , Xcode   

    If you want your subviews rendered before the alpha value is applied you can use the UIViewGroupOpacity Info Plist setting.

     
  • Ullrich 15:34 on 16. April 2010 Permalink | Reply
    Tags: , Xcode   

    My list of breakpoints. Add them to your ~/.gdbinit

    fb -[NSException raise]
    fb -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:]
    fb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
     
    fb NSKVODeallocateBreak
     
    fb _NSAutoreleaseNoPool
     
    fb -[_NSZombie init]
    fb -[_NSZombie retainCount]
    fb -[_NSZombie retain]
    fb -[_NSZombie release]
    fb -[_NSZombie autorelease]
    fb -[_NSZombie methodSignatureForSelector:]
    fb -[_NSZombie respondsToSelector:]
    fb -[_NSZombie forwardInvocation:]
    fb -[_NSZombie class]
    fb -[_NSZombie dealloc]
     
    fb szone_error
     
    fb objc_exception_throw
    fb malloc_error_break
     
    fb CGPostError
    fb malloc_printf
    fb _objc_error
    fb objc_exception_during_finalize_error
    fb auto_zone_resurrection_error
    fb auto_refcount_underflow_error

    UPDATE: added _NSAutoreleaseNoPool breakpoint to stop when there’s no autorelease pool but one is expected.

     
  • Ullrich 11:53 on 27. November 2009 Permalink | Reply
    Tags: , Xcode   

    Use NSAssert(…) during development.
    But set NS_BLOCK_ASSERTIONS pre compiler flag for release.

     
    • toto 15:23 on 17. May 2010 Permalink

      NS_BLOCK_ASSERTIONS=1 Seems to be default in XCode 3.2

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