Private consuming NSDictionary property

312 Views Asked by At

I'm currently implementing TrustKit SSL Pinning on a React Native project.

Due to another library on my XCode project, which does already install TrustKit Cocoapod I am not be able to refer it directly anymore, that's why I'm trying to call it in a "private" manner, just like this example:

  // Disable TrustKit if it is present 
  Class TrustKit = NSClassFromString(@"TrustKit"); //Private calling
  if (TrustKit != nil)
  {
    // Override TrustKit's logger method, useful for local debugging
    void (^loggerBlock)(NSString *) = ^void(NSString *message)
    {
      NSLog(@"TrustKit log: %@", message);
    };

    SEL setLoggerBlock = sel_registerName("setLoggerBlock:");
    [TrustKit performSelector: setLoggerBlock withObject:loggerBlock];
    
    NSDictionary *trustKitConfig =
    @{
      kTSKSwizzleNetworkDelegates: @YES,// How to private consume this property
      kTSKPinnedDomains: @{
          @"*.apps.dev.js.com" : @{
              kTSKIncludeSubdomains: @YES, // Pin all subdomains
              kTSKEnforcePinning: @YES, // Block connections if pinning validation failed
              kTSKDisableDefaultReportUri: @YES,
              kTSKPublicKeyHashes: @[
                @"dz0GbS1i4LnBsJwhRw3iuZmVcgqpn+AlxSBRxUbOz0k=",
                @"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=",
              ],
          },
      }
    };
    
    SEL setInitSharedInstanceWithConfiguration = sel_registerName("initSharedInstanceWithConfiguration:");
    [TrustKit performSelector: setInitSharedInstanceWithConfiguration withObject:trustKitConfig];
  }

I was able to execute TrustKit methods properly. However, I don't know how to handle trustKitConfig properties from the dictionary by private calling

Error screen: Use of undeclared identifier 'kTSK....'

1

There are 1 best solutions below

4
Fonts On

Thanks for the help, I was able to fix this issue by using string value @""

I had to remove the k letter from the beginning

NSDictionary *trustKitConfig =
    @{
      @"TSKSwizzleNetworkDelegates": @YES,// How to private consume this property
      @"TSKPinnedDomains": @{
          @"*.apps.atp.dev.jsafrasarasin.com" : @{
              @"TSKIncludeSubdomains": @YES, // Pin all subdomains
              @"TSKEnforcePinning": @YES, // Block connections if pinning validation failed
              @"TSKDisableDefaultReportUri": @YES,
              @"TSKPublicKeyHashes": @[
                @"dz0GbS1i4LnBsJwhRw3iuZmVcgqpn+AlxSBRxUbOz0k=",
                @"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=",
              ],
          },
      }
    };