Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How Platform.select({}) works? getting undefined BuildConfig when executing on iOS

$
0
0

I'm having configuration in build.gradle and info.plist which i need to get on run time using ▼

import { Platform } from 'react-native';import BuildConfig from 'react-native-build-config';

I have no issue while testing this on iPhone but gets undefined on Buildconfig when i execute this on Android, It make no sense that BuildConfig is undefined, though it's fetching Info.plist property which is wrong but it should point to property not to BuildConig, itself.
when it's running on Android it works perfectly for Android but failed on iOS part or on GlobalConfig.b.CFBundleURLTypes[0].CFBundleURLSchemes[1].

Failing scenarios:

 // Deeplinks -----------------------  public static readonly DEEPLINK_INTENT_HOST: string = Platform.select({    ios: BuildConfig.CFBundleURLTypes[0].CFBundleURLSchemes[1],    android: BuildConfig.INTENT_FILTER_HOST,    default: ''  });

//-----------------------------------------------------------------

// Deeplinks -----------------------      public static readonly DEEPLINK_INTENT_HOST: string =       Platform.select({        ios: (BuildConfig.CFBundleURLTypes || [])[0].CFBundleURLSchemes[1],        android: BuildConfig.INTENT_FILTER_HOST,        default: ''      });

//-----------------------------------------------------------------

  // Deeplinks -----------------------  public static b: any = BuildConfig;  public static readonly DEEPLINK_INTENT_HOST: string = Platform.select({    ios: GlobalConfig.b.CFBundleURLTypes[0].CFBundleURLSchemes[1],    android: GlobalConfig.b.INTENT_FILTER_HOST,    default: ''  });

Working scenarios:

  // Deeplinks -----------------------  public static readonly DEEPLINK_INTENT_HOST: string = Platform.OS == 'ios' ? BuildConfig.CFBundleURLType[0].CFBundleURLSchemes[1] : BuildConfig.INTENT_FILTER_HOST;

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>