Hi, I'm working on a KMP project and have an issue...
# multiplatform
a
Hi, I'm working on a KMP project and have an issue with platform-specific code. My iOS code uses
NSBundle
to read custom keys like
BASE_URL
and
IS_DEBUG
from
Info.plist
, which works fine when I build with Xcode. However, when I run the same code via Android Studio, those keys return null.
Copy code
//iosMain inside actual class
private fun getBaseUrlFromBundle(): String { 
val bundle = NSBundle.Companion.mainBundle 
val baseUrl = bundle.objectForInfoDictionaryKey("BASE_URL") as? String 
return baseUrl ?: "" 
} 

private fun getEnvironmentFromBundle(): Environment { 
val bundle = NSBundle.Companion.mainBundle 
val isDebug = bundle.objectForInfoDictionaryKey("IS_DEBUG") as? String 
return if (isDebug?.lowercase() == "true") Environment.STAGE else Environment.PROD 
}