Reputation: 2082
Hi I have been working on my first iOS app. I have completed all of its requirements. Now its time to distribute. But before distribution I want to manage things well.
I searched for it and got "Target" as what I wanted. now just suppose the following requirement:
I have Client 1 and Client 2, and they both have different web addresses and Images and App Master password.
Now the 1 thing is to change them manually before making the build. But I wanted more proper way. So I thought of creating a Config file per target per client. but I am not getting it done.
Because after adding "Config" file for client 1 I am unable to create the 2nd "Config" file for Target 2 which indicates the client 2.
Please help me I am confused. Thanks in advance
Upvotes: 1
Views: 3274
Reputation: 1434
Once you have different targets, you also have different property list attached to it. This allows you to customise some elements of your configuration for a specific target.
In this example, I duplicated my target and have now two targets, two schemes and two .plist
files. I can customise one .plist
without affecting the other target.
Another way to solve this problem is to create two configuration files in Swift. For instance, you can create a AppConfig
struct foreach app configuration and attach it to one target at a time. It could be under AppConfig.swift
and AppConfigDemo.swift
, both with following code but different url in it.
struct AppConfig {
let urlString = "https://myclienturl.com"
}
The key is to include each file into the right target. Here, this AppConfig.swift
is available with Test
target. It won't be accessible in TestDemo
target. You can do the same foreach one of your client.
Upvotes: 1
Reputation: 79
Make sure they have different names, Info.plist and Client2-Info.plist (for example).
and you can set targets config file in its build settings. just search for Info.plist and set the relative path to the configuration you need.
Upvotes: 0