Skip to content

earnshavian/ios-template

 
 

Repository files navigation

iOS template

A template for new iOS projects at Raizlabs.

Inspired by thoughtbot/ios-template

What's in the template?

  • Configures the project name, company name, lead name, an initial local repo, gitignore and synx.
  • Option to configure Hockey apps automatically.
  • Default Fastfile with test, develop, sprint, beta and release lanes and slack notifications.
  • Configuration for CircleCI with auto-triggered builds for merges to develop or tags prefixed with sprint, beta or release.
  • APIClient Stub with functional OAuth implementation and APIEndpoint protocol.
  • SwiftGen configured to generate localized strings and image enums.
  • Default swiftlint rules to help enforce code style standards across projects.
  • Default set of Cocoapods including:
    • Anchorage - "A lightweight collection of intuitive operators and utilities that simplify iOS layout code."
    • BonMot - "Beautiful, easy attributed strings in Swift"
    • Swiftilities - Keyboard avoidance guides, lifecycle event code injection, about view, accessibility helpers, color helpers, device size detection, hairline views, logging
    • KeychainAccess - Wrapper for keychain APIs. Used by the Oath implementation to protect credentials
    • OHHTTPStubs - Stub API requests with edge case datasets for unit tests or to fake an endpoint while it is in development.

Usage

  1. Install cookiecutter (brew install cookiecutter on macOS).
  2. Run cookiecutter gh:raizlabs/ios-template.
  3. Answer the questions.
  4. Delete anything that is not of interest to your project.

Configuring the generated project

Fastlane

Crashlytics

Instabug

OAuth Endpoint

APIClient

Cookie Cutter

Cookie Cutter is a python project for templating files and directories. Cookie cutter will ask a serires of questions as defined in cookiecutter.json and then run the expansion on the contained files and directory names, and file contents. Anything with {{ cookiecutter.variable }} is expanded when the template is expanded. This is a powerful primitive, but has some complications with Xcode

Post processing

Cookie cutter follows a pattern of expand and prune, where the superset of the template is expanded, and then any specific functionality is pruned in a post in shell script post_gen_project.sh. You can also run shell scripts to integrate with webservices. The included post_gen_project.sh is a good example of this and it will create 2 apps on hockey and configure the Fastfile.

Contributing to the template

Managing an XCode Project Template

If you place a cookie cutter expansion in a .pbxproj file, Xcode will no longer open the project file. To simplify managing the Xcode project, I have a more primitive expansion script in generate_template.sh that will replace a smaller set of words with cookiecutter variables. In particular PRODUCTNAME is expanded to {{ cookiecutter.project_name }}. Using this simpler form of expansion allows the project in the PRODUCTNAME directory to continue to work in Xcode, and lets you manage your template just like any other Xcode project. When you are done with modifications, run generate_template.sh | sh.

If you are looking to do specific Xcode project modifications, I would recommend using .xcconfig files, and placing any expansion in those files. If you are looking to expand variables outside of the project file, you can use cookie cutters {{ cookiecutter.whatever }} variables directly.

About

A `cookiecutter` template for iOS projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 86.6%
  • Ruby 11.9%
  • Shell 1.2%
  • Objective-C 0.3%