Skip to content

Commit 263f3c7

Browse files
authored
Merge pull request #146 from Comcast/add-spm-support
Mamba 2.0 SPM Support
2 parents 7f7870c + 6de0a80 commit 263f3c7

File tree

69 files changed

+554
-315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+554
-315
lines changed

Package.swift

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// swift-tools-version:5.3
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
//
4+
// Package.swift
5+
// mamba
6+
//
7+
// Copyright © 2020 Comcast Cable Communications Management, LLC
8+
// Licensed under the Apache License, Version 2.0 (the "License");
9+
// you may not use this file except in compliance with the License.
10+
// You may obtain a copy of the License at
11+
//
12+
// http://www.apache.org/licenses/LICENSE-2.0
13+
//
14+
// Unless required by applicable law or agreed to in writing, software
15+
// distributed under the License is distributed on an "AS IS" BASIS,
16+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
// See the License for the specific language governing permissions and
18+
// limitations under the License.
19+
//
20+
21+
import PackageDescription
22+
23+
let package = Package(
24+
name: "mamba",
25+
products: [
26+
.library(
27+
name: "mamba",
28+
targets: ["mamba"]
29+
)
30+
],
31+
targets: [
32+
.target(
33+
name: "mamba",
34+
dependencies: [.target(name: "HLSObjectiveC")],
35+
path: "mambaSharedFramework",
36+
exclude: [
37+
"HLS ObjectiveC",
38+
"PlaylistParserError",
39+
"mamba.h"
40+
],
41+
resources: [
42+
.process("Resources")
43+
]
44+
),
45+
.target(
46+
name: "PlaylistParserError",
47+
path: "mambaSharedFramework/PlaylistParserError"
48+
),
49+
.target(
50+
name: "HLSObjectiveC",
51+
dependencies: ["PlaylistParserError"],
52+
path: "mambaSharedFramework/HLS ObjectiveC",
53+
exclude: [
54+
"PrototypeRapidParseArray.include",
55+
"RapidParser_LookingForEForEXTINFState_ParseArray.include",
56+
"RapidParser_LookingForEForEXTState_ParseArray.include",
57+
"RapidParser_LookingForHashForEXTINFState_ParseArray.include",
58+
"RapidParser_LookingForHashForEXTState_ParseArray.include",
59+
"RapidParser_LookingForIForEXTINFState_ParseArray.include",
60+
"RapidParser_LookingForNewlineForEXTINFState_ParseArray.include",
61+
"RapidParser_LookingForNewLineForEXTState_ParseArray.include",
62+
"RapidParser_LookingForNewLineForHashState_ParseArray.include",
63+
"RapidParser_LookingForNForEXTINFState_ParseArray.include",
64+
"RapidParser_LookingForTForEXTINFState_ParseArray.include",
65+
"RapidParser_LookingForXForEXTINFState_ParseArray.include",
66+
"RapidParser_LookingForXForEXTState_ParseArray.include",
67+
"RapidParser_ScanningState_ParseArray.include",
68+
]
69+
)
70+
]
71+
)

mamba.xcodeproj/project.pbxproj

+386-300
Large diffs are not rendered by default.

mambaSharedFramework/FrameworkInfo.swift

+11-1
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,22 @@ public enum FrameworkInfo {
2525
/// returns the version of the mamba framework
2626
public static var version: String {
2727

28+
/// When exporting a framework on SPM, there is no way to access the info dictionary, so the version should be provided differently
29+
#if SWIFT_PACKAGE
30+
guard let versionFilePathUrl = Bundle.module.url(forResource: "version", withExtension: "txt"),
31+
let version = try? String(contentsOf: versionFilePathUrl, encoding: .utf8)
32+
.trimmingCharacters(in: .whitespacesAndNewlines)
33+
else {
34+
assertionFailure("Unable to find version string in framework bundle")
35+
return "Error: Unable to find version string in framework bundle"
36+
}
37+
#else
2838
let bundle = Bundle(for: PlaylistParser.self)
29-
3039
guard let version = bundle.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String else {
3140
assertionFailure("Unable to find version string in framework bundle")
3241
return "Error: Unable to find version string in framework bundle"
3342
}
43+
#endif
3444

3545
return version
3646
}

mambaSharedFramework/Rapid Parser/MambaStringRef/MambaStringRefFactory.h mambaSharedFramework/HLS ObjectiveC/MambaStringRefFactory.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// limitations under the License.
1818
//
1919

20-
#import <mamba/mamba.h>
20+
#import "MambaStringRef.h"
2121

2222
@interface MambaStringRefFactory : MambaStringRef
2323

mambaSharedFramework/Rapid Parser/MambaStringRef/MambaStringRef_ConcreteNSData.h mambaSharedFramework/HLS ObjectiveC/MambaStringRef_ConcreteNSData.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// limitations under the License.
1818
//
1919

20-
#import <mamba/mamba.h>
20+
#import "MambaStringRef.h"
2121

2222
@interface MambaStringRef_ConcreteNSData : MambaStringRef
2323

mambaSharedFramework/Rapid Parser/MambaStringRef/MambaStringRef_ConcreteNSString.h mambaSharedFramework/HLS ObjectiveC/MambaStringRef_ConcreteNSString.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// limitations under the License.
1818
//
1919

20-
#import <mamba/mamba.h>
20+
#import "MambaStringRef.h"
2121

2222
@interface MambaStringRef_ConcreteNSString : MambaStringRef
2323

mambaSharedFramework/Rapid Parser/MambaStringRef/MambaStringRef_ConcreteUnownedBytes.h mambaSharedFramework/HLS ObjectiveC/MambaStringRef_ConcreteUnownedBytes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// limitations under the License.
1818
//
1919

20-
#import <mamba/mamba.h>
20+
#import "MambaStringRef.h"
2121

2222
@interface MambaStringRef_ConcreteUnownedBytes : MambaStringRef
2323

mambaSharedFramework/Rapid Parser/RapidParserError.m mambaSharedFramework/HLS ObjectiveC/RapidParserError.m

+6-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818
//
1919

2020
#include "RapidParserError.h"
21-
#if __has_include("mamba-Swift.h")
22-
#import "mamba-Swift.h"
21+
// Module mamba-Swift is not available in Swift Package Manager.
22+
// In order to import 'HLSParserError.swift' a new module in Package.swift was created.
23+
// This is needed to access HLSParserInternalErrorCode enum.
24+
#if SWIFT_PACKAGE
25+
@import PlaylistParserError;
2326
#else
24-
#import <mamba/mamba-Swift.h>
27+
#import <mamba/mamba-Swift.h>
2528
#endif
2629

2730
const uint32_t RapidParserErrorMissingTagData = PlaylistParserInternalErrorCodeMissingTagData;

mambaSharedFramework/Rapid Parser/MambaStringRef/MambaStringRef.swift mambaSharedFramework/MambaStringRef+Extensions.swift

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
import Foundation
2121

22+
#if SWIFT_PACKAGE
23+
import HLSObjectiveC
24+
#endif
25+
2226
public extension MambaStringRef {
2327

2428
convenience init(descriptor: PlaylistTagDescriptor) {

mambaSharedFramework/Pantos-Generic Playlist Parsing/Pantos-Generic Tag Parsers/GenericSingleValueTagParser.swift

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
// limitations under the License.
1818
//
1919

20+
#if SWIFT_PACKAGE
21+
import PlaylistParserError
22+
#endif
23+
2024
import Foundation
2125

2226
/// Class for generically parsing tags in the form of `#EXT-X-TARGETDURATION:10`, where there is a tag with a one and only one value associated with it

mambaSharedFramework/Pantos-Generic Playlist Parsing/Pantos-Generic Tag Validators/EXTINFValidator.swift

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//
1919

2020
import Foundation
21+
import CoreMedia
2122

2223
// Specialized validator for EXTINF tags
2324
class EXTINFValidator: PlaylistTagValidator {

mambaSharedFramework/Pantos-Generic Playlist Parsing/PantosTag.swift

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
import Foundation
2121

22+
#if SWIFT_PACKAGE
23+
import HLSObjectiveC
24+
#endif
25+
2226
/**
2327
enum describing all playlist tags that mamba understands from the Pantos HLS specification
2428

mambaSharedFramework/Playlist Models/Playlist Concrete Types/VariantPlaylist.swift

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//
1919

2020
import Foundation
21+
import CoreMedia
2122

2223
/**
2324
`VariantPlaylist` is a struct that represents a variant-style HLS playlist.

mambaSharedFramework/Playlist Models/Playlist Concrete Types/VariantPlaylistTagMatchSegmentInfo.swift

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
//
1919

2020
import Foundation
21+
import CoreMedia
22+
2123

2224
public protocol PlaylistSegmentMatcher {
2325
/**

mambaSharedFramework/Playlist Models/Playlist Structure/PlaylistStructureCore.swift

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
//
1919

2020
import Foundation
21+
import CoreMedia
22+
2123

2224
public final class PlaylistStructureCore<PSD: PlaylistStructureDelegate>: PlaylistStructureInterface {
2325

mambaSharedFramework/Playlist Models/Playlist Structure/PlaylistStructureInterface.swift

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//
1919

2020
import Foundation
21+
import CoreMedia
2122

2223
/**
2324
This protocol defines a minimal interface of a object that represents HLS playlist structure.

mambaSharedFramework/Playlist Models/Playlist Structure/VariantPlaylistStructure.swift

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
//
1919

2020
import Foundation
21+
import CoreMedia
22+
23+
#if SWIFT_PACKAGE
24+
import HLSObjectiveC
25+
#endif
2126

2227
/**
2328
This object is responsible for maintaining a HLS playlist structure, including a array of tags and

mambaSharedFramework/Playlist Models/PlaylistCore.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
//
1919

2020
import Foundation
21-
2221
import CoreMedia
2322

23+
#if SWIFT_PACKAGE
24+
import HLSObjectiveC
25+
#endif
26+
2427
/**
2528
A structure representing a HLS playlist in easy to edit form.
2629

mambaSharedFramework/Playlist Models/PlaylistTag.swift

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
//
1919

2020
import Foundation
21+
import CoreMedia
22+
23+
#if SWIFT_PACKAGE
24+
import HLSObjectiveC
25+
#endif
2126

2227
/**
2328
A struct representing a single tag line from a HLS playlist.

mambaSharedFramework/Playlist Models/PlaylistURLDataExtensions.swift

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
//
1919

2020
import Foundation
21+
import QuartzCore
22+
23+
#if SWIFT_PACKAGE
24+
import HLSObjectiveC
25+
#endif
2126

2227
/// Specialized custom data modifier for VariantPlaylist and MasterPlaylist
2328
public struct PlaylistURLData {

mambaSharedFramework/PlaylistParser.swift

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
//
1919

2020
import Foundation
21+
import QuartzCore
22+
23+
#if SWIFT_PACKAGE
24+
import PlaylistParserError
25+
import HLSObjectiveC
26+
#endif
2127

2228
/**
2329
A performant parser for HLS playlists.

mambaSharedFramework/PlaylistTagDescriptor.swift

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
// limitations under the License.
1818
//
1919

20+
#if SWIFT_PACKAGE
21+
import HLSObjectiveC
22+
#endif
23+
2024
import Foundation
2125

2226
/// Protocol that describes the behavior of a playlist tag descriptor.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.3.0

mambaSharedFramework/Utils/FailableStringLiteralConvertible.swift

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
//
1919

2020
import Foundation
21+
import CoreMedia
22+
23+
#if SWIFT_PACKAGE
24+
import HLSObjectiveC
25+
#endif
2126

2227
/// A protocol for objects that can be constructed from a string, but might fail.
2328
public protocol FailableStringLiteralConvertible {

mambaSharedFramework/Utils/OutputStream+HLSWriting.swift

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
import Foundation
2121

22+
#if SWIFT_PACKAGE
23+
import HLSObjectiveC
24+
#endif
25+
2226
public enum OutputStreamError: Error {
2327
case couldNotWriteToStream(NSError?)
2428
case invalidData(description: String?)

mambaSharedFramework/Utils/RegisteredPlaylistTags.swift

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
import Foundation
2121

22+
#if SWIFT_PACKAGE
23+
import HLSObjectiveC
24+
#endif
25+
2226
/**
2327
This struct is the mechanism to register and deregister arbitrary PlaylistTagDescriptor and
2428
PlaylistTagValueIdentifier objects to support arbitrary playlist tag types.

mambaSharedFramework/Utils/String Util/String+EquatableMambaTypes.swift

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919

2020
import Foundation
2121

22+
#if SWIFT_PACKAGE
23+
import HLSObjectiveC
24+
#endif
25+
26+
2227
extension String {
2328

2429
public init(tagDescriptor: PlaylistTagDescriptor) {

mambaSharedFramework/Utils/Tag Parser Helpers/GenericDictionaryTagParserHelper.swift

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
// limitations under the License.
1818
//
1919

20+
#if SWIFT_PACKAGE
21+
import PlaylistParserError
22+
#endif
23+
2024
import Foundation
2125

2226
struct GenericDictionaryTagParserHelper {

mambaSharedFramework/mamba.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ FOUNDATION_EXPORT double mambaVersionNumber;
3232
FOUNDATION_EXPORT const unsigned char mambaVersionString[];
3333

3434
// In this header, you should import all the public headers of your framework using statements like #import <mamba/PublicHeader.h>
35-
36-
#import <mamba/MambaStringRef.h>
37-
#import <mamba/RapidParser.h>
38-
#import <mamba/RapidParserCallback.h>
39-
#import <mamba/CMTimeMakeFromString.h>
40-
#import <mamba/StaticMemoryStorage.h>
35+
#import "MambaStringRef.h"
36+
#import "RapidParser.h"
37+
#import "RapidParserCallback.h"
38+
#import "CMTimeMakeFromString.h"
39+
#import "StaticMemoryStorage.h"

0 commit comments

Comments
 (0)