How To Change Build Configuration In Xcode

As you know, your build is different when you build an app directly to your device or simulator and it’s different from what you build for the App Store.

By default, you have two possible configurations Debug and Release.

If you have a different configuration or you’re in a big project it might be different but if you’re working on your own it looks like in this post by default.

Let’s assume we have this code

struct ContentView: View {
    
var body: some View {
    
    VStack {
    
        #if DEBUG
    
        Text(“Text in Debug version”)
    
        #else
    
        Text(“Text in Release version”)
    
        #endif
    
        Text(“Text in both versions”)
    
            .padding()
    
    }
    }
}

If you don’t know what #if is, then check this post.

When you run this code you see two lines of text, like this:

When you build the same code for the App Store then the result is different.

Why?

Because of these configurations. You can change it easily.

On the top menu click on your project name. In my case, it’s BuildVersion (the name of the project).

Click on it and click Edit Scheme…

On the left panel select Run and change Build Configuration to Release.

The result:

Notice that on the left panel, there is Archive and there is a Release version selected. It means that every time you prepare your build for the App Store there is a Release version. There you can change it in the same way as you did for Run.

Now, build again the app and the first line of text is different.

If you want to add custom #if checks then here you can read more about it.