Skip to main content

Veritran Docs

Integration for iOS

In the integration process for iOS, you need to:

  1. Set the necessary credentials to access XpressPlug's private repositories for iOS.

  2. Integrate XpressPlug as a dependency on your Xcode project.

  3. Create a communication bridge between React Native and iOS native code.

Set Repository's Credentials

Follow these steps to set your credentials for XpressPlug's private repository for iOS.

  1. Create the .netrc file in the root directory (/home/:user/).

  2. Add the following configuration, which will allow dependency managers such as Cocoapods to access Veritran's private resources.

    machine developer.veritran.com
    login user
    password <PRIVATE_TOKEN> 

    Important

    To obtain the private token, send an email to mobile_support@veritran.com with the "XpressPlug Access" assignment, and the team will provide you with the necessary resources.

Integrate XpressPlug to your Project

To configure the "podfile" and the dependencies, follow these steps:

  1. Add: the following repositories at the beginning of the iOS project's podfile, within the iOS folder in its React project.

    platform :ios, '13.4'
    source 'https://developer.veritran.com/resources/xpressplug/ios/specs.git'
    source 'https://github.com/CocoaPods/Specs'  
  2. Add the following lines in your podfile, that will allow library compatibility with Xcode and React-Native:

    plugin 'cocoapods-user-defined-build-types'   
    enable_user_defined_build_types!
  3. In the "Pod" section, add the following XpressPlug dependency within your project's main target:

    pod 'XpressPlug', '7.10.2.51785-react', :build_type => :dynamic_framework 
  4. Add the following in the Post Script section:

    post_install do |installer| 
    
       react_native_post_install(installer) 
    
       installer.pods_project.targets.each do |target| 
    
         target.build_configurations.each do |config| 
    
          if ["lottie-ios","Alamofire", "CryptoSwift", "SwiftyJSON"].include?(target.display_name) 
    
             config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES' 
    
          end 
    
          if ["Alamofire"].include?(target.display_name) 
    
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0' 
    
          end 
    
          if ["Alamofire", "lottie-ios", "SwiftyJSON", "vt_contract_resources_manager", "CryptoSwift"].include?(target.display_name)
    
             next 
    
           end 
    
           config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' 
    
         end 
    
       end 
    
      end 
  5. Run the following command in your terminal:

    pod install --repo-update 

    After installing the dependencies, you will see the confirmation message "Pod installation complete".

  6. Verify your project is compiling and running in your device. Go to Xcode, click Product > Build to install and open the app in your device.

Create a Communication Bridge between React Native and Objective-C Native

It is necessary to create a class that works as a communication bridge between React Native and iOS native code. Because of this, you need to implement the React protocol RCTBridgeModule.

VTXpressPlugModule.h

#import <React/RCTBridgeModule.h> 
@interface VTXpressPlugModule : NSObject <RCTBridgeModule> 
- (void) initialize: (RCTPromiseResolveBlock) resolve 
           rejecter: (RCTPromiseRejectBlock) reject; 
- (void) callEntryPoint: (NSString*) entryPointName 
             parameters: (NSDictionary*) parameters 
             outputKeys: (NSArray*) outputKeys 
               resolver: (RCTPromiseResolveBlock) resolve 
               rejecter: (RCTPromiseRejectBlock) reject; 
@end  

VTXpressPlugModule.m

 @implementation VTXpressPlugModule { 
  XpressPlugInitializer *initializer; 
  XpressPlugEntryPoint *entryPoint; 
} 

RCT_EXPORT_MODULE(XpressPlugModule); 

RCT_EXPORT_METHOD(initialize: (RCTPromiseResolveBlock) resolve 
                  rejecter: (RCTPromiseRejectBlock) reject) { 
NSLog(@"---- VTXpressPlugModule did receive call initialize"); 
initializer = [[XpressPlugInitializer alloc] initWithResolve: resolve 
                                                        reject: reject]; 
[initializer execute]; 
} 

RCT_EXPORT_METHOD(callEntryPoint: (NSString*) entryPointName 
                  parameters: (NSDictionary*) parameters 
                  outputKeys: (NSArray*) outputKeys 
                  resolver: (RCTPromiseResolveBlock) resolve 
                  rejecter: (RCTPromiseRejectBlock) reject) { 
  NSLog(@"---- VTXpressPlugModule did receive call entry point"); 
  entryPoint = [[XpressPlugEntryPoint alloc] initWithEntryPointName: entryPointName 
                                                         parameters: parameters 
                                                         outputKeys: outputKeys 
                                                            resolve: resolve 
                                                             reject: reject]; 
[entryPoint execute]; 
} 

@end