I’d been having a problem where I was yo-yoing backwards and forwards between CocoaPods and Xcode, each presenting a warning which once remedied would cause the other to raise a warning.
The issue is around embedding Swift Libraries when working on a Swift based project. There are two settings, one deprecated EMBEDDED_CONTENT_CONTAINS_SWIFT
and one more current ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
.
CocoaPods generates the settings for Swift projects (possibly just those that have dependencies on Swift pods) on running pod install
:
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
This setting tells Xcode to include the Swift libraries as part of the product even if the product itself is Objective-C rather than Swift.
If you are building an app that does not use Swift but embeds content such as a framework that does, Xcode will not include these libraries in your app.
From Xcode 8.0 the setting was changed to ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
.
The new build setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES replaces the EMBEDDED_CONTENT_CONTAINS_SWIFT setting, which has been deprecated. This new setting indicates that Xcode should always embed Swift standard libraries in a target for which it has been set, whether or not the target contains Swift code.
This causes Xcode to warn the user to “Update to recommended settings”. Applying these changes results in the following Build Settings:
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
This causes CocoaPods to respond with the warning:
The target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting. This can lead to problems with the CocoaPods installation
The advice given in the warning is to:
- Use the
$(inherited)
flag, or - Remove the build settings from the target.
Being a sucker for minimalism, I opted for the second option. This was the wrong move. The correct way of resolving this issue is to use the $(inherited)
flag:
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = $(inherited)
This can be found on the targets Build Settings page, under Build Options.
This has been fixed in Cocoapods 1.2.0, however, if like me you have a project from before then, you may need to clean out those settings in Xcode and potentially your Pods directory before running pod install
. With any luck this should also resolve the issue.
Happy Xcoding…