LoginSignup
19
16

More than 5 years have passed since last update.

xcodeライブラリファイル(.framework)から特定のアーキテクチャのみ抽出する方法

Last updated at Posted at 2016-07-07

.frameworkファイルに余計なアーキテクチャが含まれていてApp Storeにアップロードできない

AWS SDKのframeworkファイルにはシミュレータ(i386)およびOS X(x86_64)のアーキテクチャが含まれており
App Store にアップロードできずエラーになったため、

Unsupported Architectures.The executable  フレームワーク.framework contains unsupported architectures "[x86_64,i386]"

特定のアーキテクチャのみ抽出して.frameworkを再生成しました。
そのときの対策を記載しておきます。

unnamed.png

.frameworkファイルから特定のアーキテクチャのみ抽出する

今回は以下の4つの.frameworkファイルに対して修正しました。

  • AWSCognito.framework
  • AWSAPIGateway.framework
  • AWSCognitoIdentityProvider.framework
  • AWSCore.framework

lipoツールにて修正を行います。
今回はarmv7およびarm64のみ抽出しました

# 含まれているアーキテクチャを確認する
$lipo -info AWSCognito.framework/AWSCognito
Architectures in the fat file: AWSCognito.framework/AWSCognito are: i386 x86_64 armv7 armv7s arm64 
# 特定のアーキテクチャのみ抽出する
$lipo -extract arm64 AWSCognito.framework/AWSCognito -o AWSCognito.framework/AWSCognito-arm64
$lipo -extract armv7 AWSCognito.framework/AWSCognito -o AWSCognito.framework/AWSCognito-armv7
# 抽出したアーキテクチャから再生成する
$lipo -o AWSCognito.framework/AWSCognito-merged -create AWSCognito.framework/AWSCognito-armv7 AWSCognito.framework/AWSCognito-arm64
$lipo -info AWSCognito.framework/AWSCognito-merged 
Architectures in the fat file: AWSCognito.framework/AWSCognito-merged are: armv7 arm64 
# 元のファイルを削除し、置き換える
$rm -rf AWSCognito.framework/AWSCognito
$mv AWSCognito.framework/AWSCognito-merged  AWSCognito.framework/AWSCognito
$rm -rf AWSCognito.framework/AWSCognito-*
# AWSAPIGateway.framework、AWSCognitoIdentityProvider.framework、AWSCore.frameworkに関しても同様に行う

余談ですが、
otoolとかlipoとかnmとか使うと
特定のコンパイル済みファイル(.o)を除外したり、
静的ライブラリ(.a)ファイルを結合とか変態的なことができるみたい

19
16
2

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
19
16