Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

DefineConstants problem

$
0
0

Hello,

I have a problem with constants defined inside .csproj file of Xamarin Forms app. I have defined additional keyword for AppStore configuration there and added some #if blocks to swap some ids depending on that keyword. I have just realised that #if block works only when target platform is set to "AnyCPU". This is fine for android build but for iOS platform it is set to "iPhone" and the #if does not work as I have expected.

I have traced it that .csproj has definition:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore |AnyCPU' ">
    <Optimize>true</Optimize>
    <OutputPath>bin\AppStore</OutputPath>
    <DefineConstants>APP_STORE;</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>

I have changed it to:

  <PropertyGroup Condition=" '$(Configuration)' == 'AppStore' ">
    <Optimize>true</Optimize>
    <OutputPath>bin\AppStore</OutputPath>
    <DefineConstants>APP_STORE;</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>

but that did not help.

I have expected that changing to AppStore configuration will affect the #if block regardless the platform. But that's not working this way.
Anyone have an idea what can I do to make it work?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



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