Search code examples
ioscolorsstylesconfigdimensions

iOS location for color style constants


I was wondering if such a thing was available; I'm used to developing Android for apps, Gui wise in web you obviously go for css, in android you have the styles and config files for strings, ints colors etc.

Now, what would be "The best" option to use such a thing for iOS?

I have this project with multiple targets, which I now separate in a targets folder to contain their custom style and images. (I'm not sure how to note the styles yet). What I'd like to have is to have some settings which I can easily edit for every single target. Settings will be stuff like, text colors, navbar color, login-background-image etc. The images I'll handle by just putting these in either assets or loosely in those dirs.

what to use for dimensions, strings, colors etc.? I'm fine with reading it with a style class parsing values if needed.


Solution

  • You can use the "User-Defined" section in the Build Settings of your target to store dimensions, string, and colors. Use the "+" button to add new user-defined values.

    enter image description here

    By the way, I like to use .xcconfig files to store User-Defined values.

    1:Create a new configuration settings file. enter image description here

    2:Assign your new configuration settings file to a target. enter image description here

    3:Add some values in the configuration settings file enter image description here

    4:The values should be inserted into build settings as User-Defined values automatically. enter image description here

    For images, you can put them in different folders for different target and select the target the images belong to in the "Target Membership" section in the file inspector.

    enter image description here