Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ matrix:
- os: osx
language: generic
# Xcode version implicitly defines the Swift version to be used on macOS.
osx_image: xcode8.2
osx_image: xcode8.3

- os: osx
language: generic
# Xcode version implicitly defines the Swift version to be used on macOS.
osx_image: xcode9

- os: linux
language: generic
Expand All @@ -22,7 +27,7 @@ matrix:
#
# You can use tags to select a specific Swift version if the
# image supports it, e.g. "swift:3.0.2" or "swift:latest".
DOCKER_IMAGE="swift:3.0.2"
DOCKER_IMAGE="swift:3.1"

script:
- chmod ugo+x ./scripts/travis-build-script.sh
Expand Down
2 changes: 1 addition & 1 deletion Configs/SortedArray.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.3</string>
<string>0.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// swift-tools-version:3.1
import PackageDescription

/// Provides the `SortedArray` type, an array that keeps its elements
/// sorted according to a given sort predicate.
///
/// - Author: Ole Begemann
/// - Seealso: https://github.com/ole/SortedArray
/// - Seealso: https://blog/2017/02/sorted-array/
///
let package = Package(
name: "SortedArray"
name: "SortedArray",
swiftLanguageVersions: [3, 4]
)
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# SortedArray

A sorted array type written in Swift 3.0.
A sorted array type for Swift 3.1+ and 4.0+.

Provides the `SortedArray` type, an array that keeps its elements sorted according to a given sort predicate.

Written by Ole Begemann, February 2017.

For more info, see my accompanying [blog article](https://oleb.net/blog/2017/02/sorted-array/).
For more info, see the [GitHub repo](https://github.com/ole/SortedArray) and my accompanying [blog article](https://oleb.net/blog/2017/02/sorted-array/).

## Status

[![Build Status](https://travis-ci.org/ole/SortedArray.svg?branch=master)](https://travis-ci.org/ole/SortedArray)

## Supported Platforms

Supports Swift versions 3.1, 3.2, and 4.0. Not compatible with Swift 3.0. The last version compatible with Swift 3.0 is v0.4.

Since the code has no dependencies other than the Swift standard library (it doesn't even use Foundation), it should work on all platforms where Swift is available.

I tested it on macOS, iOS, tvOS, and Linux.
Expand Down
38 changes: 21 additions & 17 deletions SortedArray.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -334,36 +334,36 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = SortedArray;
TargetAttributes = {
52D6D97B1BEFF229002C0205 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
52D6D9851BEFF229002C0205 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
52D6D9E11BEFFF6E002C0205 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
52D6D9EF1BEFFFBE002C0205 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
52D6DA0E1BF000BD002C0205 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
DD7502791C68FCFC006590AF = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
DD75028C1C690C7A006590AF = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
};
};
Expand Down Expand Up @@ -531,14 +531,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -582,14 +588,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -610,6 +622,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
Expand All @@ -636,7 +649,6 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.olebegemann.SortedArray-iOS";
PRODUCT_NAME = SortedArray;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
Expand All @@ -658,7 +670,6 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.olebegemann.SortedArray-iOS";
PRODUCT_NAME = SortedArray;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
Expand All @@ -671,7 +682,6 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.SortedArray.SortedArray-iOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
Expand All @@ -684,7 +694,6 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.SortedArray.SortedArray-iOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
Expand Down Expand Up @@ -727,7 +736,6 @@
PRODUCT_NAME = SortedArray;
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
Expand Down Expand Up @@ -772,7 +780,6 @@
PRODUCT_NAME = SortedArray;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
Expand Down Expand Up @@ -821,7 +828,6 @@
PRODUCT_NAME = SortedArray;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
Expand Down Expand Up @@ -852,7 +858,6 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.SortedArray.SortedArray-macOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
Expand All @@ -878,7 +883,6 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.SortedArray.SortedArray-tvOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TVOS_DEPLOYMENT_TARGET = 9.1;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Latest</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
Expand Down Expand Up @@ -56,6 +57,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
Expand Down Expand Up @@ -56,6 +57,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
Expand Down Expand Up @@ -56,6 +57,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
Expand All @@ -37,6 +38,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
6 changes: 5 additions & 1 deletion Tests/SortedArrayTests/SortedArrayTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ class SortedArrayTests: XCTestCase {

func testLinuxTestSuiteIncludesAllTests() {
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
let darwinTestCount = Int(SortedArrayTests.defaultTestSuite().testCaseCount)
#if swift(>=4.0)
let darwinTestCount = SortedArrayTests.defaultTestSuite.testCaseCount
#else
let darwinTestCount = Int(SortedArrayTests.defaultTestSuite().testCaseCount)
#endif
let linuxTestCount = SortedArrayTests.allTests.count
XCTAssertEqual(linuxTestCount, darwinTestCount, "allTests (used for testing on Linux) is missing \(darwinTestCount - linuxTestCount) tests")
#endif
Expand Down
15 changes: 10 additions & 5 deletions scripts/travis-build-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@
# <https://travis-ci.org/>. Supports testing Swift Package Manager
# packages on macOS and Linux.

set -ue -o pipefail

echo "Running on OS: ${TRAVIS_OS_NAME}"

if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
# macOS
# 1. Test using Swift Package Manager
swift build --clean
swift --version
swift package clean
swift build
swift test
swift test --parallel

# 2. Test using xcodebuild
set -o pipefail
xcodebuild -version
xcodebuild -showsdks
instruments -s devices
xcodebuild test -scheme SortedArray-macOS | xcpretty
xcodebuild test -scheme SortedArray-iOS -destination "platform=iOS Simulator,name=iPhone 7,OS=10.1" | xcpretty
xcodebuild test -scheme SortedArray-tvOS -destination "platform=tvOS Simulator,name=Apple TV 1080p" | xcpretty
Expand All @@ -25,9 +30,9 @@ elif [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
echo "Using Docker image: ${DOCKER_IMAGE}"
# Download the Docker container. This is not strictly necessary since
# docker run would automatically download a missing container.
docker pull ${DOCKER_IMAGE}
docker pull "${DOCKER_IMAGE}"
# Share the current directory (where Travis checked out the repository)
# with the Docker container.
# Then, in the container, cd into that directory and run the tests.
docker run --volume "$(pwd):/root/repo" ${DOCKER_IMAGE} /bin/bash -c "cd /root/repo; swift build --clean; swift build; swift test"
docker run --volume "$(pwd):/package" "${DOCKER_IMAGE}" /bin/bash -c "cd /package; swift --version; swift package clean; swift build; swift test --parallel"
fi