LoginSignup
29

More than 3 years have passed since last update.

【iOS】ライセンス一覧を設定アプリに自動表記する方法【LicensePlist】

Last updated at Posted at 2020-08-03

今回はアプリ内で利用したライブラリのライセンス一覧を、簡単に設定アプリに表記する方法を紹介します。
ライブラリを新しく追加しても更新されるのでとても便利です。

スクリーンショット 2020-08-03 8.39.34.png

LicensePlistというライブラリを活用する

ライセンス一覧を手軽に表記することができる、かなりオススメのライブラリです。
有名なアプリでも結構使われているみたいです、開発者の方いつもお世話になっています!

①インストール

Cocoapodsを使いました。

pod ‘LicensePlist’とPodfileに入れてinstallします。

②Run Scriptを編集

Xcodeの Build Phases のRun Script Phase にスクリーンショット 2020-08-03 9.42.21.png
下記を追加します。

if [ $CONFIGURATION = "Debug" ]; then
    ${PODS_ROOT}/LicensePlist/license-plist --output-path $PRODUCT_NAME/Settings.bundle
fi

③Settings.bundleを追加

新規ファイルでSettings.bundleを追加します。
スクリーンショット 2020-08-03 13.16.31.png

Settings.bundleの中に作られるen.lprojというフォルダは必要ないので削除して、Root.plistだけを残します。

④Root.plistを編集

Root.plistを好きなエディタで開き、下記の様に編集します。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>PreferenceSpecifiers</key>
        <array>
            <dict>
                <key>Title</key>
                <string>Licenses</string>
                <key>Type</key>
                <string>PSChildPaneSpecifier</string>
                <key>File</key>
                <string>com.mono0926.LicensePlist</string>
            </dict>
        </array>
        <key>StringsTable</key>
        <string>Root</string>
    </dict>
</plist>

⑤ビルドする

ビルドが完了するとSettings.bundleの中に、ライブラリのライセンスを表示するためのフォルダが追加されます。

設定アプリを見ると、ライセンス一覧が確認できます。
※表示されない場合は再度ビルドして下さい

IMG_6F8E099B2506-1.jpeg

参考

https://github.com/mono0926/LicensePlist
https://medium.com/swift-column/license-plist-c0363a008c67
https://tomoyaonishi.hatenablog.jp/entry/2018/09/19/133447

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
29