How to use Prefix.pch in WP8 like in iOS?
Asked Answered
V

2

0

In iOS I have 5 application which use same code. I was able to refer the common classes and separate the application name, theme and color using the values from the Prefix.pch file. My Prefix file has these,

#define APPLICATION_NAME @"Application01"
#define APPLICATION_THEME @"Brown"

By using these macros defined my prefix file, in my program I can say

#if APPPLICATION_THEME = @"Brown"
-perform this-

I would like to follow the same approach in WP8. I don't know where do I define these macro values and to use them in the code. Please help me in achieving this.

Vilify answered 23/1, 2014 at 11:11 Comment(0)
H
0

Just replace

#define APPLICATION_NAME @"Application01" by #define APPLICATION_NAME_Application01

and

#if APPPLICATION_THEME = @"Brown" by #if APPPLICATION_THEME_Brown

additional the instead of #define you can just set it in the project properties in the menu Build->Conditional compilation Symbols: and just put APPLICATION_NAME_Application01

Highkeyed answered 23/1, 2014 at 14:13 Comment(5)
is there any other way without adding it to Conditional compilation Symbols: ? as i have around 50+ macors and its difficult to add and remove in Conditional compilation SymbolsPiton
@Piton there is only two ways that I know how one is by explicitly writing in the code the #define ... and other is in the Conditional compilation Symbols so you can create like a master defines page where you set all the #defines.Highkeyed
Please have a look here you will understand what i am looking for #22094643Piton
master defines page ? how to do it ? can you please show me how ?Piton
the reply to the question you posted is exactly what's in the reply in the first lineHighkeyed
D
0

C# language supports defines which can be defined either globally in the project file or you can define them on top of any file:

#define USE_BROWN_THEME

However, using application name is set in the WMAppManifest.xml file and you can only check/read it at runtime, you cannot do that at compile time. And xml files don't play well with #defines.

#define (C# Reference)

Duodecillion answered 23/1, 2014 at 11:49 Comment(0)
H
0

Just replace

#define APPLICATION_NAME @"Application01" by #define APPLICATION_NAME_Application01

and

#if APPPLICATION_THEME = @"Brown" by #if APPPLICATION_THEME_Brown

additional the instead of #define you can just set it in the project properties in the menu Build->Conditional compilation Symbols: and just put APPLICATION_NAME_Application01

Highkeyed answered 23/1, 2014 at 14:13 Comment(5)
is there any other way without adding it to Conditional compilation Symbols: ? as i have around 50+ macors and its difficult to add and remove in Conditional compilation SymbolsPiton
@Piton there is only two ways that I know how one is by explicitly writing in the code the #define ... and other is in the Conditional compilation Symbols so you can create like a master defines page where you set all the #defines.Highkeyed
Please have a look here you will understand what i am looking for #22094643Piton
master defines page ? how to do it ? can you please show me how ?Piton
the reply to the question you posted is exactly what's in the reply in the first lineHighkeyed

© 2022 - 2024 — McMap. All rights reserved.