ISBX / apprtc-ios

A native iOS video chat app based on WebRTC
BSD 3-Clause "New" or "Revised" License
1.34k stars 411 forks source link

Can i able to use WebRTC in Swift Project ? #39

Open indrajitsinh opened 8 years ago

indrajitsinh commented 8 years ago

i am new to IOS development and i just recently learned swift programming language and i am not familiar with objective C

i know there is a feature called bridging header that allows you to use objective c code in Swift project but as i am new hop someone suggest me what should i do ?

Thank you

Xioshock commented 8 years ago

I haven't tried this this project yet, but if you are targeting iOS 8+ and have updated CocoaPods, you don't need bridging header. Just type use_frameworks! at the top of your Podfile. It will create a framework from this library and you can then import it in your swift file, same as UIKit is imported

SeanChenU commented 8 years ago

I am using pod 0.39.0 and encountering this issue when pod install The 'Pods-XXX-iOS' target has transitive dependencies that include static binaries: (/Users/User/XXX-ios/Pods/libjingle_peerconnection/libjingle_peerconnection/libWebRTC.a)

coolwr commented 8 years ago

Yes, the project should work inside your Swift Project. However, because of the static library dependency you'll need to manually integrate into your project or create a framework per @Xioshock

The transitive dependency error seems to e an issue with the recent version of cocoa pods. We'll need to investigate this further to find a resolution.

SeanChenU commented 8 years ago

Here are my steps to integrate APPRTC into my project manually:

  1. Remove: pod 'APPRTC' and add them: pod 'libjingle_peerconnection' pod 'SocketRocket' in Podfile
  2. Copy from Lib/ folder from APPRTC project into my project
  3. Add these frameworks and libraries into project: "QuartzCore", "OpenGLES", "CoreGraphics", "CoreVideo", "CoreMedia", "CoreAudio", "AVFoundation", "AudioToolbox", "GLKit", "CFNetwork", "Security", "sqlite3", "stdc++.6", "icucore", "c++"
  4. Add related headers in my case #import <libjingle_peerconnection/RTCEAGLVideoView.h> #import "ARDAppClient.h" #import "RTCPeerConnectionFactory.h" into Bridging-Header.h
  5. Build!
coolwr commented 8 years ago

Awesome. Thanks for posting the instructions! Would be great if someone could help investigate how to fix the transitive dependency error in cocoa pods so the integration would be easier.

cmorell commented 8 years ago

Hi! yes I also did the same like @SeanChenU but I really like how to add appRTC pod or how to create ones in order to has AppRTC client as a Pod and be usefull using swift project. Can anyone did it before?

I think I am closer (or not) but I get this error:

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_RTCSessionDescription", referenced from:
      objc-class-ref in ARDSignalingMessage.o
      objc-class-ref in RTCSessionDescription+JSON.o
      l_OBJC_$_CATEGORY_RTCSessionDescription_$_JSON in RTCSessionDescription+JSON.o
  "_OBJC_CLASS_$_RTCICECandidate", referenced from:
      objc-class-ref in ARDSignalingMessage.o
      objc-class-ref in RTCICECandidate+JSON.o
      l_OBJC_$_CATEGORY_RTCICECandidate_$_JSON in RTCICECandidate+JSON.o
  "_OBJC_CLASS_$_RTCPair", referenced from:
      objc-class-ref in ARDAppClient.o
      objc-class-ref in RTCMediaConstraints+JSON.o
  "_OBJC_CLASS_$_RTCMediaConstraints", referenced from:
      objc-class-ref in ARDAppClient.o
      objc-class-ref in RTCMediaConstraints+JSON.o
      l_OBJC_$_CATEGORY_RTCMediaConstraints_$_JSON in RTCMediaConstraints+JSON.o
  "_OBJC_CLASS_$_RTCVideoCapturer", referenced from:
      objc-class-ref in ARDAppClient.o
  "_OBJC_CLASS_$_RTCICEServer", referenced from:
      objc-class-ref in ARDAppClient.o
      objc-class-ref in RTCICEServer+JSON.o
      l_OBJC_$_CATEGORY_RTCICEServer_$_JSON in RTCICEServer+JSON.o
  "_OBJC_CLASS_$_RTCPeerConnectionFactory", referenced from:
      objc-class-ref in ARDAppClient.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
saiteja7 commented 8 years ago

what is the meanning of 2nd step @SeanChenU

cmorell commented 8 years ago

@saiteja7 the meaning of 2nd step in @SeanChenU comment is that we need to copy in our project the classes that contains AppRTC/Lib folder:

ARDAppClient.(h/m) ARDMessageResponse.(h/m) ARDRegisterResponse.(h/m) ARDSignalingMessage.(h/m) ARDUtilities.(h/m) ARDWebSocketChannel.(h/m) RTCICECandidate+JSON.(h/m) RTCICEServer+JSON.(h/m) RTCMediaConstraints.(h/m) RTCSessionDescription.(h/m)

saiteja7 commented 8 years ago

okay thanq

On 18 August 2016 at 15:00, cmorell notifications@github.com wrote:

@saiteja7 https://github.com/saiteja7 the meaning of 2nd step in @SeanChenU https://github.com/SeanChenU comment is that we need to copy in our project the classes that contains AppRTC/Lib folder:

ARDAppClient.(h/m) ARDMessageResponse.(h/m) ARDRegisterResponse.(h/m) ARDSignalingMessage.(h/m) ARDUtilities.(h/m) ARDWebSocketChannel.(h/m) RTCICECandidate+JSON.(h/m) RTCICEServer+JSON.(h/m) RTCMediaConstraints.(h/m) RTCSessionDescription.(h/m)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ISBX/apprtc-ios/issues/39#issuecomment-240671687, or mute the thread https://github.com/notifications/unsubscribe-auth/ATr_kL_hnRPp_GZXESw5ZGsd_BHfb4jiks5qhCYbgaJpZM4Iv2iT .

sonysum commented 7 years ago

Hi, @SeanChenU i follow your solution but i can not call renderFrame, Ex: [self.localView renderFrame:nil]; // error class has no men=mber 'renderFrame' any solution?

Carlos77 commented 6 years ago

I have the same problem can i have more informations for how to solve this issues

WorkSpace/Test2/platforms/ios/Test2/Plugins/com.onsip.cordova/libwebrtc_base.a Undefined symbols for architecture arm64: "_OBJCCLASS$_RTCEAGLVideoView", referenced from: objc-class-ref in PhoneRTCPlugin.o "_OBJCCLASS$_RTCICEServer", referenced from: objc-class-ref in PhoneRTCPlugin.o "_OBJCCLASS$_RTCICECandidate", referenced from: objc-class-ref in PhoneRTCDelegate.o "_OBJCCLASS$_RTCMediaConstraints", referenced from: objc-class-ref in PhoneRTCDelegate.o "_OBJCCLASS$_RTCPair", referenced from: objc-class-ref in PhoneRTCDelegate.o "_OBJCCLASS$_RTCVideoCapturer", referenced from: objc-class-ref in PhoneRTCDelegate.o "_OBJCCLASS$_RTCSessionDescription", referenced from: objc-class-ref in PhoneRTCDelegate.o "_OBJCCLASS$_RTCPeerConnectionFactory", referenced from: objc-class-ref in PhoneRTCDelegate.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)