CocoaPods 1.9 New Features: XCFramework Support, Configuration‑Based Dependencies, Test Coverage, Swift Version Variants, and Linkage Customization
CocoaPods 1.9 introduces XCFramework support, configuration‑based podspec dependencies, test‑spec code coverage, Swift version variant handling, and a static‑linkage option for use_frameworks!, providing iOS developers with enhanced dependency management and build flexibility.
CocoaPods 1.9 adds support for XCFrameworks, configuration‑based dependencies, generated scheme code coverage, Swift version variants, and a new static‑linkage option for the use_frameworks! DSL, along with various bug fixes and enhancements.
With Xcode 11 Apple introduced the .xcframework bundle format, which can contain multiple framework binaries for different architectures and platforms. CocoaPods now lets pod authors declare XCFrameworks via the existing vendored_frameworks DSL, for example:
Pod::Spec.new do |s|
s.name = 'ToastLib'
s.version = '1.0.0'
# ...rest of attributes here
s.vendored_frameworks = 'ButterLib.xcframework'
endWhen a pod includes a dynamic framework, CocoaPods adds a new script phase named [CP] Prepare Artifacts to embed the .xcframework into the app bundle.
For detailed guidance on creating XCFrameworks, see Apple’s WWDC session “Binary Frameworks in Swift”.
The release also extends configuration‑based dependency exclusion to podspec authors. The :configurations option can now be used with the dependency DSL, allowing pods to be linked only for specific build configurations (e.g., Debug or Release). Example:
Pod::Spec.new do |s|
s.name = 'ToastLib'
s.version = '1.0.0'
# ...rest of attributes here
s.dependency 'ButterDebugging', :configurations => ['Debug']
s.dependency 'ErrorReportingTool', :configurations => ['Release']
endNote: Currently only Debug and Release configurations are supported; custom configuration names may be added in the future.
Test specifications can now enable code coverage by setting the code_coverage flag in the scheme DSL, for example:
Pod::Spec.new do |s|
s.name = 'Networking'
s.version = '1.0.0'
# ...rest of attributes here
s.test_spec 'Tests' do |test_spec|
test_spec.scheme = {
:code_coverage => true,
:environment_variables => {'FOO' => 'BAR'}
}
end
endSwift version handling is improved: pod authors can specify multiple supported Swift versions via the swift_versions attribute, while the supports_swift_version DSL in a Podfile declares the app’s supported Swift range. This allows CocoaPods to generate separate targets for the same pod when different targets require different Swift versions. Example podspec:
Pod::Spec.new do |s|
s.name = 'CannonPodder'
s.version = '1.0.0'
s.swift_versions = ['4.0', '5.0']
endCorresponding Podfile:
target 'SampleApp' do
supports_swift_version '< 5.0'
pod 'CannonPodder'
end
target 'SecondApp' do
supports_swift_version '>= 5.0'
pod 'CannonPodder'
endFinally, the use_frameworks! DSL now accepts a :linkage => :static option, giving developers control over whether pods are linked as static or dynamic frameworks. Example:
use_frameworks! :linkage => :staticFor more details, see the CocoaPods issue discussion at https://github.com/CocoaPods/CocoaPods/issues/9099.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Sohu Tech Products
A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
