Skip to content

Commit

Permalink
Simplify installation instructions in README (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewchang-bird authored May 18, 2020
1 parent e66be63 commit a246a83
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 121 deletions.
16 changes: 5 additions & 11 deletions Examples/iOSMockingbirdExample-Carthage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ Having issues setting up Mockingbird? Join the [Slack channel](https://slofile.c

## Tutorial

### Create the Xcode Project

Open Xcode and create an iOS Single View App with the name `iOSMockingbirdExample-Carthage`. Make sure
that the checkbox labeled “Include Unit Tests” is selected.

### Configure Carthage

Create the Cartfile in the Xcode project root directory.
Expand All @@ -30,24 +25,23 @@ $ echo 'github "birdrides/mockingbird" ~> 0.12' >> Cartfile

### Install Mockingbird

Build the framework using Carthage.
Build the framework and link the built `Mockingbird.framework` to the test target, making sure to add the
framework to
[a new Copy Files build phase](https://github.com/birdrides/mockingbird/wiki/Linking-Test-Targets) with the
destination set to `Frameworks`.

```bash
$ carthage update --platform ios
$ open Carthage/Build/iOS
```

Link the built `Mockingbird.framework` to the test target, making sure to add the framework to
[a new Copy Files build phase](https://github.com/birdrides/mockingbird/wiki/Linking-Test-Targets) with the
destination set to `Frameworks`.

Then install the CLI.

```bash
$ (cd Carthage/Checkouts/mockingbird && make install-prebuilt)
```

Configure the test target by using the CLI.
Configure the test target.

```bash
$ mockingbird install \
Expand Down
9 changes: 2 additions & 7 deletions Examples/iOSMockingbirdExample-CocoaPods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ Having issues setting up Mockingbird? Join the [Slack channel](https://slofile.c

## Tutorial

### Create the Xcode Project

Open Xcode and create an iOS Single View App with the name `iOSMockingbirdExample-CocoaPods`. Make sure
that the checkbox labeled “Include Unit Tests” is selected.

### Configure CocoaPods

Create the Podfile in the Xcode project root directory.
Expand All @@ -33,14 +28,14 @@ end

### Install Mockingbird

Install the framework and CLI.
Initialize the pod and install the CLI.

```bash
$ pod install
$ (cd Pods/MockingbirdFramework && make install-prebuilt)
```

Then configure the test target by using the CLI.
Then configure the test target.

```bash
$ mockingbird install \
Expand Down
11 changes: 3 additions & 8 deletions Examples/iOSMockingbirdExample-SPM/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ Having issues setting up Mockingbird? Join the [Slack channel](https://slofile.c

## Tutorial

### Create the Xcode Project

Open Xcode and create an iOS Single View App with the name `iOSMockingbirdExample-SPM`. Make sure that the
checkbox labeled “Include Unit Tests” is selected.

### Configure Dependencies

1. File > Swift Packages > Add Package Dependency…
Expand All @@ -22,17 +17,17 @@ checkbox labeled “Include Unit Tests” is selected.

### Install Mockingbird

Install the CLI from the checked out Mockingbird repository in derived data.
Initialize the package dependency and install the CLI.

```bash
$ xcodebuild -resolvePackageDependencies
$ DERIVED_DATA=$(xcodebuild -showBuildSettings | grep -m1 'BUILD_DIR' | grep -o '\/.*' | dirname $(xargs dirname))
$ DERIVED_DATA=$(xcodebuild -showBuildSettings | pcregrep -o1 'OBJROOT = (/.*)/Build')
$ (cd "${DERIVED_DATA}/SourcePackages/checkouts/mockingbird" && make install-prebuilt)
```

### Configure Test Target

Configure the test target by using the CLI.
Configure the test target.

```bash
$ mockingbird install \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ setup-carthage:

setup-spm:
(cd Examples/iOSMockingbirdExample-SPM && xcodebuild -resolvePackageDependencies)
$(eval DERIVED_DATA = $(shell xcodebuild -project Examples/iOSMockingbirdExample-SPM/iOSMockingbirdExample-SPM.xcodeproj -showBuildSettings | grep -m1 'BUILD_DIR' | grep -o '\/.*' | xargs dirname | xargs dirname))
$(eval DERIVED_DATA = $(shell xcodebuild -project Examples/iOSMockingbirdExample-SPM/iOSMockingbirdExample-SPM.xcodeproj -showBuildSettings | pcregrep -o1 'OBJROOT = (/.*)/Build'))
(cd $(DERIVED_DATA)/SourcePackages/checkouts/mockingbird && make install-prebuilt)

test-cocoapods: setup-cocoapods
Expand Down
28 changes: 25 additions & 3 deletions MockingbirdCli/Interface/Commands/InstallCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,24 @@ import MockingbirdGenerator
import PathKit
import SPMUtility

final class InstallCommand: BaseCommand {
class ConfigureCommand: InstallCommand {
private enum Constants {
static let name = "configure"
static let overview = "Configure a test target to use mocks (alias of 'install')."
}
override var name: String { return Constants.name }
override var overview: String { return Constants.overview }

required init(parser: ArgumentParser) {
super.init(parser: parser, name: Constants.name, overview: Constants.overview)
}

required init(parser: ArgumentParser, name: String, overview: String) {
super.init(parser: parser, name: name, overview: overview)
}
}

class InstallCommand: BaseCommand, AliasableCommand {
private enum Constants {
static let name = "install"
static let overview = "Configure a test target to use mocks."
Expand All @@ -37,8 +54,12 @@ final class InstallCommand: BaseCommand {
private let disableCacheArgument: OptionArgument<Bool>
private let disableRelaxedLinking: OptionArgument<Bool>

required init(parser: ArgumentParser) {
let subparser = parser.add(subparser: Constants.name, overview: Constants.overview)
required convenience init(parser: ArgumentParser) {
self.init(parser: parser, name: Constants.name, overview: Constants.overview)
}

required init(parser: ArgumentParser, name: String, overview: String) {
let subparser = parser.add(subparser: name, overview: overview)

self.projectPathArgument = subparser.addProjectPath()
self.sourceTargetsArgument = subparser.addSourceTargets()
Expand Down Expand Up @@ -108,6 +129,7 @@ final class InstallCommand: BaseCommand {
print("""
Please add starter supporting source files for basic compatibility with system frameworks.
$ mockingbird download starter-pack
See https://github.com/birdrides/mockingbird/wiki/Supporting-Source-Files for more information.
""")
}
}
4 changes: 4 additions & 0 deletions MockingbirdCli/Interface/Program.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ protocol Command {
workingPath: Path) throws
}

protocol AliasableCommand: BaseCommand {
init(parser subparser: ArgumentParser, name: String, overview: String)
}

class BaseCommand: Command {
var name: String { fatalError() }
var overview: String { fatalError() }
Expand Down
1 change: 1 addition & 0 deletions MockingbirdCli/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func main(arguments: [String]) -> Int32 {
let program = Program(usage: "<method>",
overview: "Mockingbird mock generator",
commands: [GenerateCommand.self,
ConfigureCommand.self,
InstallCommand.self,
UninstallCommand.self,
DownloadCommand.self,
Expand Down
Loading

0 comments on commit a246a83

Please sign in to comment.