I have a project with a main iOS target, some custom frameworks whose source files are in the same project, and CocoaPods.
I recently changed my Xcode build configuration names and added two more in order to cover two environments (staging, production) plus debug and release configuration for each environment.
MyProduct (Staging)
with default configurations Debug
, Release
MyProduct (Production)
with default configurations Debug
, Release
I was so annoyed by having to check two targets in the save dialog every time. I decided to have only one target but multiple build configurations. And surprisingly you can do pretty much everything with build configurations and variables in your Info.plist files.
So I changed the configurations like so:
Debug
to Debug Staging
Release
to Release Staging
Debug Production
Release Production
I needed to update the scheme settings, too, to use the correct config.
Since you change the configuration in the project and not in the individual targets, all targets will get these configurations.
Since I'm using CocoaPods I ran pod install
to generate the configurations for the Pods as well. It succeeds and I can build and run my main target with different configurations.
The problem now is that I can neither build my custom frameworks individually anymore, nor their unit tests. I'm getting errors like these:
- Command MergeSwiftModule failed with a nonzero exit code
- Framework not found "Pods_MyProject"
I've tried already everything from cleaning derived data to deintegrating CocoaPods.
Turned out Cocoapods gets somehow confused when there is no default Debug
and Release
configuration anymore. After running pod install
I could see actually 6 build configurations for the Pods Xcode project:
Debug
Debug Staging
Debug Production
Release
Release Staging
Release Production
I decided to use Debug
and Release
for the Production environment and Debug Staging
and Release Staging
for the staging environment. I ran pod install
again and: Problem solved. I see 4 build configurations for the Pods project:
Debug
<-- ProductionDebug Staging
Release
<-- ProductionRelease Staging
All the custom frameworks build again successfully and I can run my unit tests again.