My app thinks it is a phone. Why?

  • My app (iOS 5.1) has a xib called MainWindow.xib which does NOT contain a window, just two objects, one of this is an UIApplicationDelegate.

    This UIApplicationDelegate has:

    - (void)applicationDidFinishLaunching:(UIApplication *)application
    {
    NSLog(@"%s %u",__FUNCTION__,[[UIDevice currentDevice] userInterfaceIdiom]);
    ...
    }

    When I run this in iPad 5.1 Simulator, it prints "0" = UIUserInterfaceIdiomPhone.

    Why does this thing delude itself being a phone?

    (This was an iPhone project, which I am now trying to make universal).

    Kind regards,

    Gerriet.
  • On May 5, 2012, at 10:15 PM, Gerriet M. Denkmann wrote:

    > My app (iOS 5.1) has a xib called MainWindow.xib which does NOT contain a window, just two objects, one of this is an UIApplicationDelegate.
    >
    > This UIApplicationDelegate has:
    >
    > - (void)applicationDidFinishLaunching:(UIApplication *)application
    > {
    > NSLog(@"%s %u",__FUNCTION__,[[UIDevice currentDevice] userInterfaceIdiom]);
    > ...
    > }
    >
    > When I run this in iPad 5.1 Simulator, it prints "0" = UIUserInterfaceIdiomPhone.
    >
    > Why does this thing delude itself being a phone?
    >
    > (This was an iPhone project, which I am now trying to make universal).

    Are you sure you've configured your application to target both iPhone and iPad? Check that the Project and Target levels match and say the same thing.
    --
    David Duncan
  • On 8 May 2012, at 01:08, David Duncan wrote:

    > On May 5, 2012, at 10:15 PM, Gerriet M. Denkmann wrote:
    >
    >> My app (iOS 5.1) has a xib called MainWindow.xib which does NOT contain a window, just two objects, one of this is an UIApplicationDelegate.
    >>
    >> This UIApplicationDelegate has:
    >>
    >> - (void)applicationDidFinishLaunching:(UIApplication *)application
    >> {
    >> NSLog(@"%s %u",__FUNCTION__,[[UIDevice currentDevice] userInterfaceIdiom]);
    >> ...
    >> }
    >>
    >> When I run this in iPad 5.1 Simulator, it prints "0" = UIUserInterfaceIdiomPhone.
    >>
    >> Why does this thing delude itself being a phone?
    >>
    >> (This was an iPhone project, which I am now trying to make universal).
    >
    >
    > Are you sure you've configured your application to target both iPhone and iPad? Check that the Project and Target levels match and say the same thing.

    You are absolutely right: it turned out to be wrong settings:

    1. Target → Info → Application requires iPhone environment was YES
    2. Bild Settings → Deployment → Targeted Device Family was just iPhone

    The first one I found early, the second one many hours after asking the list.

    I think this is a general Xcode problem: starting with the right template everything is very smooth.
    But changing directions later (like iPhone only to universal, or non-document-based to document-based) is kind of difficult - there are so many settings which may or may not be relevant.

    It would be rather nice if Xcode allowed me formulate a wish (like "This project should be universal") and it answered with a list of things which must be (or probably should be) done:
    Like: "Targeted Device Family must be changed to iPhone/iPad" and some buttons: "Show me" and: "Please do it for me".
    Followed by: "Read more about this in the xxx-Guide" with a helpful button: "Open in Browser".

    Such a list probably cannot be exhaustive (even if following all suggestions, some problems might remain) but it would very helpful indeed.

    Kind regards,

    Gerriet.
  • On May 7, 2012, at 10:14 PM, Gerriet M. Denkmann wrote:

    >
    > On 8 May 2012, at 01:08, David Duncan wrote:
    >
    >> On May 5, 2012, at 10:15 PM, Gerriet M. Denkmann wrote:
    >>
    >>> My app (iOS 5.1) has a xib called MainWindow.xib which does NOT contain a window, just two objects, one of this is an UIApplicationDelegate.
    >>>
    >>> This UIApplicationDelegate has:
    >>>
    >>> - (void)applicationDidFinishLaunching:(UIApplication *)application
    >>> {
    >>> NSLog(@"%s %u",__FUNCTION__,[[UIDevice currentDevice] userInterfaceIdiom]);
    >>> ...
    >>> }
    >>>
    >>> When I run this in iPad 5.1 Simulator, it prints "0" = UIUserInterfaceIdiomPhone.
    >>>
    >>> Why does this thing delude itself being a phone?
    >>>
    >>> (This was an iPhone project, which I am now trying to make universal).
    >>
    >>
    >> Are you sure you've configured your application to target both iPhone and iPad? Check that the Project and Target levels match and say the same thing.
    >
    > You are absolutely right: it turned out to be wrong settings:
    >
    > 1. Target → Info → Application requires iPhone environment was YES
    > 2. Bild Settings → Deployment → Targeted Device Family was just iPhone
    >
    > The first one I found early, the second one many hours after asking the list.
    >
    > I think this is a general Xcode problem: starting with the right template everything is very smooth.
    > But changing directions later (like iPhone only to universal, or non-document-based to document-based) is kind of difficult

    FWIW, I've found this to be the general case in Xcode, at least with iOS development.  IF you do everything right from the start, and know the right way to go, it's not a big deal, but for those who try things out and explore, it ends up being rather easy to be caught in a mess with many hours wasted and not understanding what went right and why.

    We faced similar problems when creating Macromedia's Director back last century, and I see similar cases with storyboarding in Xcode. Sometimes, if you're used to doing everything in code, it's impossible to figure out why the storyboard feature is crashing Xcode, what's tied in to, what and where it should be tied to.  Maybe having some feature in Storyboarding that puts a red alert badge over a item whose contents aren't completely/properly wired up, or at least an indicator - much like the warning indicators in the build process.

    Simply indicating storyboard items that have an action, but no delegate, outlet or view connection would eliminate a lot of crashes and "why isn't this thing doing anything" brain freezes.
  • On May 7, 2012, at 7:14 PM, Gerriet M. Denkmann wrote:

    > On 8 May 2012, at 01:08, David Duncan wrote:
    >
    >> On May 5, 2012, at 10:15 PM, Gerriet M. Denkmann wrote:
    >>
    >>> My app (iOS 5.1) has a xib called MainWindow.xib which does NOT contain a window, just two objects, one of this is an UIApplicationDelegate.
    >>>
    >>> This UIApplicationDelegate has:
    >>>
    >>> - (void)applicationDidFinishLaunching:(UIApplication *)application
    >>> {
    >>> NSLog(@"%s %u",__FUNCTION__,[[UIDevice currentDevice] userInterfaceIdiom]);
    >>> ...
    >>> }
    >>>
    >>> When I run this in iPad 5.1 Simulator, it prints "0" = UIUserInterfaceIdiomPhone.
    >>>
    >>> Why does this thing delude itself being a phone?
    >>>
    >>> (This was an iPhone project, which I am now trying to make universal).
    >>
    >>
    >> Are you sure you've configured your application to target both iPhone and iPad? Check that the Project and Target levels match and say the same thing.
    >
    > You are absolutely right: it turned out to be wrong settings:
    >
    > 1. Target → Info → Application requires iPhone environment was YES
    > 2. Bild Settings → Deployment → Targeted Device Family was just iPhone
    >
    > The first one I found early, the second one many hours after asking the list.

    The first one actually doesn't do what you think. Thats just an Info.plist flag so that the Finder doesn't try to launch the application if you find and double click it. iOS ignores it completely (in this case iPhone environment just means iOS, the flag is a hold over from before the OS had an official name).

    The second one does what you needed done.

    > I think this is a general Xcode problem: starting with the right template everything is very smooth.
    > But changing directions later (like iPhone only to universal, or non-document-based to document-based) is kind of difficult - there are so many settings which may or may not be relevant.
    >
    > It would be rather nice if Xcode allowed me formulate a wish (like "This project should be universal") and it answered with a list of things which must be (or probably should be) done:
    > Like: "Targeted Device Family must be changed to iPhone/iPad" and some buttons: "Show me" and: "Please do it for me".
    > Followed by: "Read more about this in the xxx-Guide" with a helpful button: "Open in Browser".
    >
    > Such a list probably cannot be exhaustive (even if following all suggestions, some problems might remain) but it would very helpful indeed.

    There are almost certainly places where this could be made better, so please file a bug report asking that things like this be made easier.
    --
    David Duncan
previous month may 2012 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today