iPhone Development FAQs

Getting your UDID and install an AdHoc version

This guide explains how to determine the UDID of your iPhone and how to install an AdHoc version.

Downloading a tracking configuration and loading at runtime

It is possible to dynamically load a tracking configuration at runtime. For this it is necessary to host the tracking configuration on a server and download it to a temporary directory on the iPhone. There are different possibilities to download a file from the web:

  • Using Apple's <a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html#//apple_ref/doc/uid/20001836-BAJEAIEE" target="_blank">NSURLConnection</a>.
  • Using 3rd party libraries like <a href="http://allseeing-i.com/ASIHTTPRequest/" target="_blank">ASIHTTPRequest</a>.

To determine the cache directory for your application, have a look <a href="http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/StandardBehaviors/StandardBehaviors.html#//apple_ref/doc/uid/TP40007072-CH4-SW11" target="_blank">here</a>.

Once you've downloaded the tracking.xml_enc file to you iPhone, just load the downloaded tracking configuration by calling:

 unifeye->setTrackingData([pathToYourFile UTF8String]);

Note, that you have to preserve the file extension (xml_enc).

How to create Junaio like Billboards (text/images)

To create billboards with various content on them, its necessary to create the textures for the billboards on-the-fly and set the resulting image as texture for the billboard. Here are a few pointers how to achieve this

// initialize a UIImage with the background of the billboard
UIImage* bgImage = [UIImage imageNamed:@"img_poi_bg.png"];
   
// create a new image context with the size of the background image
UIGraphicsBeginImageContext( bgImage.size );         
CGContextRef currContext = UIGraphicsGetCurrentContext();
   
// mirror the context transformation to draw the images correctly
CGContextTranslateCTM( currContext, 0, bgImage.size.height );
CGContextScaleCTM(currContext, 1.0, -1.0);         
CGContextDrawImage(currContext,  CGRectMake(0, 0, bgImage.size.width, bgImage.size.height), [bgImage CGImage]);

// now bringt the context transformation back to what it was before
CGContextScaleCTM(currContext, 1.0, -1.0);               
CGContextTranslateCTM( currContext, 0, -bgImage.size.height );
   
// and add some text...
CGContextSetRGBFillColor(currContext, 1.0f, 1.0f, 1.0f, 1.0f);
CGContextSetTextDrawingMode(currContext, kCGTextFill);
CGContextSetShouldAntialias(currContext, true);
NSString* textToDraw = @"My billboard";
   
CGFloat actualFontsize; 
// draw the text to the current context
[textToDraw drawAtPoint:CGPointMake(10, 6) forWidth:(width-2*border) withFont:[UIFont boldSystemFontOfSize:16] minFontSize:12 actualFontSize:&actualFontsize lineBreakMode:UILineBreakModeTailTruncation baselineAdjustment:UIBaselineAdjustmentAlignCenters];    

// retrieve the image from the current context
UIImage* blendetImage = UIGraphicsGetImageFromCurrentImageContext();   
UIGraphicsEndImageContext();

The code above produces a UIImage that can now be set as the texture of an existing billboard by calling

unifeye->setMD2Texture( billboardSceneID, "uniqueIdentifier", [blendetImage CGImage] );

or by loading a new billboard

unifeye->loadImageBillboard( "myTextureName", [blendetImage CGImage] );

How to recognize touching/picking of Billboards / 3D models

Picking of billboards or 3D models can be done by implementing the touchesBegan method of the EAGLView. Within that view, just call Unifeye to provide the sceneID for a given location. The sceneID will be > 0 if a geometry is picked.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{   
   UITouch *touch = [touches anyObject];
   NSSet *allTouches = [event allTouches];
   CGPoint loc = [touch locationInView:self];
   

   int sceneID = [[IPhoneSceneManager sharedIPhoneSceneManager] unifeyeMobile]->getGeometryFromScreenCoordinates(loc.x, loc.y, true);
         
   // if we picked a new model
   if(sceneID != -1)
   {
      NSLog(@"We picked model %i", sceneID);
   }
}

How to add support for the retina screen

Its fairly easy to provide support for the retina screen. The most important step is to apply a scale factor to the EAGLView and make sure that the scale factor is also used by Unifeye.

- (id)initWithCoder:(NSCoder*)coder {
    
    if ((self = [super initWithCoder:coder])) {
      
      float os_version = [[[UIDevice currentDevice] systemVersion] floatValue];
      float scaleFactor = 1.0f;
      if( os_version >= 4.0 )
      {
         scaleFactor = [UIScreen mainScreen].scale;
         
         // this will scale the OpenGLView for retina screens
         self.contentScaleFactor = scaleFactor;
      }
      
        // Get the layer
        CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
        
        eaglLayer.opaque = YES;
        eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                        [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
        
        context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
        
        if (!context || ![EAGLContext setCurrentContext:context]) {
            [self release];
            return nil;
        }
        
        animationInterval = 1.0 / 30.0;
      
      // multiply with scale factor for retina screens
      unifeyeMobile = metaio::CreateARMobileSystem(320 * scaleFactor, 426 * scaleFactor);
   }
    return self;
}

Note, that all methods that use a pixel location like getGeometryFromScreenCoordinates or get3DPositionFromScreenCoordinates have to be adapted to make use of the scale factor:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event inView:(UIView*)view andScaleFactor:(float) scale
{   
   // Here's how to pick a geometry
   UITouch *touch = [touches anyObject];
   
   CGPoint loc = [touch locationInView:view];
   
   // ask unifeye if the user picked an object
   // the 'true' flag tells unifeye to actually use the vertices for a hit-test, instead of just the bounding box
   int sceneID = glView.unifeyeMobile->getGeometryFromScreenCoordinates(loc.x * scale, loc.y * scale, true);
   
   if ( sceneID > 0 )
   {
      // we have touched the metaio man
      // let's start an animation
      glView.unifeyeMobile->startAnimation( sceneID, "shock_down" );
   }
}

Running on Simulator

It is possible to compile your application for the iPhone Simulator. However, the simulator does not provide a camera and certain APIs are not available on the iPhone Simulator.

Therefore, if you're using the AVCaptureVideoPreviewLayer to draw the camera image, you must exclude the respective code section from compilation for iPhone Simulator:

- (void) applyPreviewLayer
{
   // AVCapture is not entirely available on iPhoneSimulator.
#if !TARGET_IPHONE_SIMULATOR
   float iPhoneSDKVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
   if( iPhoneSDKVersion >= 4.0 )
   {
      // Get a preview layer for the camera
      AVCaptureVideoPreviewLayer* previewLayer = glView.unifeyeMobile->getCameraPreviewLayer();
      // resize the layer to our preview size
      previewLayer.frame = previewView.bounds;
      // Add the preview as a sublayer
      [previewView.layer addSublayer:previewLayer];
   }
#endif
}

What is the best way of delivering image assets for the GUI

Please have a look at the specifications here.

How to submit a crash report on iPhone?

Here are the steps:

  1. Connect your iPhone with your PC and synch it using iTunes
  2. After it is done, the crash logs will be stored to this folder:
  • Mac OS X : ~/Library/Logs/CrashReporter/MobileDevice/<DEVICE_NAME>
  • Windows XP: C:\Documents and Settings\<USERNAME>\Application Data\Apple computer\Logs\CrashReporter/<DEVICE_NAME>
  • Windows Vista: C:\Users\<USERNAME>\AppData\Roaming\Apple computer\Logs\CrashReporter/MobileDevice/<DEVICE_NAME>

Alternatively, you can also let iTunes automatically submit them by syncing your iPhone with iTunes.

Note: iTunes has to be allowed to do that – in case you deactivated this the first time you connected your phone, you can just open iTunes preferences / Advanced / click on 'Reset all dialog warnings'

When you sync your phone you should get a screen like this:

Select OK, then the crash reports will automatically be transmitted through iTunesConnect to our developer portal.

Developing for iPad 2

UnifeyeSDKMobile is also compatible with iPad 2. Just initialize your EAGLView and Unifeye with the native iPad resolution of 1024x768:

      float scaleFactor = [UIScreen mainScreen].scale;
   
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        unifeyeMobile = metaio::CreateARMobileSystem(768, 1024);
    }
    else
    {        
        unifeyeMobile = metaio::CreateARMobileSystem(360 * scaleFactor, 480 * scaleFactor);
    }

Also please adjust the XIB files to be in native iPad resolution, then the OpenGL context will also be created in that size.

In addition to that you have to make sure that you build your application as an iPad application. The target configuration for your application should show 'iPad' or 'Universal':
Screen_shot_2011-04-04_at_9.33.31_AM.png

Submission process for the Appstore

For app store submission you need to do the following:

List of required elements for submission preparation

  • Application Name (must be unique, 255 characters max)
  • Application Description (4000 chars max, 700 chars recommended, plain text only, use section headers/bullets for easy reading, no keyword list here)
  • Countries for submission
  • Primary Category: choose from list (book, business, education, entertainment, finance, games, healthcare/fitness, lifestyle, medical, music, navigation, news, photography, productivity, reference, social network, sports, travel, tools, weather) -> check current list in app store, is extended…
  • Secondary Category : choose from list (see above)
  • Copyright: 2011, XXX, rights reserved
  • Version Number: 1.0
  • SKU Number: made up number
  • Keywords (Keywords can only be edited with the submission of a new binary. 100 Characters Max. )
  • Support URL
  • Contact Email Address
  • Application URL (optional)
  • Review notes (optional): help Apple to understand how to test your app
  • At least 1 screenshot as PNG (iPhone and iPad screenshot if applicable)
  • Application icon as PNG with 512x512 pixel
Topic revision: r1 - 2011-12-06 - 10:31:27 - SupportMetaio
 
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback