Fix: Cannot Synthesize Weak Property Deployment Target Error in CocoaPods

Written by

in

Quick answer: Add a post-install hook to your Podfile that sets a consistent IPHONEOS_DEPLOYMENT_TARGET for all pods, or use platform :ios, '9.0' and delete per-target deployment targets so they inherit the project setting.

Why this happens

When you upgrade to CocoaPods 1.0 or later, the tool no longer automatically propagates your project’s deployment target down to each individual pod target. Each pod then builds with its own default deployment target — often an ancient version like iOS 4.3 — which doesn’t support modern language features such as weak references. The compiler then emits:

Cannot synthesize weak property because the current deployment target does not support weak references

This mismatch occurs because CocoaPods 1.0 changed to treat each pod as an independent target with its own build settings, rather than inheriting from the parent project.

How to fix it

1. Force a single deployment target for all pods (recommended)

Add a post_install hook at the end of your Podfile that overwrites IPHONEOS_DEPLOYMENT_TARGET for every pod target and configuration. This guarantees all pods build against the same minimum iOS version.

# Podfile
platform :ios, '13.0'  # your app's minimum deployment target

target 'MyApp' do
  pod 'KeepLayout', :git => 'https://github.com/iMartinKiss/KeepLayout', :tag => 'v1.6.0'
  pod 'EasyMapping'
  # ... other pods
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
    end
  end
end

Run pod install (or pod update) after editing. The next build will use iOS 13.0 for every pod, eliminating the weak-reference error.

2. Let pods inherit the project deployment target

If you prefer not to hard-code the version, declare the platform once and then remove the per-target setting so each pod falls back to the project-level value.

platform :ios, '13.0'

target 'MyApp' do
  # pods...
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings.delete('IPHONEOS_DEPLOYMENT_TARGET')
    end
  end
end

This approach keeps the deployment target in a single place (platform :ios) and avoids duplication.

3. Per-pod override (rarely needed)

If only specific pods require a higher deployment target, target them by name inside the hook:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if ['KeepLayout', 'SomeOldPod'].include?(target.name)
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
      end
    end
  end
end

Use this sparingly; a uniform target is simpler to maintain.

How to prevent it

  • Always declare platform :ios, 'X.Y' at the top of your Podfile to set the baseline.
  • Include one of the post_install snippets above in every project that uses CocoaPods.
  • Pin the CocoaPods version in your Gemfile (gem 'cocoapods', '~> 1.15') so CI and teammates run the same version.
  • Run pod outdated periodically; newer pod versions often raise their own minimum deployment targets.

FAQ

Why did this start happening after updating CocoaPods?

CocoaPods 1.0 stopped automatically copying the project’s deployment target into each pod target. Pods now default to their own (often very old) deployment targets unless you explicitly configure them.

Can I set the deployment target in Xcode instead of the Podfile?

Changes made in the Xcode UI to the Pods project are overwritten every time you run pod install or pod update. The Podfile is the single source of truth.

What if a pod legitimately requires a lower deployment target than my app?

You can’t build that pod with a higher deployment target than it supports. Either drop your app’s minimum to match, find a maintained fork, or replace the dependency. The post_install hook can lower the target for that specific pod, but then your app must also support that lower version.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 3.0; this article is shared under the same license.