13
14

More than 5 years have passed since last update.

iOSのopensslライブラリをビルドする手順

Last updated at Posted at 2015-10-03

以下の条件でopensslフレームワークを生成します。

  • Xcode: 7.0
  • Mac OS: 10.10.5 Yosemite
  • OpenSSL version: 1.0.2d

1. 現在のOpenSSLバージョンを確認

$ openssl version -a

OpenSSL 0.9.8zg 14 July 2015
....

2. OpenSSLをHomebrewでアップデート

$ brew update
$ brew install openssl
$ brew link --force openssl

シェルを再起動後バージョンを再度確認します。

$ openssl version -a
OpenSSL 1.0.2d 9 Jul 2015
...

3. 変換プログラムを入手

x2on/OpenSSL-for-iPhone

上記リンクからZIPをダウンロードします。
解凍したフォルダへ移動し以下のコマンドを実行してビルドします。

./build-libssl.sh

しばらく待てば完成。

フレームワーク化するには以下のコマンドを実行し、生成されたopenssl.frameworkを各自のプロジェクトへ取り込みます。

./create-openssl-framework.sh

Xcode7.0ではフレームワークを追加しても、Build SettingsのFramework Search Pathが自動で追加されないので手動で追加したパスを記載する必要があるので注意が必要です。

ビルドエラーが出た場合の対処

clang: warning: no such sysroot directory: '/Library/Developer/CommandLineTools/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk'
In file included from cryptlib.c:117:
./cryptlib.h:62:11: fatal error: 'stdlib.h' file not found
# include <stdlib.h>
          ^
1 error generated.
make[1]: *** [cryptlib.o] Error 1
make: *** [build_crypto] Error 1

上記のようなエラーでビルドできない場合は次のコマンドを実行します。

$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

Xcode.appの名称を(Xcode7.app等)変更している場合は
$ sudo xcode-select -switch /Applications/Xcode7.app/Contents/Developer

先ほど解凍したフォルダを削除し、再度zipから解凍、そのフォルダへ移動して以下を再度実行すると通るかと思います。

$ ./build-libssl.sh

おわり

Cocoapodsにもあったかな?

13
14
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
13
14