Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mamba 2.0 SPM Support #146

Merged
merged 4 commits into from
Nov 13, 2024
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
71 changes: 71 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
//
// Package.swift
// mamba
//
// Copyright © 2020 Comcast Cable Communications Management, LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import PackageDescription

let package = Package(
name: "mamba",
products: [
.library(
name: "mamba",
targets: ["mamba"]
)
],
targets: [
.target(
name: "mamba",
dependencies: [.target(name: "HLSObjectiveC")],
path: "mambaSharedFramework",
exclude: [
"HLS ObjectiveC",
"PlaylistParserError",
"mamba.h"
],
resources: [
.process("Resources")
]
),
.target(
name: "PlaylistParserError",
path: "mambaSharedFramework/PlaylistParserError"
),
.target(
name: "HLSObjectiveC",
dependencies: ["PlaylistParserError"],
path: "mambaSharedFramework/HLS ObjectiveC",
exclude: [
"PrototypeRapidParseArray.include",
"RapidParser_LookingForEForEXTINFState_ParseArray.include",
"RapidParser_LookingForEForEXTState_ParseArray.include",
"RapidParser_LookingForHashForEXTINFState_ParseArray.include",
"RapidParser_LookingForHashForEXTState_ParseArray.include",
"RapidParser_LookingForIForEXTINFState_ParseArray.include",
"RapidParser_LookingForNewlineForEXTINFState_ParseArray.include",
"RapidParser_LookingForNewLineForEXTState_ParseArray.include",
"RapidParser_LookingForNewLineForHashState_ParseArray.include",
"RapidParser_LookingForNForEXTINFState_ParseArray.include",
"RapidParser_LookingForTForEXTINFState_ParseArray.include",
"RapidParser_LookingForXForEXTINFState_ParseArray.include",
"RapidParser_LookingForXForEXTState_ParseArray.include",
"RapidParser_ScanningState_ParseArray.include",
]
)
]
)
686 changes: 386 additions & 300 deletions mamba.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion mambaSharedFramework/FrameworkInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,22 @@ public enum FrameworkInfo {
/// returns the version of the mamba framework
public static var version: String {

/// When exporting a framework on SPM, there is no way to access the info dictionary, so the version should be provided differently
#if SWIFT_PACKAGE
guard let versionFilePathUrl = Bundle.module.url(forResource: "version", withExtension: "txt"),
let version = try? String(contentsOf: versionFilePathUrl, encoding: .utf8)
.trimmingCharacters(in: .whitespacesAndNewlines)
else {
assertionFailure("Unable to find version string in framework bundle")
return "Error: Unable to find version string in framework bundle"
}
#else
let bundle = Bundle(for: PlaylistParser.self)

guard let version = bundle.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String else {
assertionFailure("Unable to find version string in framework bundle")
return "Error: Unable to find version string in framework bundle"
}
#endif

return version
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// limitations under the License.
//

#import <mamba/mamba.h>
#import "MambaStringRef.h"

@interface MambaStringRefFactory : MambaStringRef

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// limitations under the License.
//

#import <mamba/mamba.h>
#import "MambaStringRef.h"

@interface MambaStringRef_ConcreteNSData : MambaStringRef

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// limitations under the License.
//

#import <mamba/mamba.h>
#import "MambaStringRef.h"

@interface MambaStringRef_ConcreteNSString : MambaStringRef

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// limitations under the License.
//

#import <mamba/mamba.h>
#import "MambaStringRef.h"

@interface MambaStringRef_ConcreteUnownedBytes : MambaStringRef

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
//

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

const uint32_t RapidParserErrorMissingTagData = PlaylistParserInternalErrorCodeMissingTagData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import Foundation

#if SWIFT_PACKAGE
import HLSObjectiveC
#endif

public extension MambaStringRef {

convenience init(descriptor: PlaylistTagDescriptor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// limitations under the License.
//

#if SWIFT_PACKAGE
import PlaylistParserError
#endif

import Foundation

/// 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//

import Foundation
import CoreMedia

// Specialized validator for EXTINF tags
class EXTINFValidator: PlaylistTagValidator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import Foundation

#if SWIFT_PACKAGE
import HLSObjectiveC
#endif

/**
enum describing all playlist tags that mamba understands from the Pantos HLS specification

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//

import Foundation
import CoreMedia

/**
`VariantPlaylist` is a struct that represents a variant-style HLS playlist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
//

import Foundation
import CoreMedia


public protocol PlaylistSegmentMatcher {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
//

import Foundation
import CoreMedia


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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//

import Foundation
import CoreMedia

/**
This protocol defines a minimal interface of a object that represents HLS playlist structure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
//

import Foundation
import CoreMedia

#if SWIFT_PACKAGE
import HLSObjectiveC
#endif

/**
This object is responsible for maintaining a HLS playlist structure, including a array of tags and
Expand Down
5 changes: 4 additions & 1 deletion mambaSharedFramework/Playlist Models/PlaylistCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
//

import Foundation

import CoreMedia

#if SWIFT_PACKAGE
import HLSObjectiveC
#endif

/**
A structure representing a HLS playlist in easy to edit form.

Expand Down
5 changes: 5 additions & 0 deletions mambaSharedFramework/Playlist Models/PlaylistTag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
//

import Foundation
import CoreMedia

#if SWIFT_PACKAGE
import HLSObjectiveC
#endif

/**
A struct representing a single tag line from a HLS playlist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
//

import Foundation
import QuartzCore

#if SWIFT_PACKAGE
import HLSObjectiveC
#endif

/// Specialized custom data modifier for VariantPlaylist and MasterPlaylist
public struct PlaylistURLData {
Expand Down
6 changes: 6 additions & 0 deletions mambaSharedFramework/PlaylistParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
//

import Foundation
import QuartzCore

#if SWIFT_PACKAGE
import PlaylistParserError
import HLSObjectiveC
#endif

/**
A performant parser for HLS playlists.
Expand Down
4 changes: 4 additions & 0 deletions mambaSharedFramework/PlaylistTagDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// limitations under the License.
//

#if SWIFT_PACKAGE
import HLSObjectiveC
#endif

import Foundation

/// Protocol that describes the behavior of a playlist tag descriptor.
Expand Down
1 change: 1 addition & 0 deletions mambaSharedFramework/Resources/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.3.0
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
//

import Foundation
import CoreMedia

#if SWIFT_PACKAGE
import HLSObjectiveC
#endif

/// A protocol for objects that can be constructed from a string, but might fail.
public protocol FailableStringLiteralConvertible {
Expand Down
4 changes: 4 additions & 0 deletions mambaSharedFramework/Utils/OutputStream+HLSWriting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import Foundation

#if SWIFT_PACKAGE
import HLSObjectiveC
#endif

public enum OutputStreamError: Error {
case couldNotWriteToStream(NSError?)
case invalidData(description: String?)
Expand Down
4 changes: 4 additions & 0 deletions mambaSharedFramework/Utils/RegisteredPlaylistTags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import Foundation

#if SWIFT_PACKAGE
import HLSObjectiveC
#endif

/**
This struct is the mechanism to register and deregister arbitrary PlaylistTagDescriptor and
PlaylistTagValueIdentifier objects to support arbitrary playlist tag types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

import Foundation

#if SWIFT_PACKAGE
import HLSObjectiveC
#endif


extension String {

public init(tagDescriptor: PlaylistTagDescriptor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// limitations under the License.
//

#if SWIFT_PACKAGE
import PlaylistParserError
#endif

import Foundation

struct GenericDictionaryTagParserHelper {
Expand Down
11 changes: 5 additions & 6 deletions mambaSharedFramework/mamba.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ FOUNDATION_EXPORT double mambaVersionNumber;
FOUNDATION_EXPORT const unsigned char mambaVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <mamba/PublicHeader.h>

#import <mamba/MambaStringRef.h>
#import <mamba/RapidParser.h>
#import <mamba/RapidParserCallback.h>
#import <mamba/CMTimeMakeFromString.h>
#import <mamba/StaticMemoryStorage.h>
#import "MambaStringRef.h"
#import "RapidParser.h"
#import "RapidParserCallback.h"
#import "CMTimeMakeFromString.h"
#import "StaticMemoryStorage.h"