Until Xcode 5, Release builds could be prevented from including NSAssert statements and their variants, using the default Build Setting:
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
This setting can be found in project.pbxproj and is set in Xcode here:
(Note that this grab was taken from an Xcode 4 project converted to Xcode 5.)
Each target would inherit this setting in the Release build only. Obviously this was a good thing. Rather than crash immediately, the app would possibly struggle on regardless. Whereas for Debug builds, you want to know immediately when an NSAssert fails.
However, I am struggling to find the equivalent in Xcode 5.
Creating a new project using the default templates shows no equivalent setting:
My question is, what is the equivalent setting in Xcode 5, or does NS_BLOCK_ASSERTIONS have to be added manually to Other C Flags for the Release build?
It's got it's own setting field now! Enable Foundation Assertions. Set your debug as yes and your release as no, as shown in screen grab below.
Note: You need to click All in the top left in your build settings tab to see it, you can see in my screen grab the blue ALL in the top left.
Related
The problem:
With All/Combined selected from the top menu within either the Project or the Target, this is what I see. Debug used to be listed within the Provisioning Profile and Code Signing Identity sections, but it is now missing. I can build a run on the simulator like this but when trying to deploy to a tethered testing device I get errors about provisioning profile and code signing being required.
This is not a duplicate of 'Provisioning profile' options missing from 'Code signing' Xcode 6.3 because I have All/Combined selected. It's not just that Debug is not visible in the list... it doesn't even exist anymore in the project.pbxproj file that Xcode uses to build the list.
What caused it:
I was trying to remove a profile in Xcode 7.3.1 and pressed the delete key without realizing the root debug row was selected rather than the child row which holds the profile itself. I can add a child (e.g. a release type such as Any iOS SDK) to a Release or Debug row by hovering over the parent row and clicking the +, but I can't add a new root item like Debug that way. No + is available when hovering over the Code Signing or Provisioning Profile rows. Unfortunately, while I can't remove one of these root rows with the mouse (no - button on them), I can accidentally do so with the delete key – which is what led to this broken state.
What I've tried:
Cleaning, restarting Xcode and computer, reinstalling Xcode, upgrading to Xcode 8, migrating to Swift 2.3, migrating to Swift 3, etc. I used a text editor with JSON syntax highlighting to opened multiple versions of the project.pbxproj file (some before the deletion) to see the differences. The project.pbxproj file is used to generate the menu items for the project and target. The old version is missing many new settings for the Release section found in the new version now that it has gone through several upgrade iterations with Xcode and Swift migrations. Among other concerns with that file, I wouldn't even know what was missing from the Debug section I'd be trying to add back. I could start a fresh project and copy over the Debug section from it's project.pbxproj file, but I'm convinced that manually editing that file to try to add the debug items back is a bad idea. There's probably a better option.
Question:
What's the best way to restore the missing Debug menu items?
What I would suggest is to create "manually" the new Debug configuration. You will not restore your old configuration but you will be able to set the correct configuration for the Debug configuration.
The operation is described in Adding a build configuration in Xcode but in your case you will have to duplicate the Release configuration and edit it to fit your requirements.
I also guess you will have to edit your schemes to use the correct configuration for each action (build/run/...).
I recently migrated from XCode 3 to XCode 4. I've spent more than one hour trying to find some build setting (Runpath Search Paths) without finding it.
I've come back to XCode 3, opened the same project, and there could find that setting. I set a value, and came back to XCode 4. The build setting has appeared.
It seems like the build settings are by default displayed only if they have a non-default value.
Is there any way to show all build settings, including the ones with default value?
I have an iOS project that builds and runs fine, but the "Clean Build Folder..." option is disabled. As a matter of fact, it is disabled in all of my projects (all iOS, some in workspaces).
They have not been upgraded from previous Xcode version as discussed in this thread.
To See the Clean Build Folder... option, hold the option key while viewing the Product menu.
What can I do to enable it?
Update:
Almost a year later. Currently on Xcode 6.3. Still no luck.
I tried the following steps.
Preference --> Locations -->
For derived data, click "Advanced".
Inside build location, choose "Unique".
The "Clear Build Folder" button appears again.
I had this problem with a project in Xcode 8, and found that in addition to the setting #ycwjjjj mentioned, I also needed to check File → Workspace Settings… → Advanced… and switch away from Custom Settings to Unique (or Xcode Default).
In XCode 4.0.2 there is a good way to configure the program in Build Settings when you click in "Levels" format. Like this screen
The levels are in this way:
Target Settings
Project Settings
iOS Default Settings
So the XCode see if the Target have a config, if not see in project and if not use the iOS default.
The problem here is that when you set a config in a low level and than delete it, it's impossible use the config of a upper level.
Like in image. I set all targets to use Google in Current Project Version, but in this target I want it use stackOverflow and it work. But in the other Generated Versioning ... I first config with stackOverflow but change my mind and want to use the Project Settings. Now is impossible delete the Target Settings and I will have to enter it manually.
How can I delete the target setting to use the project setting?
In xcode 5 it worked right simple for me. I had the same situation as in the picture in the question. Some data in the project setting and an empty but green setting on target level.
You have to select the line e.g. with the mouse that is marked and afterwards press the delete button the green marking is gone from the target level. In my test it and it will never delete the setting on the highes level, so there is no risk.
Click the Combined button and change the build setting value. Now when you click the Levels button, you will see the target and project both have the new value for the build setting.
I just figured this out. It's a little sketchy, but it works, and does not feel dangerous to me (particularly if you're using version control).
In Xcode, delete the text from the target-level configuration. Make sure you still have it defined at the project level.
Look at a diff of the YourProjectName.xcodeproj/project.pbxproj so you can figure out the code-level name of the setting you just changed. For example, in Xcode, I deleted the text from my target-level configuration for "Other C Flags". My diff showed the OTHER_CFLAGS setting changing from OTHER_CFLAGS="mytargetlevelsetting" to OTHER_CFLAGS="". If you're using version control (which you should be), it'll be easy to get this diff.
Quit Xcode.
Open up YourProjectName.xcodeproj/project.pbxproj in a text editor. Find all the lines starting with the setting name you found in step 2. Delete all the ones where the value is an empty string, and keep all the rest. For example, I deleted all the lines that said OTHER_CFLAGS="", but kept all the lines that said OTHER_CFLAGS="settingiwanttokeep". If you don't see any where the value is an empty string, or all their values are empty strings, you probably didn't follow step 1.
When you reopen Xcode and look at your target's build settings again, the setting in question should be using the project-level configuration, not the target.
I remember seeing it from the release notes of an earlier XCode version saying that it allows the three all in one IDE since then, instead of having to switch back and forth between the different windows when working on build, debug and editing. But with the latest XCode install, I still have to do that in separate windows. Is there a special setting to merge them all together under one IDE/window?
It's in XCode preferences, called "All in one" layout. Check this:
http://img.skitch.com/20101121-xsxhc34ywurcf14yuhm6hna5qi.png
Note that in order for that to be changed - all projects must be closed.