Updating the iOS Hybrid Web Container Project

After upgrading the PhoneGap library to Cordova, you must update the Hybrid Web Container project.

  1. In Xcode, in the Project Navigator, open WorkFlow.xcodeproj.
  2. Select the WorkFlow project so that the project settings screen is displayed, then select the WorkFlow target, find the Other Linker Flags entry, and for each configuration, replace all instances of "libPhoneGap.a" with "libCordova.a."
  3. Create two directories: WorkFlow/CordovaLib and WorkFlow/CordovaLib/Classes.
  4. Copy all of the .h files from ~/Documents/CordovaLib/Classes to WorkFlow/CordovaLib/Classes.
    Be sure to get all .h files, even in nested directories.
  5. Again, open the project settings screen, find the Header Search Paths entry, and change all instances of "PhoneGapLib" to "CordovaLib."
  6. In the Xcode project, perform two global search-and-replace operations:
    1. Replace all instances of USE_PHONEGAP with USE_CORDOVA.
    2. Replace all instances of PHONEGAP_FRAMEWORK with CORDOVA_FRAMEWORK.
      After this, it is assumed that the code no longer includes references to USE_PHONEGAPand instead contains references to USE_CORDOVA.
  7. In the Xcode Project Navigator, find and open the WorkFlowAppDelegate.h file in the Classes group folder.
    1. Near the top of the file, replace the import of PhoneGapDelegate.h.
      The import should look like this:
      #ifdef USE_CORDOVA
      #ifdef CORDOVA_FRAMEWORK
      #import <Cordova/CDVViewController.h>
      #import <Cordova/CDVContacts.h>
      #else
      #import "CDVViewController.h"
      #import "CDVContacts.h"
      #endif
      #endif
      
      Note: USE_PHONEGAP has already been changed to USE_CORDOVA, and PHONEGAP_FRAMEWORK to CORDOVA_FRAMEWORK.
    2. Find the declaration of the SUPWorkFlowAppDelegate interface, and in the #ifdef USE_CORDOVA block, change the super class from PhoneGapDelegate to CDVViewController.
    3. In the same #ifdef block, add the UIApplicationDelegate protocol to the list of implemented protocols.
  8. In Xcode Project Navigator, find the WorkFlowAppDelegate.m file, which is located next to WorkFlowAppDelegate.h.
    1. Near the top of the file, remove the entire #ifdef USE_CORDOVA block that is currently importing PhoneGapDelegate.h, as this is already done in WorkFlowAppDelegate.h, and is unnecessary here.
    2. Find the application:didFinishLaunchingWithOptions: and remove the entire contents of the #ifdef USE_CORDOVA block at the very end:
      #ifdef USE_CORDOVA   
      if ( [super respondsToSelector:@selector(application:didFinishLaunchingWithOptions:)])      
      [super application:[UIApplication sharedApplication] didFinishLaunchingWithOptions:launchOptions];
      #endif
    3. Find the applicationDidBecomeActive: function and remove the entire contents of the #ifdef USE_CORDOVA block at the very end:
      #ifdef USE_CORDOVA   
      if ( [super respondsToSelector:@selector(applicationDidBecomeActive:)])      
      [super applicationDidBecomeActive:application]; 
      #endif
    4. Find the applicationWillResignActive: function and remove the entire contents of the #ifdef USE_CORDOVA block at the very end:
      #ifdef USE_CORDOVA   
      if ( [super respondsToSelector:@selector(applicationWillResignActive:)])      
      [super applicationWillResignActive:application]; 
      #endif
    5. Find the applicationWillTerminate: function and remove the entire contents of the #ifdef USE_CORDOVA block at the very end:
      #ifdef USE_CORDOVA   
      if ( [super respondsToSelector:@selector(applicationWillTerminate:)])      
      [super applicationWillTerminate:application];
      #endif
    6. Find the webViewDidFinishLoad: function, and add this code at the top of that function:
      #ifdef USE_CORDOVA 
      if ( [super respondsToSelector:@selector(onAppDidBecomeActive:)]) 
      [super onAppDidBecomeActive:nil];
      #endif
    7. Find the applicationWillEnterForeground: function and change it so it is no longer calling the same function on the super class, but is instead calling onAppWillEnterForeground:, like this:
      if ( [super respondsToSelector:@selector(onAppWillEnterForeground:)])      
      [super onAppWillEnterForeground:nil];
    8. Find the applicationDidEnterBackground: function and change it so it is no longer calling the same function on the super class, but is instead calling onAppDidEnterBackground:, like this:
      if ( [super respondsToSelector:@selector(onAppDidEnterBackground:)])      
      [super onAppDidEnterBackground:nil];
    9. In the initializeAppAfterKeyVaultUnlocked: find the line [PGContacts setContactsAccessDelegate:self]; and replace the class name PGContacts with CDVContacts, like this:
      [CDVContacts setContactsAccessDelegate:self];
  9. In the Xcode Project Navigator, locate the file named VERSION, at the top level of the project hierarchy, and remove it.
  10. In the Resources group folder, locate and remove these resources: PhoneGap.plist, Capture.bundle, and the www directory.
  11. In the WorkFlow/PhoneGapLib directory, locate the PhoneGap.plist file and copy it to WorkFlow/CordovaLib.
    1. Rename the newly copied PhoneGap.plist file to Cordova.plist.
    2. With any text editor, open the Cordova.plist file, and perform these two global search-and-replace operations:
      • Replace all instances of com.phonegap with org.apache.cordova.
      • Replace all instances of PG with CDV.
    3. Save the file.
  12. Locate where Cordova.framework was installed on your machine, typically, is in /Users/Shared/Cordova/Frameworks/Cordova.framework.
    1. Open this framework directory, and copy VERSION, Capture.bundle, and the www directory to WorkFlow/CordovaLib.
      Capture.bundle is a resource bundle that contains around a dozen or so png files that enable the capture.captureAudio API to function.
    2. Remove the cordova-1.5.0.js and index.html files from the www directory.
    3. If you plan to use the notification.beep API in Cordova, you must also place a file named beep.wav in the www directory.
      See the PhoneGap documentation for more details.
  13. In the Xcode Project Navigator, under the top level of the project, add the new VERSION file.
    1. In WorkFlow/CordovaLib, in the Resources group folder, add the new Capture.bundle, Cordova.plist, and www directory.
      Make sure you create folder references, not group references, for the added folders.
  14. Clean and rebuild all configurations of the Hybrid Web Container.
  15. The Cordova JavaScript file, usually named cordova-<version>.js, and which is typically located in ~/Documents/CordovaLib/javascripts, must now be included in any Workflow targeting the new Hybrid Web Container with the new Cordova library.
    For each Workflow you want to generate, copy this file to the Generated Workflow\js folder of the Eclipse WorkSpace where the Sybase Mobile SDK is installed, and remove any old instances of the file.
  16. Regenerate the Workflow.