Skip to content

Instantly share code, notes, and snippets.

@ykst
Created January 28, 2015 14:15
Show Gist options
  • Save ykst/5cf7caee75a087255865 to your computer and use it in GitHub Desktop.
Save ykst/5cf7caee75a087255865 to your computer and use it in GitHub Desktop.
CocoaPodsでNo architectures to compile for.. が出た時の対処法

CocoaPodsでNo architectures to compile for.. が出た時の対処法

No architectures to compile for..

Xcodeで実機デバッグを行う際に、

No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=armv7s, VALID_ARCHS=armv7).

↑このようなエラーが出てビルドが失敗するケースがあります。 古いコードを64bitデバイスで動かそうとした場合なんかによく発生します。

これはコードが特定のARMアーキテクチャに依存しており、Build SettingのValid Architecturesに含まれていないARMの実機でバイナリを動かそうとした時に起きます。 このような場合はBuild Active Archtecture OnlyをNOにセットしてユニバーサルなバイナリをビルドする必要があります。 デフォルトのReleaseモードはそのように設定されているのですが、Debugモードはビルド時間を短縮するためにフラグがYESに設定されています。

CocoaPodsを使っている場合

単一のプロジェクトであれば該当フラグをNOにすれば良いのですが、CocoaPodsを使用している場合はサブプロジェクトのBuild Active Archtecture OnlyがDebugモードではYESに設定されているので、そのままだとDebugビルドが出来なくなってしまうか、pod installする度に全てのフラグをNOに設定するという手作業が必要になってしまいます。

これはとても面倒なので、プロジェクトのPodfileに以下の処理を付け足すことでinstall後にフラグを一斉に書き換える事が出来ます。

post_install do |installer_representation|
  installer_representation.project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
    end
  end
end

というやり方を、このスレッドで見かけました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment