Skip to content

Commit

Permalink
Add Swift Example
Browse files Browse the repository at this point in the history
  • Loading branch information
ianyanzhang committed Feb 12, 2023
1 parent 2deb61c commit 716005a
Show file tree
Hide file tree
Showing 17 changed files with 1,058 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Swift-Call-OC-Example/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'SwiftCallOC' do
# Comment the next line if you don't want to use dynamic frameworks
# Pods for TXLiteAVDemo_Professional
pod 'TXLiteAVSDK_Player', '~> 10.9.13161'
end

679 changes: 679 additions & 0 deletions Swift-Call-OC-Example/SwiftCallOC.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

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

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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
36 changes: 36 additions & 0 deletions Swift-Call-OC-Example/SwiftCallOC/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// AppDelegate.swift
// SwiftCallOC
//
// Copyright (c) 2022 Tencent. All rights reserved.
//

import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
24 changes: 24 additions & 0 deletions Swift-Call-OC-Example/SwiftCallOC/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
25 changes: 25 additions & 0 deletions Swift-Call-OC-Example/SwiftCallOC/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
52 changes: 52 additions & 0 deletions Swift-Call-OC-Example/SwiftCallOC/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// SceneDelegate.swift
// SwiftCallOC
//
// Copyright (c) 2022 Tencent. All rights reserved.
//

import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?


func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
}

func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}

func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}

func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}

func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}

func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}


}

13 changes: 13 additions & 0 deletions Swift-Call-OC-Example/SwiftCallOC/SwiftCallOC-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// SwiftCallOC-Bridging-Header.h.h
// SwiftCallOC
//
// Copyright (c) 2022 Tencent. All rights reserved.
//

#ifndef SwiftCallOC_Bridging_Header_h_h
#define SwiftCallOC_Bridging_Header_h_h

#import <TXLiteAVSDK_Player/TXLiteAVSDK.h>

#endif /* SwiftCallOC_Bridging_Header_h_h */
41 changes: 41 additions & 0 deletions Swift-Call-OC-Example/SwiftCallOC/ViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// ViewController.swift
// SwiftCallOC
//
// Copyright (c) 2022 Tencent. All rights reserved.
//

import UIKit
import TXLiteAVSDK_Player

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

// 方式一:使用桥接头文件
// a.创建桥接头文件,例如 ‘***-Bridging-Header.h’,并添加如下代码 ‘#import <TXLiteAVSDK_Player/TXLiteAVSDK.h>’

// b.配置工程 'BuildSetting' 的 'Objective-c Bridging header' 选项。设置桥接文件的路径添加到Objective-c Bridging header中,编译运行即可。
// 如:$(SRCROOT)/SwiftCallOC/***-Bridging-Header.h

let vodPlayer : TXVodPlayer = TXVodPlayer()
vodPlayer.setMute(true)

let vodPlayerConfig : TXVodPlayConfig = TXVodPlayConfig()
vodPlayerConfig.playerType = 1
vodPlayer.config = vodPlayerConfig

// 方式二:使用SDK内的 module.modulemap 文件
// a.检查 ‘TXLiteAVSDK_Player.framework’里是否有包含 ‘Modules - module.modulemap’ 文件

// b.配置工程 'BuildSetting' 的 'Swift Compiler - Search Paths' 选项。添加 ‘module.modulemap’ 文件所在的目录路径或其上层目录路径,此处可为:
// ${PODS_ROOT}/TXLiteAVSDK_Player/TXLiteAVSDK_Player/TXLiteAVSDK_Player.framework/Modules

// c.在需要调用的类顶部,使用 ‘import TXLiteAVSDK_Player’ 来进行引入并调用相关的方法
}



}

36 changes: 36 additions & 0 deletions Swift-Call-OC-Example/SwiftCallOCTests/SwiftCallOCTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// SwiftCallOCTests.swift
// SwiftCallOCTests
//
// Copyright (c) 2022 Tencent. All rights reserved.
//

import XCTest
@testable import SwiftCallOC

final class SwiftCallOCTests: 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.
// Any test you write for XCTest can be annotated as throws and async.
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
}

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.
}
}

}
41 changes: 41 additions & 0 deletions Swift-Call-OC-Example/SwiftCallOCUITests/SwiftCallOCUITests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// SwiftCallOCUITests.swift
// SwiftCallOCUITests
//
// Copyright (c) 2022 Tencent. All rights reserved.
//

import XCTest

final class SwiftCallOCUITests: XCTestCase {

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

// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false

// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}

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 {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()

// Use XCTAssert and related functions to verify your tests produce the correct results.
}

func testLaunchPerformance() throws {
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// SwiftCallOCUITestsLaunchTests.swift
// SwiftCallOCUITests
//
// Copyright (c) 2022 Tencent. All rights reserved.
//

import XCTest

final class SwiftCallOCUITestsLaunchTests: XCTestCase {

override class var runsForEachTargetApplicationUIConfiguration: Bool {
true
}

override func setUpWithError() throws {
continueAfterFailure = false
}

func testLaunch() throws {
let app = XCUIApplication()
app.launch()

// Insert steps here to perform after app launch but before taking a screenshot,
// such as logging into a test account or navigating somewhere in the app

let attachment = XCTAttachment(screenshot: app.screenshot())
attachment.name = "Launch Screen"
attachment.lifetime = .keepAlways
add(attachment)
}
}

0 comments on commit 716005a

Please sign in to comment.