ボイラー プレート ファイルと MVVM デザイン パターンのコード構造を含む Xcode ファイル テンプレートを作成しようとしています。
以下のように、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>Kind</key>
<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
<key>Description</key>
<string>MVVM Module Template.</string>
<key>Summary</key>
<string>MVVM Module Template</string>
<key>Options</key>
<array>
<dict>
<key>Identifier</key>
<string>productName</string>
<key>Required</key>
<true/>
<key>Name</key>
<string>Module Name:</string>
<key>Description</key>
<string>The module name.</string>
<key>Type</key>
<string>text</string>
<key>Default</key>
<string>Base</string>
</dict>
<dict>
<key>Identifier</key>
<string>View</string>
<key>Name</key>
<string>Also create View file for user interface</string>
<key>Description</key>
<string>Create a view file with the same name</string>
<key>Type</key>
<string>checkbox</string>
<key>NotPersisted</key>
<true/>
</dict>
</array>
</dict>
</plist>
問題は、チェックボックスをオンにすると、View フォルダー内のすべてのファイルが作成されましたが、チェックボックスをオフにすると、ファイルが作成されないことでした。
次のケースを達成するにはどうすればよいですか。
- チェックボックスがオフの場合、「ソース」フォルダからソース ファイルを生成します。
- チェックボックスがチェックされている場合、フォルダ「View」からソースファイルを生成します。