I’ve done this twice for the Word Counter: once for an in memory store, once using test data. Hit the + button and then duplicate the existing Debug configuration.įrom the project view, it’s easy to duplicate the existing debug build configuration. They work well with Schemes, though, and setting up a build configuration and a scheme is much less overhead than maintaining a custom target. I’ve never played around with build configurations in Xcode. But that doesn’t scale well if all I want is change a preprocessor macro to switch from file-based to in memory storage, for example. To test the Word Counter during development, I have long used a special build target. If you are not using cocoapods you can skip this section.Make Custom Debug Build Configurations Play Nicely With CocoaPods ![]() Don’t forget to edit the schemes to run the corresponding build configuration on Run From the “manage schemes” menu, let’s create two new schemes named Production and Development using the default target. I usually delete (select and click on the “-“ icon) the default scheme and create new ones for each configuration. First let’s make some custom schemes so that we can easily switch between the various build configurations. If it wasn’t for cocoapods our project would build and run right now, but we’ll deal with that later. Now if we navigate to “Edit Scheme” for the current scheme, our just defined build configurations are avaiable to select for the different actions. You can define this for the whole project or for specific targets. Then select which configuration file this build configuration is based on. I will go for release for Production and debug for Development. ![]() Press the “+” icon and select which basic configuration you want to duplicate, release or debug in this case. Instead, I use only new variable names and assign them to the corresponding values in ist (more on that later) Create New Build Configurations I do not prefer this approach since dealing with build setting levels and inheritance can be a tedious. A minor annoyance, but quite handy when you know it!Īnother way to go about customising existing target build settings is to override settings such as PRODUCT_NAME. It’s used in order to escape the double dash so that the part following it is not treated as a comment. $() denotes an empty variable substitution. We can add the following to Production.xcconfig: Let’s say that we want to be able to configure a backend endpoint and the app’s display name. We’ll create one file for Production, called Production.xcconfig and another one for Development called… you guessed it, Development.xcconfig Define build variables xcconfig file extension) is a plain text file that defines and overrides the build settings for a particular build configuration of a project or target. ![]() ![]() Go to File -> New -> File (or cmd + N) and select the “Configuration Settings File” template.Ī Configuration Settings File (a file with a. Unfortunately (at the time of writing this post) the way to set up build configurations in Xcode is not very straightforward and it certainly does not feel as user friendly as other Xcode features. Which is not the case if you need to comment/uncomment lines every time you build in order to point to the correct environment. The number one rule of automated build is that you have to be able to produce a build for your project with a “single command”. Take automated builds for example, be it custom nightly build scripts or some ultra-fancy CI pipeline. Of course you can do the “comment/uncomment URL constants” dance everytime you need to switch environments, but other than being a tedious and error-prone process there are cases where build configurations are unavoidable. If you are developing an app that’s currently in production, chances are you are switching from your production API endpoints to some kind of test environment endpoints for development. Build configurations are useful for a handful of reasons.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |