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 1 year has passed since last update.

Xcode14 & CocoaPodsでResource Bundleを含む依存があるとSigningに失敗する

Posted at

しばらく前から発生してて話題になってないから多分みんなIssue見て解決できてると思うんですが、困っている人いるかもしれないので日本語情報として残しておきます。

何が起きたか

Xcode14でResource Bundleを含む依存を入れている場合に、実機ビルドやリリースビルドなどを行おうとするとSigningでエラーが発生する。

確認した環境

Macbook Pro (Apple M1 Pro)
macOS 12.6
Xcode 14.0
CocoaPods 1.11.3

なぜ起きるか

上記環境の場合、CocoaPodsがBundleターゲットもSigningしようとしてしまうが、本来Signingは不要なので必要な情報が不足しておりエラーが発生する。

修正方法

方針

Signingをしないように生成されたプロジェクトのBundleターゲットにBuild Settingsにフラグ(CODE_SIGNING_ALLOWED)を追加する。

Podfileにpost_installのフック処理を追加することでpod install後に発火されるスクリプトの処理を書くことができる。
これを利用し、生成されたプロジェクトのBundleターゲットのフラグをセットする。

generate_multiple_pod_projectsを設定している場合生成されるプロジェクトの構造が変わるためスクリプトが違うのに注意

回避用ワークアラウンド

(手元にgenerate_multiple_pod_projectsを設定しているプロジェクトしかないので、使ってない方は動作確認してないです:bow:

Podfile
...

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
      target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
      end
    end
  end
end
Podfile(generate_multiple_pod_projectsを設定している場合)
install! 'cocoapods',
  :generate_multiple_pod_projects => true
...

post_install do |installer|
  installer.generated_projects.each do |project|
    project.targets.each do |target|
      target.build_configurations.each do |config|
        if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end
  end
end

公式Issue

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?