How to set a default configuration for simulator build? - ios

As you know when you create a new Xcode project you have two configuration already created for you: Debug and Release.
I created two more because I have different headers for device and simulator build.
I set the paths for every configuration.
Now I want to know how to set the project to run the specific configuration automatically?

Related

Using One Widget Extension target for multiple schemes Swift

I set up multiple environments for my app by creating multiple configurations, with multiple schemes for each configuration (Article Describes in more detail my set up). Therefore I only have to have one target. This works fine for the actual app itself but I'm having trouble doing the same setup within an app widget extension. The production scheme works fine but when trying to build the dev side scheme I'm receiving this error.
/Users/ss/Library/Developer/Xcode/DerivedData/appName-hdbxzenesdshvnfgnywdjhuifcbu/Build/Products/Debug Development-iphoneos/AppNameWidgetExtension.appex error build: : No such file or directory
When I look through the derived data I can see the dev versions .appex. AppNameWidgetExtension-dev.appex but it seems to be looking for the none dev versions .appex. I would like to be able to continue to use one app target and one extension target but not sure how to get the dev widget extension to refer to the correct .appex file.
I noticed that embedded foundation extensions within the app target only referes to the dubug Production .appex. How could I change this .appex based on current scheme? Screen shot below
Scheme setup (The same setup as article I've attached)
Ive seen similar problems here but most are referring to having multiple targets and id much rather keep my current environment only using one target for multiple configurations.
Update:
So I think my issue was renaming the product name in packaging (within the build settings of app target) which would change the product module name too. Instead, I put it back to $(TARGET_NAME). I was changing the product module name to change the app display name on phone so instead I added Bundle Display name key and set the value to $(APP_NAME) (app name is from config files) to app targets plist. I also moved all my configuration settings into config files and added config files to project configurations. I used this tutorial to help me set up my project with xcconfig files.

Xcode new build system uses wrong build configuration set in scheme

I have a large app with multiple schemes and configurations. Ever since I use the new build system, Xcode shows info off the wrong build configuration.
I have 10 configurations and 10 schemes.
If I select scheme4 it should use configuration4 but it doesn't. It always uses the first configuration that is listed in Project -> Info.
Every time I go to my Target -> Info, it should show info of the current build configuration settings of that scheme but it doesn't. If I switch back to the old build system it works like intented ...

Set build variable in scheme instead of target

I am currently working on an iOS project in XCode that uses configurations to specify the different API environments my app can connect to. Additionally, I use targets to override one of my project configuration's user-defined values to specify a particular configuration file to use in the app. However, this is the only value that changes in the target. I work with multiple different configuration files (maybe 10 to 20 at a time) and creating a new target for each file to update one value seems clunky.
My question: Is there a way to pass this one value in from the scheme instead of setting it in the target?
I have seen that there is a pre-build script that can be run but I have not yet had any success exporting environment variables.
CONFIG_FILE="My Config File"
export CONFIG_FILE
I have also seen that some people have had success using PlistBuddy to write the values into the info.plist file during the pre-build phase of the scheme. This may be an option as well although it would require I redo a lot of my build process. I wanted to see if there was any other options before heading down this path.
Thanks for the help.
I was able to do this by using a .xcconfig file that is updated during my pre-build action in my scheme.
I used this tutorial to learn how to set up the project: http://www.jontolof.com/cocoa/using-xcconfig-files-for-you-xcode-project/

iOS - Exclude Test files from Release build

While developing an iOS application, I am required to run unit & ui tests on a preloaded database. So, I planned to include the DB file preloaded in the App only for DEBUG build as UI/Unit tests will run only with DEBUG build. How can i exclude the DB file from Release build?
Currently I can detect if the host app is running for testing or not using following way,
https://stackoverflow.com/a/33466038/1084174,
but how can exclude and include database.db using this technique?
A little guidance will really be appreciated.
Finally i solve the problem.
Open your project file. At the bottom of the screen click Add Build Setting -> Add User Defined Setting and name it EXCLUDED_SOURCE_FILE_NAMES.
Click the arrow to the left of EXCLUDED_SOURCE_FILE_NAMES to expand it. In the Release configuration for this variable, add libTestFlight.a and any other files you’d like to exclude (separated by spaces).
The standard way to do this would be to create a new Target in Xcode to use for debug. You can then use the target selector on files
Here you can see I have a source file that is included in my main target, but not in my messages extension. This appears in the Utilities pane on the right hand side of the screen. You can achieve the same by including a file in your debug target, but not release (or vice versa).

Change build version - Xcode 8

Is there a way to change the build version in Xcode 8?
I see the option below, but it won't seem to change it for me. It's stuck on "1.0.10" (what I last had it as before the new Xcode release).
You can set the value via a xcconfig file. Create a Configuration Settings File in Xcode with the following content
CURRENT_PROJECT_VERSION = 1.10.11
Then add this file in Project Settings | Configurations to the project or the desired targets.
EDIT: Btw. you can see where this value is currently set when you select Levels instead of Combined in the table header of the build settings.

Resources