问题描述
我正在build.gradle和info.plist中进行配置,我需要使用▼来启动运行时间
import { Platform } from 'react-native';
import BuildConfig from 'react-native-build-config';
在iPhone上测试时我没有问题,但是当我在Android上执行此操作时,在 Buildconfig 上却未定义,尽管BuildConfig会获取错误的Info.plist属性,但BuildConfig是未定义的但它应该指向属性而不是BuildConig本身。
当它在Android上运行时,它可以完美地在Android上运行,但在iOS部分或GlobalConfig.b.CFBundleURLTypes[0].CFBundleURLSchemes[1]
上运行失败。
失败情况:
// 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],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: ''
});
工作场景:
// Deeplinks -----------------------
public static readonly DEEPLINK_INTENT_HOST: string = Platform.OS == 'ios' ? BuildConfig.CFBundleURLType[0].CFBundleURLSchemes[1] : BuildConfig.INTENT_FILTER_HOST;
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)