0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CocosPodsで導入した特定のライブラリの'IPHONEOS_DEPLOYMENT_TARGET'を変更する

Last updated at Posted at 2021-10-15

環境

  • Xcode 13.0
  • CocosPods 1.10.2

概要

CocoaPodsで導入したライブラリの IPHONEOS_DEPLOYMENT_TARGET を変更する際、

Podfile
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '{任意のOSバージョン}'
    end
  end
end

上記のような対応をすることがあるかと思いますが、全てのライブラリに変更が及んでしまいます。

そこで今回は、特定のライブラリのみに別の値を設定したい場合の対応を紹介します。

対応方法

Build SettingsProduct Name を判定して分岐処理を加えると対応できます。

Podfile
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config| 
      if config.build_settings['PRODUCT_NAME'] == '{特定のライブラリ名}'
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '{任意のOSバージョン}'
      else
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '{任意のOSバージョン}'
      end
    end
  end
end

もしくは、全てのライブラリの変更が必要ない場合、target.name を判定して処理をするのもいいかもしれません。

Podfile
post_install do |installer|
  pods_target = installer.pods_project.targets.find { |target| target.name == '{特定のライブラリ名}' }
  pods_target.build_configurations.each do |config|
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '{任意のOSバージョン}'
  end
end
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?