Skip to content

Commit

Permalink
Adds support for macOS and tvOS targets using Carthage and SwiftPM (D…
Browse files Browse the repository at this point in the history
…iUS#32)

* Updates the project with Xcode suggested Swift4 updates

* Updates frameworks’ version in Cartfile

* Removes argument from closure

* Explicitly exposes swift functions to objc

* Fixes non-prototype declaration

* Bumps up TravisCI osx_image to 9

* Removes block declaration is not a prototype warning

* Prepares Swift PM project structure

* Builds and tests for iOS target

* Builds for macOS and tvOS targets

* Still supports older deployment targets

- iOS 9.3
- macOS 10.10
- tvOS 9.2

* TravisCI builds for the Apple’s four platforms

* Does not explicitly upgrade swiftlint

TravisCI complained that latest swiftlint was already installed.

* The order of script steps *is* important

* Build dependencies for all supported platforms

* Discards fastlane scan and uses xcodebuild matrix

* TravisCI builds dependencies only for the needed platform

* Disables bitcode for iOS target

- Nimble framework does not contain bitcode

* Excludes watchOS

Dependency Nimble does not (yet) support watchOS

* TravisCI does not build for watchOS

* Builds for iOS and macOS using Carthage

- tests on iOS 11, 10.3.1 and 9.3
- tests on macOS x86_64

* Project structure cleanup

* Adds support for Swift Package Manager

* Updates Podspec and Supports Swift Package Manager

* Updates podspec

* Updates README.md

* Removes Scanfile and updates Contributing information

- Scanfile no longer valid as framework supports macOS as well
- Adds contributing information how to test for different platforms and package managers
- Fixes code coverage settings

* Updates documentation and fixes scheme test pre- post- scripts

* Updates README.md

* Updates README.md and Travis config

* Removes writing mock service startup/stop to log files

* Updates README.md

* Improves test coverage

* Removes iOS incompatible files

* Adds Carthage tvOS support

* TravisCI config to build for tvOS

* fixes travis config file structure/indent

* Adds AppleTV 4K test to TravisCI config

- Tests with AppleTV 4K
- Bumps up the Swift version in .swift-version file

* Code style improvements

* Reduces the number of destinations in TracisCI and reintroduces build.sh script
  • Loading branch information
surpher authored and andrewspinks committed Oct 2, 2017
1 parent 5248ba4 commit 51b567a
Show file tree
Hide file tree
Showing 34 changed files with 2,177 additions and 349 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ coverage:
changes: no

ignore:
- PactConsumerSwiftTests/*
- Tests/*

parsers:
gcov:
Expand Down
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.0
3 changes: 1 addition & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ excluded:
- scripts
- Carthage
- certificates
- PactConsumerSwiftTests/
- Products/
included:
- PactConsumerSwift/
- Sources/
opt_in_rules:
- empty_count
force_cast:
Expand Down
23 changes: 17 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
language: objective-c
osx_image: xcode9
env:
global:
- IOS_FRAMEWORK_SCHEME="PactConsumerSwift iOS"
- MACOS_FRAMEWORK_SCHEME="PactConsumerSwift macOS"
- TVOS_FRAMEWORK_SCHEME="PactConsumerSwift tvOS"
- PROJECT_NAME="PactConsumerSwift.xcodeproj"
- secure: QmmEqePFeG6D1Qu0KrWI0w6LiwiY3V2qUWAHxQrSYFFPG4wJOZuHpwdk9NO45gOzPYxbkzXT9MynWFMs5pZKrIJCmQRkK5fNcDecwvNunsJEzBmvNYLhd0B4IKy2R1pBmKcDHPIYCzgpanPDAV7LhTXlGoUGk59+QL6qK8+hBQs=
- secure: FpfacekFs93LkX9gerQUxQKIDTjBl2abp7ZQ/8L3DiJo4nMF7xEwUGeSDQMR+2hRqRWr/SdU59Lll5k10JBqWxAaLXDTUq3Lh3aamc4nc2PAN7yp+0aq9RQG5+PaLkfx+SLs5B/CjDiRRotZg/H/uMTRRFbkqydVtxiqGv94JOg=
matrix:
- DESTINATION="OS=11.0,name=iPhone 8" SCHEME="$IOS_FRAMEWORK_SCHEME" CARTHAGE_PLATFORM="iOS"
- DESTINATION="OS=10.3.1,name=iPhone 7 Plus" SCHEME="$IOS_FRAMEWORK_SCHEME" CARTHAGE_PLATFORM="iOS"

- DESTINATION="OS=11.0,name=Apple TV 4K (at 1080p)" SCHEME="$TVOS_FRAMEWORK_SCHEME" CARTHAGE_PLATFORM="tvOS"

- DESTINATION="arch=x86_64" SCHEME="$MACOS_FRAMEWORK_SCHEME" CARTHAGE_PLATFORM="macOS"
before_install:
- scripts/import_keychain.sh
- security find-identity -v -p codesigning
- gem install pact-mock_service -v 2.1.0
- bundle install
- brew update
- brew outdated carthage || brew upgrade carthage
- brew outdated swiftlint || brew upgrade swiftlint
- carthage checkout
script:
- set -o pipefail
- swiftlint
- carthage build --no-skip-current --platform iOS
- carthage build --no-skip-current --platform $CARTHAGE_PLATFORM
- scripts/build.sh
- bash <(curl -s https://codecov.io/bash) -J 'PactConsumerSwift'
after_script: scripts/delete_keychain.sh
after_success:
- scripts/build_children.sh
env:
global:
- secure: QmmEqePFeG6D1Qu0KrWI0w6LiwiY3V2qUWAHxQrSYFFPG4wJOZuHpwdk9NO45gOzPYxbkzXT9MynWFMs5pZKrIJCmQRkK5fNcDecwvNunsJEzBmvNYLhd0B4IKy2R1pBmKcDHPIYCzgpanPDAV7LhTXlGoUGk59+QL6qK8+hBQs=
- secure: FpfacekFs93LkX9gerQUxQKIDTjBl2abp7ZQ/8L3DiJo4nMF7xEwUGeSDQMR+2hRqRWr/SdU59Lll5k10JBqWxAaLXDTUq3Lh3aamc4nc2PAN7yp+0aq9RQG5+PaLkfx+SLs5B/CjDiRRotZg/H/uMTRRFbkqydVtxiqGv94JOg=
26 changes: 23 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
# Contributing to Pact Consumer Swift

### Prepare development environment
The Pact Consumer Swift library is using carthage to manage library dependencies. You can install carthage using homebrew, then download and build the dependencies using `carthage bootstrap`
The Pact Consumer Swift library is using Carthage and Swift Package Manager to manage library dependencies. You can install carthage using homebrew, then download and build the dependencies using `carthage bootstrap` or `swift package resolve`.

### Running tests
`scan`
iOS 11.0 on iPhone 8:
```
xcodebuild -project PactConsumerSwift.xcodeproj -scheme "PactConsumerSwift iOS" -destination "OS=11.0,name=iPhone 8" -configuration Debug ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty;
```

For more information, see the .travis.yml
macOS:
```
xcodebuild -project PactConsumerSwift.xcodeproj -scheme "PactConsumerSwift macOS" -destination "arch=x86_64" -configuration Debug ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty;
```

#### Test Carthage compatibility
```
carthage build --no-skip-current --platform iOS,macOS
```

#### Test Swift Package Manager build
```
./scripts/start_server.sh &&
swift build &&
./scripts/stop_server.sh
```

For more information, see the [.travis.yml](/.travis.yml)
1 change: 1 addition & 0 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github "Alamofire/Alamofire" ~> 4.5
github "Thomvis/BrightFutures" ~> 5.2
github "Quick/Nimble" ~> 7.0
github "Quick/Quick" ~> 1.1
1 change: 0 additions & 1 deletion Cartfile.private

This file was deleted.

2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github "Alamofire/Alamofire" "4.5.0"
github "Alamofire/Alamofire" "4.5.1"
github "Quick/Nimble" "v7.0.1"
github "Quick/Quick" "v1.1.0"
github "Thomvis/BrightFutures" "5.2.0"
Expand Down
52 changes: 52 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"object": {
"pins": [
{
"package": "Alamofire",
"repositoryURL": "https://github.com/Alamofire/Alamofire.git",
"state": {
"branch": null,
"revision": "b8995447518fd57af14c88a47f27434a16f60403",
"version": "4.5.1"
}
},
{
"package": "BrightFutures",
"repositoryURL": "https://github.com/Thomvis/BrightFutures.git",
"state": {
"branch": null,
"revision": "f18744a3061d2302a3673aafdb6fbdbbfe9b4f6f",
"version": "5.2.0"
}
},
{
"package": "Nimble",
"repositoryURL": "https://github.com/Quick/Nimble.git",
"state": {
"branch": null,
"revision": "39b67002306fda9de4c9fd1290a6295f97edd09e",
"version": "7.0.1"
}
},
{
"package": "Quick",
"repositoryURL": "https://github.com/Quick/Quick.git",
"state": {
"branch": null,
"revision": "e4fa1e85c0305ba4e0866f25812d3fa398f3a048",
"version": "1.1.0"
}
},
{
"package": "Result",
"repositoryURL": "https://github.com/antitypical/Result.git",
"state": {
"branch": null,
"revision": "c8446185238659a2b27c0261f64ff1254291d07d",
"version": "3.2.3"
}
}
]
},
"version": 1
}
30 changes: 30 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// swift-tools-version:4.0

import PackageDescription

let package = Package(
name: "PactConsumerSwift",
products: [
.library(
name: "PactConsumerSwift",
targets: ["PactConsumerSwift"]
),
],
dependencies: [
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "4.5.1"),
.package(url: "https://github.com/Quick/Quick.git", from: "1.1.0"),
.package(url: "https://github.com/Quick/Nimble.git", from: "7.0.1"),
.package(url: "https://github.com/Thomvis/BrightFutures.git", from: "5.2.0")
],
targets: [
.target(
name: "PactConsumerSwift",
dependencies: ["Alamofire", "BrightFutures", "Nimble"],
path: "./Sources"
),
.testTarget(
name: "PactConsumerSwiftTests",
dependencies: ["PactConsumerSwift", "Alamofire", "BrightFutures", "Nimble", "Quick"]
)
]
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#import "OCAnimalServiceClient.h"

@implementation Animal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <XCTest/XCTest.h>
#import "OCAnimalServiceClient.h"

Expand Down
19 changes: 11 additions & 8 deletions PactConsumerSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Pod::Spec.new do |s|
s.name = "PactConsumerSwift"
s.version = "0.4.3"
s.module_name = "PactConsumerSwift"
s.version = "0.5.0"
s.summary = "A Swift / ObjeciveC DSL for creating pacts."
s.license = { :type => 'MIT' }

Expand All @@ -13,18 +14,20 @@ Pod::Spec.new do |s|

s.homepage = "https://github.com/DiUS/pact-consumer-swift"

s.author = { "andrewspinks" => "[email protected]" }
s.author = { "andrewspinks" => "[email protected]", "markojustinek" => "[email protected]" }

s.ios.deployment_target = '9.0'
s.tvos.deployment_target = '9.0'
s.ios.deployment_target = '9.0'
s.tvos.deployment_target = '9.0'
s.osx.deployment_target = '10.10'

s.source = { :git => "https://github.com/DiUS/pact-consumer-swift.git", :tag => "v#{s.version}" }
s.source_files = 'PactConsumerSwift/**/*.swift'
s.resources = 'scripts/start_server.sh', 'scripts/stop_server.sh'
s.source_files = 'Sources/**/*.swift'
s.resources = 'scripts/start_server.sh', 'scripts/stop_server.sh'
s.requires_arc = true
s.frameworks = 'Foundation', 'UIKit', 'XCTest'
s.frameworks = 'Foundation', 'UIKit', 'XCTest', 'AppKit'

s.dependency 'Alamofire', '~> 4.4'
s.dependency 'Alamofire', '~> 4.5'
s.dependency 'BrightFutures', '~> 5.1'
s.dependency 'Nimble', '~> 7.0'
s.dependency 'Quick', '~> 1.1'
end
Loading

0 comments on commit 51b567a

Please sign in to comment.