{"id":18553020,"url":"https://github.com/ustwo/baseviewcontroller-swift","last_synced_at":"2025-10-05T01:52:04.827Z","repository":{"id":56903524,"uuid":"49124974","full_name":"ustwo/baseviewcontroller-swift","owner":"ustwo","description":"An organizational tool for writing custom view controllers using UIKit.","archived":false,"fork":false,"pushed_at":"2019-10-15T11:00:07.000Z","size":302,"stargazers_count":8,"open_issues_count":3,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-24T13:21:19.018Z","etag":null,"topics":["ios","swift","tvos","uikit"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ustwo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-06T09:09:21.000Z","updated_at":"2022-08-10T19:37:31.000Z","dependencies_parsed_at":"2022-08-21T02:50:12.699Z","dependency_job_id":null,"html_url":"https://github.com/ustwo/baseviewcontroller-swift","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ustwo%2Fbaseviewcontroller-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ustwo%2Fbaseviewcontroller-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ustwo%2Fbaseviewcontroller-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ustwo%2Fbaseviewcontroller-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ustwo","download_url":"https://codeload.github.com/ustwo/baseviewcontroller-swift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247713253,"owners_count":20983683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","swift","tvos","uikit"],"created_at":"2024-11-06T21:15:50.891Z","updated_at":"2025-10-05T01:51:59.793Z","avatar_url":"https://github.com/ustwo.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/ustwo/baseviewcontroller-swift/blob/master/LICENSE)\n[![Build Status](https://travis-ci.org/ustwo/baseviewcontroller-swift.svg?branch=master)](https://travis-ci.org/ustwo/baseviewcontroller-swift)\n[![codecov.io](https://codecov.io/github/ustwo/baseviewcontroller-swift/coverage.svg?branch=master)](https://codecov.io/github/ustwo/baseviewcontroller-swift?branch=master)\n[![Platform](https://img.shields.io/cocoapods/p/BaseViewControllerSwift.svg?style=flat)](https://ustwo.github.io/baseviewcontroller-swift)\n![Swift](https://img.shields.io/badge/Swift-5.0-orange.svg)\n\n# BaseViewController\n\nThe BaseViewController framework provides an organizational tool for writing custom view controllers using `UIKit`. This framework is written using Swift 3.0. It has been developed and used by iOS developers at [ustwo](https://ustwo.com/).\n\n## Dependencies\n\n* [Xcode](https://itunes.apple.com/gb/app/xcode/id497799835?mt=12#)\n\n## Installation\n\n### BaseViewControllerSwift version vs Swift version.\n\nBecause of the many Swift versions BaseViewControllerSwift supports, it might be confusing to find the version of BaseViewControllerSwift that you need. Below is a table that shows which version of BaseViewControllerSwift you should use for your Swift version.\n\n| Swift version | BaseViewControllerSwift version |\n|---------------|---------------------------------|\n| 5.0           | 3.0.0                           |\n| 3.0           | 2.0.0                           |\n| 2.1           | 1.0.0                           |\n\n### CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\nTo integrate BaseViewControllerSwift into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '8.3'\nuse_frameworks!\n\npod 'BaseViewControllerSwift', '~\u003e 2.0'\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### Manually\n\nIf you prefer not to use either of the aforementioned dependency managers, you can integrate BaseViewControllerSwift into your project manually. Add the `BaseViewController.swift` file from the `Sources` folder to your Xcode project.\n\n## Usage\n\nUse the `BaseViewController` as a base class for all your custom view controllers. Then override our common setup functions and have them automatically called as part of the initialization.\n\n`BaseViewController` itself is a subclass of `UIViewController`. It contains two empty setup functions that are called by `viewDidLoad()`. These commonly used setup functions are `setupView()` and `setupAccessibility()` and are called in that order.\n\nIn addition, `BaseViewController` is also a generic class that takes a `UIView` as a type parameter. During the `loadView()` phase, it instantiates the view and sets it as the controller's view. `BaseViewController` also provides a `underlyingView` property for accessing the view without needing to type cast.\n\n## Examples\n\nHere are some example implementations of using `BaseViewController`. In all of the examples we call `super` on the setup function, but do this as appropriate in your own code.\n\n### Controller Definition\n\nWhen defining your custom view controller, inherit from `BaseViewController` and specify your custom view. There is no need to instantiate your custom view or add an accessing property. This is all done by `BaseViewController`.\n\n```swift\nfinal class ProfileViewController: BaseViewController\u003cProfileView\u003e {\n  ...\n}\n```\n\n### setupView\n\nUse the `setupView()` function to add target/actions to controls, set dynamically generated values, etc.\n\n```swift\noverride func setupView() {\n\tsuper.setupView()\n\n\tunderlyingView.titleLabel.text = profile.name\n\tunderlyingView.finishedButton.addTarget(self, action: #selector(ProfileViewController.finishedButtonPressed(_:)), for: .touchUpInside)\n}\n```\n\n### setupAccessibility\n\nUse the `setupAccessibility()` function to add dynamically generated accessibility information to the view.\n\n```swift\noverride func setupAccessibility() {\n\tsuper.setupAccessibility()\n\n\tunderlyingView.profileImage.accessibilityLabel = NSLocalizedString(\"Image of\", comment: \"\") + \" \" +  profile.name\n}\n```\n\n## Maintainers\n\n* Shagun Madhikarmi (@madhikarma)\n* Aaron McTavish (@aamctustwo)\n\n## Contact\n\n* [open.source@ustwo.com](mailto:open.source@ustwo.com)\n\n## License\n\nBaseViewControllerSwift is released under the MIT License. See the LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fustwo%2Fbaseviewcontroller-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fustwo%2Fbaseviewcontroller-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fustwo%2Fbaseviewcontroller-swift/lists"}