Open wolfmanwoking opened 7 years ago
Just update the files with the new Code ? or there other things we have to do ?
I copied modification of @wolfmanwoking , plus I've added the package.json to be Cordova 7 compliant (to fix the plugin add error) in my fork: https://github.com/De-Lac/phonertc
It's not perfect, but I think I'm on the right way. The project doesn't compile with ionic cordova build ios
, but it successfully compiles in Xcode.
I am currently using it with success.
$ ionic info
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2
global packages:
Cordova CLI : 7.0.1
Gulp CLI : CLI version 3.9.1 Local version 3.9.1
local packages:
Cordova Platforms : browser 4.1.0 ios 4.4.0
Ionic Framework : ionic1 1.3.3
System:
ios-deploy : 1.9.1
ios-sim : 5.0.8
Node : v8.1.3
npm : 5.3.0
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
@De-Lac @wolfmanwoking Getting Use of unresolved identifier 'SJProgressHUD'
in the PhoneRTCPlugin.swift file and yes SJProgressHUD.swift is in the src/ios folder of the plugin file.
Have at least 5 errors when running ionic cordova build ios
:
[ERROR] An error occurred while running cordova build ios (exit code 1):
(truncated) ... SecureChat -emit-module-path
/Users/shakes/Library/Developer/Xcode/DerivedData/SecureChat-awsdbeqrzpuuapgkwxmvennmqvlo/Build/Intermediates/SecureChat.build/Debug-iphonesimulator/SecureChat.build/Objects-normal/x86_64/SessionDescriptionDelegate~partial.swiftmodule
-emit-dependencies-path
/Users/shakes/Library/Developer/Xcode/DerivedData/SecureChat-awsdbeqrzpuuapgkwxmvennmqvlo/Build/Intermediates/SecureChat.build/Debug-iphonesimulator/SecureChat.build/Objects-normal/x86_64/SessionDescriptionDelegate.d
-emit-reference-dependencies-path
/Users/shakes/Library/Developer/Xcode/DerivedData/SecureChat-awsdbeqrzpuuapgkwxmvennmqvlo/Build/Intermediates/SecureChat.build/Debug-iphonesimulator/SecureChat.build/Objects-normal/x86_64/SessionDescriptionDelegate.swiftdeps
-o
/Users/shakes/Library/Developer/Xcode/DerivedData/SecureChat-awsdbeqrzpuuapgkwxmvennmqvlo/Build/Intermediates/SecureChat.build/Debug-iphonesimulator/SecureChat.build/Objects-normal/x86_64/SessionDescriptionDelegate.o
/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/SecureChat/Plugins/com.dooble.phonertc/SessionDescriptionDelegate.swift:3:49:
error: use of undeclared type 'RTCSessionDescriptionDelegate'
class SessionDescriptionDelegate : UIResponder,
RTCSessionDescriptionDelegate {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/SecureChat/Plugins/com.dooble.phonertc/SessionDescriptionDelegate.swift:10:39:
error: use of undeclared type 'RTCPeerConnection'
func peerConnection(_ peerConnection: RTCPeerConnection!,
^~~~~~~~~~~~~~~~~
/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/SecureChat/Plugins/com.dooble.phonertc/SessionDescriptionDelegate.swift:11:46:
error: use of undeclared type 'RTCSessionDescription'
didCreateSessionDescription originalSdp: RTCSessionDescription!,
error: Error!) {
^~~~~~~~~~~~~~~~~~~~~
/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/SecureChat/Plugins/com.dooble.phonertc/SessionDescriptionDelegate.swift:47:39:
error: use of undeclared type 'RTCPeerConnection'
func peerConnection(_ peerConnection: RTCPeerConnection!,
^~~~~~~~~~~~~~~~~
/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/SecureChat/Plugins/com.dooble.phonertc/PCObserver.swift:3:30:
error: use of undeclared type 'RTCPeerConnectionDelegate'
class PCObserver : NSObject, RTCPeerConnectionDelegate {
^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/SecureChat/Plugins/com.dooble.phonertc/SessionDescriptionDelegate.swift:17:15:
error: use of unresolved identifier 'RTCSessionDescription'
let sdp = RTCSessionDescription(
^~~~~~~~~~~~~~~~~~~~~
/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/SecureChat/Plugins/com.dooble.phonertc/Session.swift:7:21:
error: use of undeclared type 'RTCPeerConnection'
var peerConnection: RTCPeerConnection!
^~~~~~~~~~~~~~~~~
/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/SecureChat/Plugins/com.dooble.phonertc/Session.swift:6:18:
error: use of undeclared type 'RTCMediaConstraints'
var constraints: RTCMediaConstraints
^~~~~~~~~~~~~~~~~~~
/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/SecureChat/Plugins/com.dooble.phonertc/Session.swift:9:30:
error: use of undeclared type 'RTCICECandidate'
var queuedRemoteCandidates: [RTCICECandidate]?
^~~~~~~~~~~~~~~
** BUILD FAILED **
The following build commands failed:
CompileSwift normal x86_64
/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/SecureChat/Plugins/com.dooble.phonertc/PhoneRTCPlugin.swift
CompileSwift normal x86_64
/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/SecureChat/Plugins/com.dooble.phonertc/PCObserver.swift
CompileSwift normal x86_64
/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/SecureChat/Plugins/com.dooble.phonertc/Session.swift
CompileSwift normal x86_64
/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/SecureChat/Plugins/com.dooble.phonertc/SessionDescriptionDelegate.swift
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(5 failures)
Error: Error code 65 for command: xcodebuild with args:
-xcconfig,/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/cordova/build-debug.xcconfig,-workspace,SecureChat.xcworkspace,-scheme,SecureChat,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS
Simulator,name=iPhone
SE,build,CONFIGURATION_BUILD_DIR=/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/shakes/Desktop/Awork/s-c/securechat/platforms/ios/build/sharedpch
System info:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2
global packages:
Cordova CLI : 7.0.1
local packages:
Cordova Platforms : android 6.2.3 ios 4.4.0
Ionic Framework : ionic1 1.3.2
System:
ios-deploy : 1.9.1
ios-sim : 5.0.8
Node : v6.10.2
npm : 3.10.10
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
add that file manually in the Xcode project. Open Xcode, open the project, find where are the other files .swift, right-click, add-file and manually paste the code. I don't know why it's missing during the installation
And a few more errors:
我已经将 Config 、 PCObserver 、PhoneRTCPlugin、Session、SessionDescriptionDelegate、SJProgressHUD 等 swift 文件升级到 swift 3.0 了。请更新您的文件,以便项目在未来做好升级。
谢谢您的观看。
Config.swift
import Foundation
struct TurnConfig { var host: String var username: String var password: String
}
struct StreamsConfig { var audio: Bool var video: Bool
}
class SessionConfig { var isInitiator: Bool var turn: TurnConfig var streams: StreamsConfig
}
class VideoConfig { var container: VideoLayoutParams var local: VideoLayoutParams?
}
class VideoLayoutParams { var x, y, width, height: Int
}
PCObserver.swift
import Foundation
class PCObserver : NSObject, RTCPeerConnectionDelegate { var session: Session
}
PhoneRTCPlugin.swift
import Foundation import AVFoundation import AudioToolbox
@objc(PhoneRTCPlugin) class PhoneRTCPlugin : CDVPlugin ,UIAlertViewDelegate{ var sessions: [String: Session]! var peerConnectionFactory: RTCPeerConnectionFactory!
}
struct VideoTrackViewPair { var videoView: RTCEAGLVideoView var videoTrack: RTCVideoTrack }
Session.swift
import Foundation
class Session { var plugin: PhoneRTCPlugin var config: SessionConfig var constraints: RTCMediaConstraints var peerConnection: RTCPeerConnection! var pcObserver: PCObserver! var queuedRemoteCandidates: [RTCICECandidate]? var peerConnectionFactory: RTCPeerConnectionFactory var callbackId: String var stream: RTCMediaStream? var videoTrack: RTCVideoTrack? var sessionKey: String
}
SessionDescriptionDelegate.swift
import Foundation
class SessionDescriptionDelegate : UIResponder, RTCSessionDescriptionDelegate { var session: Session
}
SJProgressHUD.swift
// // SJProgressHUD.swift // SJProgressHUD // // Created by king on 16/4/10. // Copyright © 2016年 king. All rights reserved. //
import UIKit
enum ShowType { case success case error case info }
extension SJProgressHUD {
}
private let circleSize = CGSize(width: 40, height: 40) private let windowBgColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.002) private func bgColor(_ alpha: CGFloat) -> UIColor { return UIColor(red: 0, green: 0, blue: 0, alpha: alpha) }
class SJProgressHUD : NSObject {
// window.transform = CGAffineTransform(rotationAngle: CGFloat(angle M_PI / 180)) window.transform = CGAffineTransform(rotationAngle: CGFloat(angle .pi / 180)) window.isHidden = false window.center = getCenter() window.addSubview(view) windows.append(window) return window } @objc static fileprivate func removeHUD(_ object: AnyObject) { if let window = object as? UIWindow { if let index = windows.index(where: { (item) -> Bool in return item == window }) { windows.remove(at: index) } } } static fileprivate func clear() { if windows.isEmpty { return } self.cancelPreviousPerformRequests(withTarget: self) windows.removeAll(keepingCapacity: false) } static func getCenter() -> CGPoint { let view = UIApplication.shared.keyWindow?.subviews.first as UIView! if UIApplication.shared.statusBarOrientation.hashValue >= 3 { return CGPoint(x: view!.center.y, y: view!.center.x) } else { return view!.center } } }
class drawImage {
// path.addArc(withCenter: CGPoint(x: 20, y: 20), radius: 19, startAngle: 0, endAngle: CGFloat(M_PI2), clockwise: true) path.addArc(withCenter: CGPoint(x: 20, y: 20), radius: 19, startAngle: 0, endAngle: CGFloat( Double.pi 2 ), clockwise: true)
// tmpPath.addArc(withCenter: CGPoint(x: 20, y: 30), radius: 1, startAngle: 0, endAngle: CGFloat(M_PI2), clockwise: true) tmpPath.addArc(withCenter: CGPoint(x: 20, y: 30), radius: 1, startAngle: 0, endAngle: CGFloat( Double.pi2), clockwise: true)
}