Skip to content

Commit

Permalink
Add support for SPM and migrate to Swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
frederoni committed Jun 5, 2019
1 parent 9725f72 commit c4a668c
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 40 deletions.
16 changes: 8 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ workflows:
default:
jobs:
- ios-build-test
- spm

step-library:
- &prepare
run:
name: Prepare
command: |
if [ $(carthage outdated | grep -cF "latest Carthage version") -eq 0 ]; then brew update && brew upgrade carthage; fi
- &install-dependencies
run:
name: Install Dependencies
Expand Down Expand Up @@ -46,14 +41,19 @@ step-library:
jobs:
ios-build-test:
macos:
xcode: "10.1.0"
xcode: "10.2.1"
environment:
HOMEBREW_NO_AUTO_UPDATE: 0
steps:
- checkout
- *prepare
- *install-dependencies
- *ios-build-test
- *macos-build-test
- *tvos-build-test
- *watchos-build
spm:
macos:
xcode: "10.2.1"
steps:
- checkout
- run: swift build
58 changes: 26 additions & 32 deletions MapboxSpeech.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@
C54F53681F6C758C00BFCC66 /* MBSpeechOptions.swift */,
C54F53501F6C754D00BFCC66 /* Info.plist */,
);
path = MapboxSpeech;
name = MapboxSpeech;
path = Sources/MapboxSpeech;
sourceTree = "<group>";
};
C54F53591F6C754D00BFCC66 /* MapboxSpeechTests */ = {
Expand All @@ -178,7 +179,8 @@
C54F535A1F6C754D00BFCC66 /* MapboxVoiceTests.swift */,
C54F535C1F6C754D00BFCC66 /* Info.plist */,
);
path = MapboxSpeechTests;
name = MapboxSpeechTests;
path = Tests/MapboxSpeechTests;
sourceTree = "<group>";
};
C5569E671FD9E97300D9B7AC /* Frameworks */ = {
Expand All @@ -196,7 +198,8 @@
children = (
C5569E6C1FD9EEE100D9B7AC /* hello.mp3 */,
);
path = fixtures;
name = fixtures;
path = ../fixtures;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand Down Expand Up @@ -385,10 +388,12 @@
};
DAE3527222420CE900A3FF9C = {
CreatedOnToolsVersion = 10.1;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
DAE3527A22420CEA00A3FF9C = {
CreatedOnToolsVersion = 10.1;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
DAE35295224213ED00A3FF9C = {
Expand All @@ -407,10 +412,11 @@
};
buildConfigurationList = C54F53461F6C754D00BFCC66 /* Build configuration list for PBXProject "MapboxSpeech" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = C54F53421F6C754D00BFCC66;
productRefGroup = C54F534D1F6C754D00BFCC66 /* Products */;
Expand Down Expand Up @@ -623,6 +629,7 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -679,6 +686,7 @@
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -696,15 +704,14 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 5;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = MapboxSpeech/Info.plist;
INFOPLIST_FILE = Sources/MapboxSpeech/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxSpeech;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -718,14 +725,13 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 5;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = MapboxSpeech/Info.plist;
INFOPLIST_FILE = Sources/MapboxSpeech/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxSpeech;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -740,13 +746,12 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
INFOPLIST_FILE = MapboxSpeechTests/Info.plist;
INFOPLIST_FILE = Tests/MapboxSpeechTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks $(PROJECT_DIR)/Carthage/Build/iOS @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.Mapbox.MapboxSpeechTests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -761,13 +766,12 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
INFOPLIST_FILE = MapboxSpeechTests/Info.plist;
INFOPLIST_FILE = Tests/MapboxSpeechTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks $(PROJECT_DIR)/Carthage/Build/iOS @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.Mapbox.MapboxSpeechTests;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -788,7 +792,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MapboxSpeech/Info.plist;
INFOPLIST_FILE = Sources/MapboxSpeech/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
Expand All @@ -797,7 +801,6 @@
PRODUCT_NAME = MapboxSpeech;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -818,15 +821,14 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MapboxSpeech/Info.plist;
INFOPLIST_FILE = Sources/MapboxSpeech/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxSpeech;
PRODUCT_NAME = MapboxSpeech;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -846,14 +848,13 @@
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MapboxSpeechTests/Info.plist;
INFOPLIST_FILE = Tests/MapboxSpeechTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(PROJECT_DIR)/Carthage/Build/Mac";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxSpeechTests;
PRODUCT_NAME = MapboxSpeechTests;
SDKROOT = macosx;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -873,13 +874,12 @@
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MapboxSpeechTests/Info.plist;
INFOPLIST_FILE = Tests/MapboxSpeechTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks $(PROJECT_DIR)/Carthage/Build/Mac";
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxSpeechTests;
PRODUCT_NAME = MapboxSpeechTests;
SDKROOT = macosx;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -897,7 +897,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MapboxSpeech/Info.plist;
INFOPLIST_FILE = Sources/MapboxSpeech/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
Expand All @@ -906,7 +906,6 @@
PRODUCT_NAME = MapboxSpeech;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand All @@ -926,15 +925,14 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MapboxSpeech/Info.plist;
INFOPLIST_FILE = Sources/MapboxSpeech/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxSpeech;
PRODUCT_NAME = MapboxSpeech;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand All @@ -953,14 +951,13 @@
"$(PROJECT_DIR)/Carthage/Build/tvOS",
);
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MapboxSpeechTests/Info.plist;
INFOPLIST_FILE = Tests/MapboxSpeechTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(PROJECT_DIR)/Carthage/Build/tvOS";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxSpeechTests;
PRODUCT_NAME = MapboxSpeechTests;
SDKROOT = appletvos;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand All @@ -979,13 +976,12 @@
"$(PROJECT_DIR)/Carthage/Build/tvOS",
);
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MapboxSpeechTests/Info.plist;
INFOPLIST_FILE = Tests/MapboxSpeechTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(PROJECT_DIR)/Carthage/Build/tvOS";
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxSpeechTests;
PRODUCT_NAME = MapboxSpeechTests;
SDKROOT = appletvos;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand All @@ -1006,7 +1002,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MapboxSpeech/Info.plist;
INFOPLIST_FILE = Sources/MapboxSpeech/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
Expand All @@ -1015,7 +1011,6 @@
PRODUCT_NAME = MapboxSpeech;
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
Expand All @@ -1036,15 +1031,14 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MapboxSpeech/Info.plist;
INFOPLIST_FILE = Sources/MapboxSpeech/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxSpeech;
PRODUCT_NAME = MapboxSpeech;
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
Expand Down
32 changes: 32 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "MapboxSpeech",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "MapboxSpeech",
targets: ["MapboxSpeech"]),
.executable(
name: "MapboxSpeechCLI",
targets: ["MapboxSpeechCLI"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "MapboxSpeech",
dependencies: []),
.testTarget(
name: "MapboxSpeechTests",
dependencies: ["MapboxSpeech"]),
.target(name: "MapboxSpeechCLI", dependencies: ["MapboxSpeech"])
]
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions Sources/MapboxSpeechCLI/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Foundation
import MapboxSpeech
import AVFoundation


guard CommandLine.arguments.count >= 2 else {
print("Nothing to say?")
exit(0)
}

guard let token = ProcessInfo.processInfo.environment["MAPBOX_ACCESS_TOKEN"] else {
print("MAPBOX_ACCESS_TOKEN not found")
exit(0)
}

let text = CommandLine.arguments[1]
let options = SpeechOptions(text: text)
var speech = SpeechSynthesizer(accessToken: token)

let url = speech.url(forSynthesizing: options)
print("URL: \(url)")
let data = try! Data(contentsOf: url)
print("Data: \(data)")
let player = try! AVAudioPlayer(data: data)
player.play()
RunLoop.main.run(until: Date().addingTimeInterval(player.duration))

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c4a668c

Please sign in to comment.