Skip to main content

Veritran Docs

Integración

En este paso, debes integrar XpressPlug como una dependencia en tu proyecto de Xcode. Para ello, ejecuta el comando pod init. Luego, en el archivo Podfile, agrega el siguiente código al destino principal de tu app y guárdalo.

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

  2. [en] Integrate XpressPlug as a dependency on your Xcode project.

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

[en] Set Repository's Credentials

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

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

  2. [en] 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> 

    Importante

    [en] 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.

[en] Integrate XpressPlug to your Project

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

  1. [en] 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. [en] 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. [en] 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. [en] 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. [en] Run the following command in your terminal:

    pod install --repo-update 

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

  6. [en] 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.

[en] Create a Communication Bridge between React Native and Objective-C Native

[en] 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.

[en] 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  

[en] 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