While this method maybe quick and convenient, it comes with some major limitations. First, because we are using a single bundle ID for both the development and production environments, you cannot install both app versions on a single device. This becomes inconvenient when you want to test the development version of the app, but still use the production version of the app on the same device.
Also, this approach allows for an opportunity to accidentally ship the development app to the store. If you forget to change that single global variable, you will be shipping the wrong app to your users. I remember once I forgot to change the global variable before submitting my app to the App Store, and users got the development version of the app. That was awful. In this article I will show you a better approach to differentiate between the development and production builds.
Specifically, we will create a development target in XCode. This method is suitable for both new and existing large projects, so you can use one of your existing apps to follow along in this tutorial. By applying this approach, the production and development versions of the app will have the same base code, but can have different icons, bundle IDs and point to separate databases. The distribution and submission processes will be very straightforward. So how can you create a development target in Xcode?
You can use your own project and follow the procedures:. Under the Targets sections, right click the existing target and select Duplicate to copy your existing target.
Xcode will ask you if your new target is for iPad development. Now that we have a new target and a new build scheme with the name todo copy. Steps 4 is optional, but highly recommended. If you want to make it easy and dummy-proof to distinguish between the development and production builds, you should use separate icons and launch screens for each version. This will make it obvious for your testers to know which app they are using, and hopefully prevent you from shipping a development version.
Go to Assets. Now go back to project settings, select your development target and change the bundle identifier.
If you performed step 4, make sure you change the app icon setting to the one created in the previous step. Xcode automatically added a plist file for your target e. You can find it at the root folder of your project. Here, it will be easier for you to manage the file. So later we can use the flag in our code to detect which version the app is currently running. Expand Preprocessor Macros and add a variable to both Debug and Release fields. For the development target i.
For Swift project, the compiler no longer supports preprocessor directives. Abhinav Abhinav Add a comment. Active Oldest Votes. Improve this answer.
Z S Z S 6, 12 12 gold badges 49 49 silver badges 91 91 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. The complication configuration including data source class, supported families, and groups.
An option to code sign the app for the Mac App Store, to code sign the app with a developer ID for distribution outside the Mac App Store, or to leave the code unsigned. The deployment target, which is the earliest OS X version on which the app will run.
Specifying debug or release builds is done elsewhere. See Managing Schemes. Add a capability by setting a switch to On. Xcode adds the necessary entitlements file to your project and links the target to the necessary frameworks. In some cases, Xcode might encounter issues enabling a capability. If so, that information will be displayed in the information area for that capability. You can show or hide detail for a capability by clicking the disclosure triangle to the left of the capability name.
For capabilities that are off, this area describes the capability and actions that occur when the capability is turned on. Migrating build settings from the project file to an xcconfig file is made very simple.
For the following steps I would recommend you open the build settings panel for the desired target in Xcode and select the options "All" and "Levels" to display the levels of build setting inheritance. You should be focusing on the values that are listed under the column with the name of your target in it. Look for cells in this column that are green and have bold text.
These are values set for this target specifically. Note: The copy action isn't very "smart" so sometimes you may need to expand the build setting and select the row of the build configuration for that setting to extract the value.
Sometimes you cannot get the right value and it may have to be recreated entirely please file a radar on this. As mentioned please consult my guide to xcconfig files linked to at the top of this section as this can be challenging to migrate complex projects. Warning: You may run into some problems with having pairing the test target with the framework. I am going to try to get another post up with a holistic explanation of migrating build settings to xcconfig files as soon as possible and link to it here.
Until then be aware this can cause issues due to Xcode wanting to resolve test host targets by string name. This is a fault with Xcode not with the targets or build configurations. When you have copied all your settings specific to that target into the xcconfig file, you can go back to the build configurations and assign the xcconfig file to that target for a specific build configuration. Before doing anything else you should back up your xcode project now.
To make sure you set up the xcconfig file correctly you will have to remove the values from the target. You can clear a build setting by pressing the "delete" when selecting a row that has a green cell in the target's column.
0コメント