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

Add Support for the Swift Package Manager #215

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.DS_Store
*/build/*
build/*
*/.build/*
.build/*
*.pbxuser
!default.pbxuser
*.mode1v3
Expand Down
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:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "YouTubePlayer",
platforms: [.iOS(.v13)],
products: [
.library(name: "YouTubePlayer",
targets: ["YouTubePlayer"])
],
dependencies: [],
targets: [
.target(
name: "YouTubePlayer",
dependencies: [],
path: "YouTubePlayer/YouTubePlayer",
exclude: ["Info.plist"],
resources: [
.process("YTPlayer.html")
]
),
.testTarget(
name: "YouTubePlayerTests",
dependencies: ["YouTubePlayer"],
path: "YouTubePlayer/Tests/YouTubePlayerTests"
)
]
)
3 changes: 3 additions & 0 deletions YouTubePlayer.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions YouTubePlayer/Tests/YouTubePlayerTests/YouTubePlayerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// YouTubePlayerTests.swift
// YouTubePlayer
//
// Created by Marcel on 04.03.21.
// Copyright © 2021 Giles Van Gruisen. All rights reserved.
//

import XCTest

class YouTubePlayerTests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}

func testPerformanceExample() throws {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}

}
20 changes: 20 additions & 0 deletions YouTubePlayer/YouTubePlayer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
/* Begin PBXBuildFile section */
50E5B9C91A4CAA050099BF69 /* YTPlayer.html in Resources */ = {isa = PBXBuildFile; fileRef = 50E5B9C81A4CAA050099BF69 /* YTPlayer.html */; };
50E5B9CB1A4CAA150099BF69 /* YouTubePlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E5B9CA1A4CAA150099BF69 /* YouTubePlayer.swift */; };
E616AC7A25F0BBC200AAE4E2 /* YouTubePlayerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E616AC7925F0BBC200AAE4E2 /* YouTubePlayerTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
502AE85F1A475FD500306AD1 /* YouTubePlayer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = YouTubePlayer.framework; sourceTree = BUILT_PRODUCTS_DIR; };
502AE8631A475FD500306AD1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; name = Info.plist; path = YouTubePlayer/Info.plist; sourceTree = "<group>"; };
50E5B9C81A4CAA050099BF69 /* YTPlayer.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = YTPlayer.html; path = YouTubePlayer/YTPlayer.html; sourceTree = SOURCE_ROOT; };
50E5B9CA1A4CAA150099BF69 /* YouTubePlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YouTubePlayer.swift; path = YouTubePlayer/YouTubePlayer.swift; sourceTree = SOURCE_ROOT; };
E616AC7925F0BBC200AAE4E2 /* YouTubePlayerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YouTubePlayerTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -32,6 +34,7 @@
502AE8551A475FD500306AD1 = {
isa = PBXGroup;
children = (
E616AC7725F0BB8800AAE4E2 /* Tests */,
502AE8611A475FD500306AD1 /* YouTubePlayer */,
502AE8601A475FD500306AD1 /* Products */,
);
Expand Down Expand Up @@ -64,6 +67,22 @@
name = "Supporting Files";
sourceTree = "<group>";
};
E616AC7725F0BB8800AAE4E2 /* Tests */ = {
isa = PBXGroup;
children = (
E616AC7825F0BB9600AAE4E2 /* YouTubePlayerTests */,
);
path = Tests;
sourceTree = "<group>";
};
E616AC7825F0BB9600AAE4E2 /* YouTubePlayerTests */ = {
isa = PBXGroup;
children = (
E616AC7925F0BBC200AAE4E2 /* YouTubePlayerTests.swift */,
);
path = YouTubePlayerTests;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -145,6 +164,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E616AC7A25F0BBC200AAE4E2 /* YouTubePlayerTests.swift in Sources */,
50E5B9CB1A4CAA150099BF69 /* YouTubePlayer.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
4 changes: 3 additions & 1 deletion YouTubePlayer/YouTubePlayer/YouTubePlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright (c) 2014 Giles Van Gruisen. All rights reserved.
//

#if canImport(UIKit)
import UIKit
import WebKit

Expand Down Expand Up @@ -252,7 +253,7 @@ open class YouTubePlayerView: UIView, WKNavigationDelegate {
}

fileprivate func playerHTMLPath() -> String {
return Bundle(for: YouTubePlayerView.self).path(forResource: "YTPlayer", ofType: "html")!
return Bundle.module.path(forResource: "YTPlayer", ofType: "html")!
}

fileprivate func htmlStringWithFilePath(_ path: String) -> String? {
Expand Down Expand Up @@ -376,3 +377,4 @@ private func printLog(_ strings: CustomStringConvertible...) {
let toPrint = ["[YouTubePlayer]"] + strings
print(toPrint, separator: " ", terminator: "\n")
}
#endif