• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

ForEach “implicitly-synthesized declarations” Error in Swift Tik Tok clone :(


New Coder
These errors

"Cannot declare entity named '$reel'; the '$' prefix is reserved for implicitly-synthesized declarations"

"Generic struct 'ForEach' requires that 'Binding<[Reel]>' conform to 'RandomAccessCollection'"

Both errors are on this ForEach

ForEach($reels) { $reel in

          ReelsPlayer(reel: $reel)

Is this because my videos are a custom type, and therefore swift is not able to ID them which is giving me the 'RandomAccessCollection' error?

I have a TabView {} and am trying to make each page a new video similar to tik tok or vine. It works when I pass in dummy data but when I pass from my array of videos I get those errors.

The View:

import SwiftUI

import AVKit

struct ReelsView: View {

  @State var currentReel = ""

  // extracting AVPlayer from media file

  @State var reels: [Reel] = MediaFileJSON.map { item -> Reel in   

    let url = Bundle.main.path(forResource: item.url, ofType: "MP4") ?? ""   

    let player = AVPlayer(url: URL(fileURLWithPath: url))

    return Reel(player: player, mediaFile: item)


  var body: some View {

    // setting width and height for rotated view

    GeometryReader { proxy in

      let size = proxy.size

      // vertical page tab view

      TabView(selection: $currentReel) {

        ForEach($reels) { $reel in // **ERRORS HERE**

          ReelsPlayer(reel: $reel)

          // setting width

          .frame(width: size.width)


          // rotate content

          .rotationEffect(.init(degrees: -90))



      // Rotate View

      .rotationEffect(.init(degrees: 90))

      // setting height as width

      .frame(width: size.height)

      .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))

      // setting max width

      .frame(width: size.width)




struct ReelsView_Previews: PreviewProvider {

  static var previews: some View {




struct ReelsPlayer: View, Identifiable {

  var id: ObjectIdentifier

  @Binding var reel: Reel

  var body: some View {

    ZStack {




MediaFile struct:

struct MediaFile: Identifiable {

  var id = UUID().uuidString

  var url: String

  var title: String

  var isExpanded: Bool = false


var MediaFileJSON = [

  MediaFile(url: "Reel1", title: "Apple AirTag......."),

  MediaFile(url: "Reel2", title: "this is the second."),

  MediaFile(url: "Reel3", title: "the third"),

  MediaFile(url: "Reel4", title: "wooooooooooooo ya"),

  MediaFile(url: "Reel5", title: "ay ayayayayay ayay lsdfk sl"),

  MediaFile(url: "Reel6", title: "this is the last one....."),


Reel struct:

struct Reel: Identifiable {

  var id: String = UUID().uuidString

  var player: AVPlayer?

  var mediaFile: MediaFile

Top Bottom