#StackBounty: #ios #xcode #macos #flutter #google-cloud-firestore 'FirebaseCore/FirebaseCore.h' file not found while building f…

Bounty: 50

I am able to run the app in Debug mode in XCODE and simulator without any errors. But when I build for Release Mode the build fails with below 2 errors:

  1. ‘FirebaseCore/FirebaseCore.h’ file not found
  2. Could not build Objective-C module ‘Firebase’

I have been trying different solutions available on Stackoverflow and gitHub over last 10 days but know seems to be working, below are the details.

FLUTTER DOCTOR :

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.17.3, on Mac OS X 10.15.3 19D76, locale en-IN)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 4.0)
[✓] Connected device (2 available)

• No issues found!

POD FILE :

# Uncomment this line to define a global platform for your project
platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def parse_KV_file(file, separator='=')
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  generated_key_values = {}
  skip_line_start_symbols = ["#", "/"]
  File.foreach(file_abs_path) do |line|
    next if skip_line_start_symbols.any? { |symbol| line =~ /^s*#{symbol}/ }
    plugin = line.split(pattern=separator)
    if plugin.length == 2
      podname = plugin[0].strip()
      path = plugin[1].strip()
      podpath = File.expand_path("#{path}", file_abs_path)
      generated_key_values[podname] = podpath
    else
      puts "Invalid plugin specification: #{line}"
    end
  end
  generated_key_values
end

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  # Flutter Pod

  copied_flutter_dir = File.join(__dir__, 'Flutter')
  copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
  copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
  unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
    # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
    # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
    # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.

    generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
    unless File.exist?(generated_xcode_build_settings_path)
      raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
    end
    generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
    cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];

    unless File.exist?(copied_framework_path)
      FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
    end
    unless File.exist?(copied_podspec_path)
      FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
    end
  end

  # Keep pod path relative so it can be checked into Podfile.lock.
  pod 'Flutter', :path => 'Flutter'

  # Plugin Pods

  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.each do |name, path|
    symlink = File.join('.symlinks', 'plugins', name)
    File.symlink(path, symlink)
    pod name, :path => File.join(symlink, 'ios')
  end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

AppDelegate.swift (file) :

import UIKit
import Flutter
import Firebase

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {

    override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
  FirebaseApp.configure()
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

Firebase.h file (Path: Pods>Pods>Firebase>CoreOnly>Firebase.h) :

// Copyright 2019 Google
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#import <FirebaseCore/FirebaseCore.h>

#if !defined(__has_include)
  #error "Firebase.h won't import anything if your compiler doesn't support __has_include. Please 
          import the headers individually."
#else
  #if __has_include(<FirebaseAnalytics/FirebaseAnalytics.h>)
    #import <FirebaseAnalytics/FirebaseAnalytics.h>
  #endif

  #if __has_include(<FirebaseAuth/FirebaseAuth.h>)
    #import <FirebaseAuth/FirebaseAuth.h>
  #endif

  #if __has_include(<FirebaseCrashlytics/FirebaseCrashlytics.h>)
    #import <FirebaseCrashlytics/FirebaseCrashlytics.h>
  #endif

  #if __has_include(<FirebaseDatabase/FirebaseDatabase.h>)
    #import <FirebaseDatabase/FirebaseDatabase.h>
  #endif

  #if __has_include(<FirebaseDynamicLinks/FirebaseDynamicLinks.h>)
    #import <FirebaseDynamicLinks/FirebaseDynamicLinks.h>
    #if !__has_include(<FirebaseAnalytics/FirebaseAnalytics.h>)
      #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
        #warning "FirebaseAnalytics.framework is not included in your target. Please add 
`Firebase/Analytics` to your Podfile or add FirebaseAnalytics.framework to your project to ensure 
Firebase Dynamic Links works as intended."
      #endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
    #endif
  #endif

  #if __has_include(<FirebaseFirestore/FirebaseFirestore.h>)
    #import <FirebaseFirestore/FirebaseFirestore.h>
  #endif

  #if __has_include(<FirebaseFunctions/FirebaseFunctions.h>)
    #import <FirebaseFunctions/FirebaseFunctions.h>
  #endif

  #if __has_include(<FirebaseInAppMessaging/FirebaseInAppMessaging.h>)
    #import <FirebaseInAppMessaging/FirebaseInAppMessaging.h>
    #if !__has_include(<FirebaseAnalytics/FirebaseAnalytics.h>)
      #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
        #warning "FirebaseAnalytics.framework is not included in your target. Please add 
`Firebase/Analytics` to your Podfile or add FirebaseAnalytics.framework to your project to ensure 
Firebase In App Messaging works as intended."
      #endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
    #endif
  #endif

  #if __has_include(<FirebaseInstanceID/FirebaseInstanceID.h>)
    #import <FirebaseInstanceID/FirebaseInstanceID.h>
  #endif

  #if __has_include(<FirebaseMessaging/FirebaseMessaging.h>)
    #import <FirebaseMessaging/FirebaseMessaging.h>
      #if !__has_include(<FirebaseAnalytics/FirebaseAnalytics.h>)
      #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
        #warning "FirebaseAnalytics.framework is not included in your target. Please add 
`Firebase/Analytics` to your Podfile or add FirebaseAnalytics.framework to your project to ensure 
Firebase Messaging works as intended."
      #endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
    #endif
#endif

  #if __has_include(<FirebaseMLCommon/FirebaseMLCommon.h>)
    #import <FirebaseMLCommon/FirebaseMLCommon.h>
  #endif

  #if __has_include(<FirebaseMLModelInterpreter/FirebaseMLModelInterpreter.h>)
    #import <FirebaseMLModelInterpreter/FirebaseMLModelInterpreter.h>
  #endif

  #if __has_include(<FirebaseMLNLLanguageID/FirebaseMLNLLanguageID.h>)
    #import <FirebaseMLNLLanguageID/FirebaseMLNLLanguageID.h>
  #endif

  #if __has_include(<FirebaseMLNLSmartReply/FirebaseMLNLSmartReply.h>)
    #import <FirebaseMLNLSmartReply/FirebaseMLNLSmartReply.h>
  #endif

  #if __has_include(<FirebaseMLNLTranslate/FirebaseMLNLTranslate.h>)
    #import <FirebaseMLNLTranslate/FirebaseMLNLTranslate.h>
  #endif

  #if __has_include(<FirebaseMLNaturalLanguage/FirebaseMLNaturalLanguage.h>)
    #import <FirebaseMLNaturalLanguage/FirebaseMLNaturalLanguage.h>
  #endif

  #if __has_include(<FirebaseMLVision/FirebaseMLVision.h>)
    #import <FirebaseMLVision/FirebaseMLVision.h>
  #endif

  #if __has_include(<FirebaseMLVisionAutoML/FirebaseMLVisionAutoML.h>)
    #import <FirebaseMLVisionAutoML/FirebaseMLVisionAutoML.h>
  #endif

  #if __has_include(<FirebaseMLVisionBarcodeModel/FirebaseMLVisionBarcodeModel.h>)
    #import <FirebaseMLVisionBarcodeModel/FirebaseMLVisionBarcodeModel.h>
  #endif

  #if __has_include(<FirebaseMLVisionFaceModel/FirebaseMLVisionFaceModel.h>)
    #import <FirebaseMLVisionFaceModel/FirebaseMLVisionFaceModel.h>
  #endif

  #if __has_include(<FirebaseMLVisionLabelModel/FirebaseMLVisionLabelModel.h>)
    #import <FirebaseMLVisionLabelModel/FirebaseMLVisionLabelModel.h>
  #endif

  #if __has_include(<FirebaseMLVisionObjectDetection/FirebaseMLVisionObjectDetection.h>)
    #import <FirebaseMLVisionObjectDetection/FirebaseMLVisionObjectDetection.h>
  #endif

  #if __has_include(<FirebaseMLVisionTextModel/FirebaseMLVisionTextModel.h>)
    #import <FirebaseMLVisionTextModel/FirebaseMLVisionTextModel.h>
  #endif

  #if __has_include(<FirebasePerformance/FirebasePerformance.h>)
    #import <FirebasePerformance/FirebasePerformance.h>
    #if !__has_include(<FirebaseAnalytics/FirebaseAnalytics.h>)
      #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
        #warning "FirebaseAnalytics.framework is not included in your target. Please add 
`Firebase/Analytics` to your Podfile or add FirebaseAnalytics.framework to your project to ensure 
Firebase Performance works as intended."
      #endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
    #endif
  #endif

  #if __has_include(<FirebaseRemoteConfig/FirebaseRemoteConfig.h>)
    #import <FirebaseRemoteConfig/FirebaseRemoteConfig.h>
    #if !__has_include(<FirebaseAnalytics/FirebaseAnalytics.h>)
      #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
        #warning "FirebaseAnalytics.framework is not included in your target. Please add 
`Firebase/Analytics` to your Podfile or add FirebaseAnalytics.framework to your project to ensure 
Firebase Remote Config works as intended."
      #endif // #ifndef FIREBASE_ANALYTICS_SUPPRESS_WARNING
    #endif
  #endif

  #if __has_include(<FirebaseStorage/FirebaseStorage.h>)
    #import <FirebaseStorage/FirebaseStorage.h>
  #endif

  #if __has_include(<GoogleMobileAds/GoogleMobileAds.h>)
    #import <GoogleMobileAds/GoogleMobileAds.h>
  #endif

  #if __has_include(<Fabric/Fabric.h>)
    #import <Fabric/Fabric.h>
  #endif

  #if __has_include(<Crashlytics/Crashlytics.h>)
    #import <Crashlytics/Crashlytics.h>
  #endif

#endif  // defined(__has_include)

Firebase.h error

Firebase.h error

Could not build Objective-C module ‘Firebase’

Could not build Objective-C module 'Firebase'


Get this bounty!!!

#StackBounty: #ios #swift #xcode #audio #audio-recording How to record audio with a certain threshold filter in swift

Bounty: 50

enter image description here

I need to add this functionality in one of my app in swift, I want the user to adjust the threshold and so it’ll be only recorded when it crosses the limit set by the user and stop automatically or in a given time when the user stops.

It would be great if you can share your expertise in how to collect all the data in one file like when a user will pause and continue it’ll keep all the audio in one file.

I actually have no idea about this and will truly appreciate any kind of feedback.

Thanks.


Get this bounty!!!

#StackBounty: #ios #swift #xcode #segue Manual (automatic) Segue not working – table view cell

Bounty: 400

I’m new to Xcode and I’m following the tutorial here which goes through how to add a manual segue.

https://github.com/AdditionAddict/learnXcode

Problem: When clicking on a table cell in the simulator the manual segue is not triggered.

What I’ve tried: I’ve added a manual (automatic) segue, an identifier, and whilst the tutorial says as this point a selection of a cell with result in going from the table view cell to the meal detail scene, I’ve continued to the code part and my breakpoint in prepare still does not trigger.

    // MARK: - Navigation

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        super.prepare(for: segue, sender: sender)
        
        switch(segue.identifier ?? "") {
            
        case "AddItem":
            os_log("Adding a new meal", log: OSLog.default, type: .debug)
            
        case "ShowDetail":
            // set the meal for the `MealViewController` as the meal selected in the `MealTableViewController`
            os_log("Show detail of a meal", log: OSLog.default, type: .debug)
            
            guard let mealDetailViewController = segue.destination as? MealViewController else {
                fatalError("Unexpected destination, (segue.destination)")
            }
            guard let selectedMealCell = sender as? MealTableViewCell else {
                fatalError("Unexpected sender, (String(describing: sender))")
            }
            guard let indexPath = tableView.indexPath(for: selectedMealCell) else {
                fatalError("The selected cell is not being displayed by the table")
            }
            
            let selectedMeal = meals[indexPath.row]
            mealDetailViewController.meal = selectedMeal
            
        default:
            fatalError("Unexpected Segue Identifier")
        }
    }

Checks made:
If, for the purposes of debugging only, I put the following in my MealTableViewController.swift with a breakpoint nothing happens when I click a table cell:

    override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
        return true
    }

This makes me think the table cells aren’t registering a ‘selection’.

Table View Selection property is Single Selection.

The custom MealTableViewCell has User Interaction Enabled checked.

Clicking the MealTableViewCell in the outline pane and selecting the Connections inspector in the utilities pane also shows the segue:

Connections Inspector showing segue

Final bits: Is it still possible to add a manual (automatic) segue?
Tutorial is in archive and I’ve managed to follow most of it with small changes.
Using Xcode 11.6

main.storyboard and Identity Inspector

Edit(s) / answers to comment questions:

  1. added (automatic) to manual. I mean the method the tutorial uses from table cell to meal detail.
  2. There isn’t anything in front of the table (that I’m aware of) such as a tap gesture recogniser
  3. The Plus segue works and triggers the prepare unlike clicking a table cell


Get this bounty!!!

#StackBounty: #xcode #macos #nstableview #appkit NSTableView selected row flickering while scrolling with arrow keys

Bounty: 200

I have a view based NSTableView and can’t figure out how to work around a visual glitch where the currently selected row flickers while scrolling up or down with the arrow keys.

The selected row should appear ‘glued’ to either the top or bottom of the view, depending on scroll direction. The Finder shows this correct behavior in list view but a regular table view seems to not behave this way out of the box. I’m confused as to why that is and see no obvious way to circumvent it. Can anybody point me to possible causes / solutions?

Edit No. 1

A cell based NSTableView behaves in the desired way by default, so this is presumably a bug specific to the view based implementation. I don’t want to use a cell based table for unrelated reasons though.

Edit No. 2

I’ve tried making the table view’s parent view layer backed, as well as intercepting the up / down arrow keystrokes to do my own scrolling, but so far I haven’t been able to eliminate the flickering.

Edit No. 3

I’ve created a small sample project that reproduces the issue.


Get this bounty!!!

#StackBounty: #c++ #ios #xcode #static-libraries Undefined symbols for architecture arm64 after linking a static library in iOS app

Bounty: 50

I am creating a sample static library to be used in my iOS app, however, when calling the static library’s methods, I ran into a linker error:

Undefined symbols for architecture arm64:
"_doMath", referenced from:
  _doMathInterface in libTestMain.a(Test.o)
 (maybe you meant: _doMathInterface)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Here is the static library’s structure:

I have a header file Test.h:

#import <Foundation/Foundation.h>

@interface Test : NSObject

int doMathInterface(int a, int b);

@end

and its implementation Test.m :

#import "Test.h"
#include "PaymentAPI.h"

@implementation Test

int doMathInterface(int a, int b){
    return doMath(a, b);
}

@end

and in PaymentAPI.h:

#ifndef PaymentAPI_h
#define PaymentAPI_h

int doMath(int a, int b);

#endif /* PaymentAPI_h */

Finally in PaymentAPI.cpp:

#include <stdio.h>
#include "PaymentAPI.h"

int doMath(int a, int b){
    return a + b;
}

As you can see it’s a very simple static library but I couldn’t figure out why this linker error is happening, I have added the static library in the "Link Binaries with Libraries" in Build Phases in the app.

Here is a screenshot of the app‘s files:

enter image description here

and search paths configuration in build settings is also correct, I believe:

enter image description here

Here is a screenshot of some build settings for the static library project

Build Phases:
enter image description here

Architecture:
enter image description here

Thanks a lot.


Get this bounty!!!

#StackBounty: #xcode #flutter impossible to build flutter on device or simulator in my mac

Bounty: 200

after two week… I successed upload xcode and catalina OS , zsh … all could be good but have always error and can’t launch my app on my physical device or simulator. Always error after Xcode build.

Things interesting, I remove App_review package from pubspec.yaml but I have always error with it…
If I launch flutter example it works, but If I use certain package like admob who worked before, or app review I have this errors. I can remove app_review package but remove ad mob no…

Edit: I remove all packages who show error, but have always this error
Here is my physical device error :

Xcode's output:
↳
   
    ld: framework not found FBLPromises
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    note: Using new build system
    note: Building targets in parallel

    note: Planning build
    note: Constructing build description

Here is the error when I use simulator :

Xcode's output:
↳
    ld: framework not found FBLPromises
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
    warning: Mapping architecture armv7 to i386. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'in_app_purchase' from project 'Pods')
    warning: Mapping architecture arm64 to x86_64. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'in_app_purchase' from project 'Pods')
    warning: Mapping architecture arm64 to x86_64. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'Runner' from project 'Runner')
    warning: Mapping architecture armv7s to i386. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'Runner' from project 'Runner')
    warning: Mapping architecture armv7 to i386. Ensure that this target's Architectures and Valid Architectures build settings are configured correctly for the iOS Simulator platform. (in target 'Runner' from project 'Runner')


Get this bounty!!!

#StackBounty: #ios #swift #xcode #uitableview #uicollectionview Passing information from a collection view to a tableview

Bounty: 50

Right now I have a table view that is an extension of a collection view.

Here is a picture of the storyboard.
enter image description here

The main premise of the app is similar to Apple Maps. I would like for a collectionView cell to be selected and then for the viewController to display a tableView that has all of the respected items from that category.

Here is my code for the collectionView.

 class ContentViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {

let imageArray = [UIImage(named: "image 1"), UIImage(named: "image 2"), UIImage(named: "image 3")]

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return imageArray.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CustomCell", for: indexPath) as! CustomCell
    cell.mapIconImage.image = imageArray[indexPath.row]
    cell.mapIconLabel.text! = imageNameArray[indexPath.row]
    return cell
}

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
    performSegue(withIdentifier: "ShowTableViewPlaces", sender: self)
}

class CustomCell: UICollectionViewCell {

@IBOutlet weak var mapIconImage: UIImageView!
@IBOutlet weak var mapIconLabel: UILabel!

}

Here is the code so far for the tableView.

import UIKit

struct PlacesInTableView {
var name: String

init(name: String) {
    self.name = name
}
}

class MapItemsTableViewController: UITableViewController {

var image1InTableView = [PlacesInTableView(name: "place 1"),
    PlacesInTableView(name: "place 2"),
    PlacesInTableView(name: "place 3")
]

var image2InTableView = [PlacesInTableView(name: "place 1")
]

var image3InTableView = [PlacesInTableView(name: "place 1"),
    PlacesInTableView(name: "place 2")
]

When a collection view is selected, I would like all of the locations in that respected category to occupy the contents of the tableview. How would I go about passing data from the collection view cell to a new tableView?


Get this bounty!!!

#StackBounty: #ios #swift #xcode #swiftui #swift5 SwiftUI List not updating inside pull to refresh view

Bounty: 100

I have a List inside a Custom Pull to refresh view. When the array inside SeeAllViewModel is updated, this list in the view is not being updated. Not only that but the counter is not being updated also. When I put the list outside this CustomScrollView it updates just fine. So i’m guessing there is something wrong with my CustomScrollView. Any idea why this is happening? Also I will provide the code for my ViewModel, just in case.

struct SeeAllView: View {
    @ObservedObject var seeAllViewModel: SeeAllViewModel

    var body: some View {
        GeometryReader { geometry in
            VStack {
                Text("(self.seeAllViewModel.category.items.count)") // updated on refresh
                CustomScrollView(width: geometry.size.width, height: geometry.size.height, viewModel: self.seeAllViewModel) {
                    VStack {
                    Text("(self.seeAllViewModel.category.items.count)")  // not being updated
                    List {
                        ForEach(self.seeAllViewModel.category.items) { (item: Item) in
                            ItemRowView(itemViewModel: ItemViewModel(item: item))
                        }
                    }
                    .listStyle(GroupedListStyle())
                    .navigationBarTitle(Text(self.seeAllViewModel.category.title.firstCapitalized))
                    }
                }
                Button(action: {
                    self.seeAllViewModel.refresh()
                }) { Text("refresh")
                }
            }
        }
    }
}

CustomScrollView

struct CustomScrollView<Content: View, VM: LoadProtocol> : UIViewRepresentable {
    var width : CGFloat
    var height : CGFloat

    let viewModel: VM
    let content: () -> Content

    func makeCoordinator() -> Coordinator {
        Coordinator(self, viewModel: viewModel)
    }

    func makeUIView(context: Context) -> UIScrollView {
        let control = UIScrollView()
        control.refreshControl = UIRefreshControl()
        control.refreshControl?.addTarget(context.coordinator, action: #selector(Coordinator.handleRefreshControl), for: .valueChanged)

        let childView = UIHostingController(rootView: content())

        childView.view.frame = CGRect(x: 0, y: 0, width: width, height: height)

        control.addSubview(childView.view)
        return control
    }

    func updateUIView(_ uiView: UIScrollView, context: Context) { }

    class Coordinator: NSObject {
        var control: CustomScrollView<Content, VM>
        var viewModel: VM
        init(_ control: CustomScrollView, viewModel: VM) {
            self.control = control
            self.viewModel = viewModel
        }

        @objc func handleRefreshControl(sender: UIRefreshControl) {
            sender.endRefreshing()
            viewModel.refresh()
        }
    }

}

SeeAllViewModel

class SeeAllViewModel: ObservableObject, LoadProtocol {
    @Published var category: Category

    init(category: Category) {
        self.category = category
    }

    func refresh() {
        //everytime you need more data fetched and on database updates to your snapshot this will be triggered
        let query = self.category.query.start(afterDocument: self.category.lastDocumentSnapshot!).limit(to: 1)
        query.addSnapshotListener { (snapshot, error) in
            guard let snapshot = snapshot else {
                print("Error retreving cities: (error.debugDescription)")
                return
            }

            guard let lastSnapshot = snapshot.documents.last else {
                // The collection is empty.
                return
            }

            self.category.lastDocumentSnapshot = lastSnapshot

            // Construct a new query starting after this document,

            // Use the query for pagination.
            self.category.items += snapshot.documents.map { document -> Item in
                return Item(document: document)
            }
        }
    }

}


Get this bounty!!!

#StackBounty: #xcode #swiftui #uinavigationbar #uitabbar #swiftui-list How to fix gray bar under List in NavigationView in TabView?

Bounty: 50

So I am having a problem where just below my list I am having a gray bar that appears and when I click on a cell to go to the other view there is an even bigger gray bar. Here is the code for the List View:

 VStack{
             NavigationView{
                VStack{



                List{
                    ForEach(answersArray.indices, id: .self) { day in
                        NavigationLink(destination: DetailView(questions: self.answersArray[day].questions, answers: self.answersArray[day].answers, date: self.answersArray[day].dayDone.toString(dateFormat: "MM/dd/yy"))) {


                        HStack{
                            VStack{
                                ForEach(self.answersArray[day].questions.indices) { question in
                                    //Text(question)
                                    Text(self.answersArray[day].questions)
                                    .lineLimit(1)
                                        .frame(width: 250, height: 30, alignment: .leading)
                                      //  .padding(.vertical, 5)
                                    //.padding(.bottom)

                                }

                            }
                           // .truncationMode(.tail)
                            //.frame(minWidth: 0, idealWidth: 200, maxWidth: .infinity, minHeight: 0, idealHeight: 50, maxHeight: 75, alignment: .leading)

                            Text(self.answersArray[day].dayDone.toString(dateFormat: "MM/dd/yy"))
                                .frame(minWidth: 0, idealWidth: 50, maxWidth: .infinity, minHeight: 0, idealHeight: 20, maxHeight: 20, alignment: .trailing)
                        }

                        .padding(.horizontal, 5)
                    }

                        //.frame(minWidth: 0, idealWidth: 250, maxWidth: .infinity, minHeight: 0, idealHeight: 50, maxHeight: 100, alignment: .center)
                    }
                    //.colorMultiply(Color("Background Green"))
                  //  .listRowBackground(Color("Background Green"))
                    //.listRowBackground(Color("Background Green"))

                    Button(action: {
                        self.answersArray.append(DailyAnswer(questions: ["Question 1", "Question 2"], answers: ["I am happy", "I am sad"], dayDone: Date().addingTimeInterval(100000), lastWeek: false))
                        self.answersArray.append(DailyAnswer(questions: ["Question 1", "Question 2"], answers: ["I am happy", "I am sad"], dayDone: Date(), lastWeek: false))
                        self.answersArray.append(DailyAnswer(questions: ["Question 1", "Question 2"], answers: ["I am happy", "I am sad"], dayDone: Date(), lastWeek: false))
                    }) {
                        Text("Create cells")
                    }
                    }
                 .navigationBarTitle("Title")
               //.colorMultiply(Color("Background Green"))




                }

             }

             .accentColor(Color("My Gray"))

            }

And here is the code for the separate view:

import SwiftUI

struct DetailView: View {
    var questions : [String];
    var answers : [String];
    var date : String;
    var body: some View {

            //Color("Background Green")
               //.edgesIgnoringSafeArea(.all)

        NavigationView{
            ZStack{
            Color("Background Green")
                   .edgesIgnoringSafeArea(.all)
                ScrollView{
                    VStack{
                        ForEach(questions.indices) { pair in
                            Text(self.questions[pair])
                                .font(.title)
                                .padding()
                            Text(self.answers[pair])
                            .padding()
                                .font(.body)
                            .frame(minWidth: 0, idealWidth: 250, maxWidth: 350, minHeight: 150, idealHeight: 200, maxHeight: .infinity, alignment: .topLeading)
                            .background(
                            RoundedRectangle(cornerRadius: 5)
                                .stroke(Color.black, lineWidth: 1)
                            )

                        }

                    }
                    .padding(.top)
                    .navigationBarTitle("(date)", displayMode: .inline)
                }

        }
        }
    }
}

List View

Other View

Also I know this appears very similar to This Question, but when I implemented the solution on that page it would just change the color of the top Navigation Bar Title and not the gray on the bottom.

Also, this is where I am styling both the Tab Bar and the Navigation Bar

 init() {

       UINavigationBar.appearance().backgroundColor = UIColor(named: "Background Green")
       UITabBar.appearance().isTranslucent = false
       UITabBar.appearance().barTintColor = UIColor.black
       }


Get this bounty!!!