How to get my iOS4.2 SDK developed code working with iOS3.1.3?

Discussion in 'iOS Programming' started by Akshata, Jul 5, 2011.

  1. Akshata, Jul 5, 2011
    Last edited by a moderator: Jul 5, 2011

    Akshata macrumors newbie

    Jul 5, 2011
    I am new to iPhone development. I started developing a project using iOS4.2 SDK. It works properly on both an iOS4.2 device and simulator. Later I realized that my app wasn't working on devices with iOS3.1.3. To solve this I updated the "Deployment Target" in my app's configuration file to "3.1.3".

    The problem I am having is that I use UITapGestureRecognizer in some of my classes. On compiling my code using iOS 3.1.3 SDK I get the following errors:

    error: 'UITapGestureRecognizer' undeclared (first use in this function)
    error: 'tap' undeclared (first use in this function)

    From what I have ready, this seems to be because iOS3.1.3 does not support UITapGestureRecognizer, so to run this i made the following changes wherever I use UITapGestureRecognizer:

     Class mailClass = (NSClassFromString(@"UITapGestureRecognizer"));
       if(mailClass != nil)
         UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(findOutTheTagmap:)];
         [imageView addGestureRecognizer:tap];
         [tap release];
    I also updated my Target configuration and set the UIKit Framework to "Weak". Additionally I have also made the following changes:
    Base SDK: 3.1.3
    Compiler Version: GCC4.2 (also tried with GCC4.0)
    Mac OS X Deployment Target: Compiler Default (also tried with 10.4 and 10.6)
    iOS Deployment Target: 3.1.3

    Yet, when I try compiling my code, I am still shown the same errors. What is surprising is that a few days ago someone was helping me and this worked.

    I have tried pretty much everything I have found in forums.

    Does anyone have an idea on how I can proceed?

    Thanks in advance!
  2. PhoneyDeveloper macrumors 68030


    Sep 2, 2008
    I recommend that you forget about this. There is very little reason for new code to support 3.1.3. I would use 4.0 as the oldest OS to support unless you have some very good reason for going older than that.
  3. jiminaus macrumors 65816


    Dec 16, 2010
    You can't use UITapGestureRecognizer at all. You must keep the code completely dynamic, or use conditional compilation.

    An example of keeping it completely dynamic.

       Class [COLOR=blue]uiTapGestureRecognizerClass[/COLOR] = NSClassFromString(@"UITapGestureRecognizer");
       if([COLOR=blue]uiTapGestureRecognizerClass[/COLOR] != nil)
         [COLOR=blue]UIGestureRecognizer[/COLOR] *tap = [[[COLOR=blue]uiTapGestureRecognizerClass[/COLOR] alloc] initWithTarget:self action:@selector(findOutTheTagmap:)];
         [imageView addGestureRecognizer:tap];
         [tap release];

Share This Page