Documentation / 02
Your Podfile
Declare pods and Swift Package Manager dependencies together. Use pod for pod dependencies and spm for Swift packages, with shared target declarations and installation settings.
Choose dependency sources
source 'https://specs.example.org/'
platform :ios, '15.0'
target 'MyApp' do
pod 'Networking', '~> 2.0'
pod 'SharedModels', :path => '../SharedModels'
pod 'Feature', :git => 'https://git.example.org/team/Feature.git',
:tag => '1.2.0'
spm 'swift-collections',
:git => 'https://github.com/apple/swift-collections.git',
:from => '1.0.0',
:products => ['Collections']
endThe pod repository URLs and module names above are placeholders. Use your own spec repository, Git repository, and local modules. The Swift Collections example uses a public Swift package. Keep credentials outside committed manifests.
Add Swift packages
The spm declaration selects a Git repository, a version requirement and the package products to link. Xcode resolves package versions and records them in Package.resolved. See the Swift package guide for exact versions, ranges, branches and revisions.
Choose a build type
Use static libraries by default, or select static or dynamic frameworks:
use_frameworks! :linkage => :static
# Or: use_frameworks! :linkage => :dynamicShare declarations across targets
platform :ios, '15.0'
abstract_target 'Shared' do
pod 'Networking', :path => './Modules/Networking'
target 'MyApp' do
end
target 'MyAppTests' do
inherit! :search_paths
end
endCustom configurations
project 'MyApp.xcodeproj',
'Debug' => :debug,
'Staging' => :release,
'Release' => :releaseSelect library tests and example applications
target 'MyApp' do
pod 'Networking', :path => './Modules/Networking',
:testspecs => ['Tests'],
:appspecs => ['Example']
endThe selected podspec must declare those test and app specs. SwiftPods creates their targets and shared schemes; unselected specs stay out of the build.