LoginSignup
1
1

More than 1 year has passed since last update.

【Swift】MintでLicensePlistを使う

Last updated at Posted at 2022-10-15

はじめに

以前、CocoaPodsを使用してLicensePlistを導入する記事を書きました。
しかし、個人的にxcworkspaceが作られるのが好きではないでの最近はmintを使用してLicensePlistを導入しています。
今回はmintを使ってLicensePlistを導入する方法を記事に記録しておきます。

今回使用するサンプルプロジェクト

スクリーンショット 2022-10-15 21.16.45.png

やりかた

Mintfile

ターミナル
cd プロジェクトフォルダ

Mintfileを作成します

ターミナル
touch Mintfile

Mintfileを開きます

ターミナル
open Mintfile

MintfileにLicensePlistを記載します

Mintfile
mono0926/LicensePlist

LicensePlistをインストールします

ターミナル
mint bootstrap

Settings Bundle

メインターゲットのファイルを選択します
スクリーンショット 2022-10-15 21.20.26.png

⌘ + Nで新規ファイル作成画面を表示させます
検索ボックスに「Setting」と入力してSettings Bundleを選択します
スクリーンショット 2022-10-15 21.22.01.png
Settingsという名前で「Create」を選択します
スクリーンショット 2022-10-15 21.22.29.png
① 「en.lproj」と「Root」を右クリックします
② 「Delete」を選択します
スクリーンショット 2022-10-15 21.25.44.png
「Move to Trash」を選択します
スクリーンショット 2022-10-15 21.26.55.png
メインターゲットのファイルを選択します
スクリーンショット 2022-10-15 21.29.46.png
⌘ + Nで新規ファイル作成画面を表示させます。
検索ボックスに「Property」と入力してProperty Listを選択します。
スクリーンショット 2022-10-15 21.33.07.png
「Save As」にRootと入力して「Create」を選択します
スクリーンショット 2022-10-15 21.34.20.png
先ほど作成した「Root」を右クリックします
「Open As」にカーソルを合わせて「Source Code」を選択します
スクリーンショット 2022-10-15 21.37.18.png
既存のコードは全て削除して、以下のコードをコピペします。

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>StringsTable</key>
 <string>Root</string>
 <key>PreferenceSpecifiers</key>
 <array>
        <dict>
            <key>Type</key>
            <string>PSChildPaneSpecifier</string>
            <key>Title</key>
            <string>Licenses</string>
            <key>File</key>
            <string>com.mono0926.LicensePlist</string>
        </dict>
 </array>
</dict>
</plist>

「Root」を「Settings」ディレクトリに移動させます。
スクリーンショット 2022-10-15 21.41.03.png
このような形になります。
スクリーンショット 2022-10-15 21.41.50.png

Run Script

① プロジェクトを選択します
② ターゲットを選択します
③ 「Build Phases」を選択します
④ 左上の「+」を選択します
⑤ 「New Run Script Phase」を選択します
スクリーンショット 2022-10-15 21.43.00.png
追加された「Run Script」に以下のコードをコピペします。

export PATH=/opt/homebrew/bin:$PATH

if which mint >/dev/null; then
    # LicensePlist
    xcrun --sdk macosx mint run mono0926/LicensePlist --output-path $PROJECT_NAME/Resource/Settings.bundle
else 
    echo 'warning: mint not installed.'

fi

スクリーンショット 2022-10-15 21.46.43.png

ビルド

スクリーンショット 2022-10-15 21.48.49.png

成功!!

スクリーンショット 2022-10-15 21.49.25.png

おわり

CocoaPodsよりもmintの方が使いやすくて好きになりました

1
1
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
1
1