Skip to content

⚒ ViewGenerator generates view code from variable name automatically in iOS development

License

Notifications You must be signed in to change notification settings

funzin/ViewGenerator

Repository files navigation

ViewGenerator

Platform Language License License

Overview

ViewGenerator generates view code from variable name automatically when you create view by code in iOS development

Download

Environment

  • Xcode 10.3 or greater
  • Swift 5.0 or greator

Demo

Install

  1. Install ViewGenerator from AppStore

  2. Enable ViewGenerator

    1. System PreferencesExtensions
    2. Switch on Xcode Source Editor checkbox

Usage

  1. Input variable name
    ⚠Important⚠ : variable name must be included class name without UI as suffix. (e.g. hogeView, hogeLabel, etc.)
    Please check Support View List bellow
  2. Select variable name
  3. EditorViewGeneratorGenerate View Code

  1. Generated⚒

Recommend

I strongly recommend that you register Generate View Code Command to shortcut

  1. Xcode Preferences → KeyBindings
  2. Input ViewGenerator in Search
  3. Register shortcut

Usage Example

Multiple variables

GIF
select

Single Variable

GIF
not_select
select

Supplement

Default access modifier is private . if you change access modifier, open viewgenerator app and then select access modifier that you want to select

Example

For example, if variable name prefix is hoge, it is generated as bellow

hogeView

private let hogeView: UIView = {
    let hogeView = UIView(frame: .zero)
    hogeView.translatesAutoresizingMaskIntoConstraints = false
    return hogeView
}()

hogeButton

private let hogeButton: UIButton = {
    let hogeButton = UIButton(frame: .zero)
    hogeButton.translatesAutoresizingMaskIntoConstraints = false
    return hogeButton
}()
hogeTableView
private let hogeTableView: UITableView = {
    let hogeTableView = UITableView(frame: .zero)
    hogeTableView.translatesAutoresizingMaskIntoConstraints = false
    return hogeTableView
}()
hogehoge
private let hogehoge: _InputTypeName_ = {
    let hogehoge = _InputTypeName_(frame: .zero)
    hogehoge.translatesAutoresizingMaskIntoConstraints = false
    return hogehoge
}()

Support View List

View
UISwitch
UIActivityIndicatorView
UIButton
UICollectionView
UIControl
UIDatePicker
UIImageView
UILabel
UINavigationBar
UIPageControl
UIPickerView
UIProgressView
UIScrollView
UISearchBar
UISegmentedControl
UISlider
UIStackView
UIStepper
UITabBar
UITableView
UITextField
UITextView
UIToolbar
UIView
UIVisualEffectView

If you input variable name that doesn't correspond to the support view list, type name is input as _InputTypeName_ automatically.

Contact

If you discover problem or have opinions, please let me know through Github issues💁‍♂️

Author

funzin

License

ViewGenerator is available under the MIT license. See the LICENSE file for more info.