Nativescript: Plugins: Use Variable in Android.xml and Info.plist

Created on 2 Nov 2016  路  4Comments  路  Source: NativeScript/NativeScript

I trying to write a plugin where I need some variable during build time. Is it possible to add custom variables like this in a plugin: https://github.com/NativeScript/sample-Groceries/blob/master/app/App_Resources/Android/AndroidManifest.xml#L15

question

Most helpful comment

@NickIliev Sorry for coming back so late. How can I pass values from iOS to this? Especially to the build.xcconfig file?

All 4 comments

You can create your own key-value pairs.
For example, you can open _app/App_Resources/Android/values_ and create/modify strings.xml file.

e.g. this will change the default application name for the key app_name

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">My New Application Name</string>
</resources>

And from here you can see how the same key is re-used in AndroidManifest.xml

    <application
        android:name="com.tns.NativeScriptApplication"
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">

or you can create your own colors like the ones created in the hello-world app
in _app/App_Resources/Android/values/colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="ns_primary">#F5F5F5</color>
    <color name="ns_primaryDark">#757575</color>
    <color name="ns_accent">#33B5E5</color>
    <color name="ns_blue">#272734</color>
</resources>

Hey @hypery2k - was that applicable for you or you need to add custom keys!?

@NickIliev Sorry for coming back so late. How can I pass values from iOS to this? Especially to the build.xcconfig file?

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings