Instantly share code, notes, and snippets.

@elitalon /Makefile
Last active Apr 25, 2018

Embed
What would you like to do?
A Makefile template providing shortcuts to iOS development tasks
SHELL = bash
###
# xcodebuild common arguments
###
WORKSPACE := MyProject.xcworkspace
SCHEME := MyScheme
PROJECT := MyProject.xcodeproj
DEBUG_CONFIGURATION := Debug
SIMULATOR := platform=iOS Simulator,OS=9.2,name=iPhone 6
###
# Utility programs
###
XCPRETTY := xcpretty
SLATHER := slather
DOXYGEN := doxygen
JAZZY := jazzy
XCODEBUILD := xcodebuild -workspace "${WORKSPACE}" -scheme "${SCHEME}"
###
# Directories
###
DOCS_DIRECTORY := docs
BUILD_DIRECTORY := build
REPORTS_DIRECTORY := ${BUILD_DIRECTORY}/reports
###
# Custom targets
###
.PHONY: clean build test
.PHONY: analyze report_coverage
.PHONY: documentation delete_documentation
.PHONY: ${XCPRETTY} ${SLATHER} ${DOXYGEN} ${JAZZY}
.DEFAULT_GOAL = build
###
# Building
###
clean: ${XCPRETTY}
@set -o pipefail && ${XCODEBUILD} -configuration "${DEBUG_CONFIGURATION}" clean | ${XCPRETTY}
build: clean
@set -o pipefail && ${XCODEBUILD} -configuration "${DEBUG_CONFIGURATION}" -destination "${SIMULATOR}" build | ${XCPRETTY}
test: clean
@set -o pipefail && ${XCODEBUILD} -configuration "${DEBUG_CONFIGURATION}" -destination "${SIMULATOR}" test | ${XCPRETTY}
${XCPRETTY}:
@type ${XCPRETTY}
###
# Code Quality
###
analyze: clean
@set -o pipefail && ${XCODEBUILD} -configuration "${DEBUG_CONFIGURATION}" -sdk iphoneos analyze | ${XCPRETTY}
report_coverage: test
@slather coverage --simple-output "${PROJECT}"
# When build artifacts must be generated
${REPORTS_DIRECTORY}:
@mkdir -p ${REPORTS_DIRECTORY}
###
# Documentation
###
# FIXME: Jazzy for Objective-C only seems to play well with frameworks, not apps.
# jazzy --objc --clean --umbrella-header ???.h --framework-root . --sdk iphoneos
documentation: ${DOXYGEN} delete_documentation
@${DOXYGEN}
${DOXYGEN}:
@type ${DOXYGEN}
delete_documentation: ${DOCS_DIRECTORY}
@echo "Cleaning ${DOCS_DIRECTORY} directory" && rm -rf "${DOCS_DIRECTORY}/*"
${DOCS_DIRECTORY}:
@mkdir -p ${DOCS_DIRECTORY}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment