Release Version of iOS App Is Hitting DEBUG Flags - ios

In my schema, I have specified Release as the build type:
In my code I have some checks to see if it's in DEBUG or RELEASE. However it always hits the DEBUG (line 125 in the example below):
Do you know what I might be missing when I build for release so it stops hitting the DEBUG flags?

Conditional compilation like this does not depend on the Build Configuration but the presence of the DEBUG flag within that configuration.
Go to your project's build settings and search for 'flag'. Look under 'Swift Compiler - Custom Flags' and then 'Active Compilation Conditions': each build configuration is then listed and the flag DEBUG should be present where you want your debug code to appear but absent where you do not.

Related

Debug warning Xcode - dwarf-with-dsym?

I get this warning upon compilation:
DEBUG_INFORMATION_FORMAT should be set to dwarf-with-dsym for all configurations. This could also be a timing issue, make sure the Fabric run script build phase is the last build phase and no other scripts have moved the dSYM from the location Xcode generated it. Unable to process FieldSense.app.dSYM at path /Users/dnb/Library/Developer/Xcode/DerivedData/myApp-ggomikgtclrabvaoqmbwhjyudhxy/Build/Products/Debug-iphonesimulator/myApp.app.dSYM
How to solve?
To solve this issue:
Go to your project settings
Select your target
Go to Build settings
Scroll down to Debug Information Format (make sure to choose All settings)
Set the values to DWARF with dSYM File

Created new XCode Configuration and Scheme - linker is suddenly failing

A new XCode project has Debug and Release Configurations. I've added a new one under "ProjectName > Info" called "development", which is for now a duplicate of "debug".
I wanted to create a new scheme for building the app in development mode, so I duplicated the "Projectname" scheme and named it "DevelopmentScheme".
I set the build configuration for "run" and "archive" to the new "development" configuration that I created.
I'm still able to build the original Scheme.
I'm also able to build all of the required libraries when the project is configured with the development scheme, but when I get to the linking phase, I get the error:
ld: library not found for -lRNCookieManagerIOS
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Being relatively new to iOS development, I'm not really sure what the issue could be. Since I duplicated everything, shouldn't that mean they behave in the same way? Thoughts on what might be different between the original and new schemes?
The problem is that Xcode will expect to find the libraries inside a folder named after your custom configuration. You can add the custom configuration to each library you use, or better follow the steps below to make it use the libraries built via the Release configuration.
Steps:
Select your target
Open Build Settings tab
Search for 'Library Search Paths'
You'll see your new configuration name alongside Debug and Release
Double-click the space next to your new configuration name
Enter "$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)"
Set recursive to true.
Exit the dialog and you should see:
(inspired by this post)
Xcode 8.3.2 needs a bit different changes.
To make it work, you need to change the Per-configuration Build Products Path for your custom build config. For example, I have an Internal build config. In that field, instead of $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME), I put $(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME), and now it works :).

TwitterKit does not compile with Xcode 6.3

I added TwitterKit from Fabric to an app under Xcode 6.3.
The app would compile before I added TwitterKit's Run Script build phase step but once I added TwitterKit it failed with this error during Debug builds:
2015-02-23 11:22:32.382 run[53735:1513077] Fabric.framework/run 1.3.13
2015-02-23 11:22:32.388 run[53735:1513077]
Fabric: dSYM Error
Unable to process fabrictest.app.dSYM at path /Users/mfoouser/Library/Developer/Xcode/DerivedData/fabrictest/Build/Products/Debug-iphonesimulator/fabrictest.app.dSYM
Make sure your project build settings are generating a dSYM file. DEBUG_INFORMATION_FORMAT should be set to dwarf-with-dsym for all configurations. This could also be a timing issue, make sure the Fabric run script build phase is the last build phase and no other scripts have moved the dSYM from the location Xcode generated it.
Command /bin/sh failed with exit code 1
Anyone find a way around this?
This was a simple fix. Just do as the error state, turn on dSYM generation for your debug build.
Change your Build Settings from this:
To this:
Then choose Build again. It should now compile and run.
You can follow below steps ,it worked for me.
open build setting of your project and search for "Generate debug symbol" and set it to Yes.
As in the below screenshot
Search for debug information format in build setting and search for "Debug information format" then set "Debug information format" to "DWARF with dSYM file"
This didn't work for me since it was already set to 'with dSYM' and it didn't build as well. After more digging and trying things out, it seems like the issue (for me at least) is under Build Settings > Generate Debug Symbols, which was set to No by default. I changed it to Yes and it worked like a charm.
No one of proposed answers worked out for me.
Deleted both Fabric.framework and Crashlytics.framework which were added via Fabric app and added them again through Cocoapods.
**It doesnt mean that Cocoapods is only workaround, but probably that they should be re-added to project again.
What worked for me was the previous answers combined:
1- Change "Build Settings -> Debug Information Format -> Debug" value to "DWARF with dSYM File"
2- Change "Build Settings -> Generate Debug Symbols" value to "Yes"
3- Remove Fabric and Crashlytics frameworks and install again

Travis CI how to build debug and release?

I have a C++ project and sometimes the release and debug code gets out of sync (some code is #ifdef'd out or breaks with diff compiler options).
I'd like Travis-CI to build both debug and release, how can I do it? If it can be done will this also work with the multiple compiler matrix? I.e would it allow me to build debug and release on g++ and clang?

static library builds in debug configuration but not in release configuration

I get a 'Lexical/Preprocessor Issue "*.h" not found' error when I build for release.
But it builds perfect fine if I set the build configuration to Debug.
I have this static library project in the same workspace, so I am assuming it builds every time I build my project just like CocoaPods.
When I look in the build folder, the .a file is not copied over. But it is there for the debug config. Maybe it is trying to call a header before the static library is built.
I have looked all over stack overflow and I feel like I have tried everything. This is not a duplicate.
I have -ObjC in other linker flags.
I have checked the Prefix Header
Update: The User Header Search Path is "$(BUILT_PRODUCTS_DIR)" both debug and release
Thanks for your help.
For your project target Build Settings, look for "Search Paths->Header Search Path". Compare your Release and Debug settings here.
Also look into the "Build Location" for the library project for Release and Debug.

Resources