Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does exact copy of Xcode Build Configuration fail?

I have a react-native app with bridged Swift code that is building, running, and archiving without issue with Xcode 10.0 with the default Release and Debug build configurations. I use Xcode -> Product -> Archive or the "Play" button and everything works as expected. Great!

Then today I added a new build configuration that is an exact duplicate of Release. It is named Release copy. I did the same for Debug as well, and its duplicate is Debug copy.

screenshot of the xcode menu showing the process of duplicating the Release build configuration

If I try to run the same Archive or Run tasks using the copies, the tasks fail at Precompile bridging header.

/Users/whaley/dev/app/theApp/theApp-Bridging-Header.h:5:9: error: 'React/RCTBridgeModule.h' file not found
#import <React/RCTBridgeModule.h>
        ^
1 error generated.
<unknown>:0: error: failed to emit precompiled header '/Users/whaley/Library/Developer/Xcode/DerivedData/theApp-ckvpglaqydwzhadbbyqoprcjvnod/Build/Intermediates.noindex/ArchiveIntermediates/theApp/PrecompiledHeaders/theApp-Bridging-Header-swift_320079J7441HX-clang_QK5YQQC41WXA.pch' for bridging header '/Users/whaley/dev/theApp/ios/theApp-Bridging-Header.h'

Odd, in my opinion, since this should be an exact copy of a build configuration that was working fine.

If I switch back to the original Build Configurations everything is fine. The originals consistently work and the copies consistently fail.

I tried disabling the Precompile bridging header task, but just encountered a different, and similar error. Again, the original build configs worked where the copies failed.

I'm already using Find implicit dependencies, the bridging header is named properly, I'm not using Cocoapods, I've rebooted and cleared Xcode's Derived Data, and please bear in mind that it does work fine normally. It's only these duplicate build configurations that fail.

Why might this be happening? Am I missing a step here? Is this perhaps a limitation of react-native and it only supports the default build configs?

like image 415
Will Haley Avatar asked Sep 24 '18 02:09

Will Haley


People also ask

How do I get Xcode build settings?

Choose the project in the Project Navigator on the left. Select the Configurations target from the Targets section and click the Build Settings tab at the top. The Build Settings tab shows the build settings for the Configurations target. It's possible to expand this list with build settings that you define.

How do I get build configuration in Swift?

Select the project in the Project Navigator on the left and click the Build Settings tab at the top. Scroll to the user-defined build settings at the bottom of the list of build settings. To add a user-defined build setting, click the + button at the top and choose Add User-Defined Setting from the list of options.

What is Xcconfig file in Xcode?

Xcode Configuration file (. xcconfig) is actually a key/value based file. You can store your build settings in the form of key/value pairs, similar to what you did in dictionaries. By using a . xcconfig file, it is very easy to define build parameters for each build.


1 Answers

Naturally, the moment I posted my question I managed to find the answer I needed via Google

Thanks to Mateusz Klimczak for clearly illustrating the problem and resolution on their website.

Add an entry to Headers Search Paths for each new Release build configuration:

$(BUILD_DIR)/Release-$(PLATFORM_NAME)/include

Add an entry to Library Search Paths for each new Release build configuration:

$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)

One might wonder why this is needed when we only change build configuration name and it was already working for Release. React Native supports Debug and Release build configurations out of the box, while any other configuration needs to be set up manually.

Sure enough, that fixed it. The answer is that only Release and Debug are supported out of the box, so that additional config is required for non-standard Build Configurations.

like image 96
Will Haley Avatar answered Oct 10 '22 22:10

Will Haley