AgoraIO / Basic-Video-Broadcasting

Sample app to join/leave a channel, set the role as a host/audience, mute/unmute, switch between front/rear cameras, and set the video parameters.
MIT License
269 stars 287 forks source link

iOS: Unable to start video broadcast #134

Open sashabaranov opened 3 years ago

sashabaranov commented 3 years ago

Hey guys,

I was following this tutorial and could not start a local video preview / broadcast.

The problem spot seem to be in:

let vidCode = agoraKit.enableVideo()
print("Video enable code: \(vidCode)")

It returns code -7 which as docs suggest indicates an error.

I've also tried to build your example from here and it also does not start. Not even a request for my camera. See screenshot attached.

photo_2021-02-18 18 39 00

plutoless commented 3 years ago

@sashabaranov -7 means sdk is not yet initialized. have you put in the appid and token field as instructed in the readme?

hvsw commented 2 years ago

An error code can be a negative number. In such a case, it should be read as if it were positive. For example, if the SDK returns error code -2, you should refer to 2 in the error code table.

7 A method is called before the initialization of RtcEngine. Ensure that the RtcEngine instance is created and initialized before calling the method.

https://docs.agora.io/en/Interactive%20Broadcast/error_rtc?platform=iOS#warning-codes


I was using .xcframeworks and what was missing was the Agoraffmpeg.xcframework.

Interestingly, when using .xcframework the app would run just fine but fail “silently” with just this misleading -7 error code, while with .framework the app would crash on launch with a helpful message:

dyld: Library not loaded: @rpath/Agoraffmpeg.framework/Agoraffmpeg
  Referenced from: /private/var/containers/Bundle/Application/D3D2D968-ED95-4557-ABA5-F9D418B8131A/MyApp.app/Frameworks/AgoraRtcKit.framework/AgoraRtcKit
  Reason: image not found

Not sure if there’s something Agora can do on their side about this, but would be nice to have some informative troubleshooting message when there’s a missing .xcframework.