Skip to content

Can't render SwiftUI canvas with Code Coverage Enabled #6219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brandtdaniels opened this issue Aug 6, 2020 · 18 comments
Closed

Can't render SwiftUI canvas with Code Coverage Enabled #6219

brandtdaniels opened this issue Aug 6, 2020 · 18 comments
Labels
api: core SwiftUI Issues directly related to Apple's SwiftUI framework

Comments

@brandtdaniels
Copy link

Step 0: Are you in the right place?

  • For issues or feature requests related to the code in this repository
    file a Github issue.
    • If this is a feature request please use the Feature Request template.
  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general (non-iOS) Firebase discussion, use the firebase-talk
    google group.
  • For backend issues, console issues, and other non-SDK help that does not fall under one
    of the above categories, reach out to
    Firebase Support.
  • Once you've read this section and determined that your issue is appropriate for
    this repository, please delete this section.

[REQUIRED] Step 1: Describe your environment

  • Xcode version: _11.6
  • Firebase SDK version: 6.28___
  • Firebase Component: Core___ (Auth, Core, Database, Firestore, Messaging, Storage, etc)
  • Component version: 6.9.1_
  • Installation method: **CocoaPods** | Carthage | Zip file (select one)

[REQUIRED] Step 2: Describe the problem

Can't render SwiftUI canvas due to FirebaseCore

linker command failed with exit code 1 (use -v to see invocation)

----------------------------------------

LinkDylibError: Failed to build TemplateListView.swift

Linking failed: linker command failed with exit code 1 (use -v to see invocation)

ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/SharedFrameworks-iphonesimulator'
Undefined symbols for architecture x86_64:
  "___llvm_profile_runtime", referenced from:
      ___llvm_profile_runtime_user in FirebaseCore(FIRComponentType.o)
      ___llvm_profile_runtime_user in FirebaseCore(FIRConfiguration.o)
      ___llvm_profile_runtime_user in FirebaseCore(FIRDiagnosticsData.o)
      ___llvm_profile_runtime_user in FirebaseCore(FirebaseCore-dummy.o)
      ___llvm_profile_runtime_user in FirebaseCore(FIRAnalyticsConfiguration.o)
      ___llvm_profile_runtime_user in FirebaseCore(FIRBundleUtil.o)
      ___llvm_profile_runtime_user in FirebaseCore(FIRAppAssociationRegistration.o)
      ...
     (maybe you meant: ___llvm_profile_runtime_user)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Steps to reproduce:

Rendering SwiftUI Canvas. The current workaround is to disable code coverage in the build scheme

Relevant Code:

NA

@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@paulb777
Copy link
Member

paulb777 commented Aug 8, 2020

A reproducible example would help us to diagnose

@brandtdaniels
Copy link
Author

brandtdaniels commented Aug 10, 2020

Any SwiftUI examples seems to reproduce the issue. Here are some SO posts regarding the issue:

https://stackoverflow.com/questions/60440074/problems-with-firebase-and-swiftui-live-previews

This workaround worked my project:
https://stackoverflow.com/a/62355502/699002
which references this tweet:
https://twitter.com/dannypier/status/1190312160557068293

@paulb777
Copy link
Member

I suspect that solving #2022 may resolve this. Until then, the workarounds may be the best bet.

@paulb777
Copy link
Member

Also may be related this issue noted at https://forums.swift.org/t/swift-packages-in-multiple-targets-results-in-this-will-result-in-duplication-of-library-code-errors/34892/38:

There is an entirely separate issue which happens only for Xcode previews which is related to all package products being built dynamically in Xcode 12 to enable previews. It is also something we're actively investigating. There is no workaround for this, since users do not have control over how builds for preview are being done.

@paulb777
Copy link
Member

Does Xcode 12 beta 5 make any difference?

@StormKop
Copy link

Unfortunately it does not Xcode 12 beta 5 does not fix the issue.

@ryanwilson ryanwilson added the SwiftUI Issues directly related to Apple's SwiftUI framework label Aug 31, 2020
@ryanwilson
Copy link
Member

I was able to reproduce this issue and the workaround works for me as well.

Steps to reproduce:

  1. Create a new SwiftUI iOS project in Xcode 12 b6. *Make sure to check the "Include Tests" box. Close the Xcode window.
  2. cd into the directory, run pod init.
  3. Add pod 'FirebaseCore' to the Podfile.
  4. Run pod update.
  5. Open the .xcworkspace generated from CocoaPods.
  6. Edit the scheme of the main app: go to the "Test" section, Options, click the Code Coverage checkbox.
  7. In ContentView.swift, add import FirebaseCore and replace the contents of body with:
var body: some View {
    Text("Hello, world!")
      .padding()
      .onAppear {
        // Use some arbitrary calls from `FirebaseCore`
        if let defaultApp = FirebaseApp.app() {
          print("Firebase configured! \(defaultApp.name)")
        } else {
          print("Firebase not configured.")
        }
      }
  }
  1. Regenerate the SwiftUI Preview Canvas. Observe the failure.

@ryanwilson ryanwilson changed the title Can't render SwiftUI canvas due to FirebaseCore Can't render SwiftUI canvas with Code Coverage Enabled Aug 31, 2020
@ryanwilson
Copy link
Member

@brandtdaniels hope you don't mind that I changed the title to make it easier to find for folks, and more accurately state the issue. Thanks again for the report.

@ryanwilson
Copy link
Member

TODO: Attempt to reproduce with Firebase 7, since dynamic frameworks are now used. Also check with Xcode 12.2 release candidate to see if the Xcode issue is resolved with static frameworks.

@brandtdaniels
Copy link
Author

Any updates on this?

@atereshkov
Copy link

Same for me. Still an issue

@denisaionita
Copy link

This is still an issue, it's most likely an Apple bug as I have found a few related issues on their forum, with weird workarounds(remove arm64 which was already done, validate workspace, set Build Active Architecture Only" to No and other such. Nothing worked or made sense for me and my project, and going through this thread I tried disabling the code coverage capability for my main scheme - and weirdly enough, that made the previews render.

@markst
Copy link

markst commented Feb 17, 2021

Also an issue for me. Disabling the code coverage does not appear to resolve.

@tichise
Copy link

tichise commented Mar 26, 2021

I am now getting previews rendered with code coverage off.

@teh-nsd
Copy link

teh-nsd commented Apr 14, 2021

I had the same issue with Canvas previews and can confirm that after I turned off Code coverage they now work.

@ryanwilson
Copy link
Member

TODO: Test this issue with Xcode 12.5 to see if it's resolved.

@ryanwilson
Copy link
Member

Hey everyone, I tested this with Xcode 12.5 with my repro steps above and was unable to reproduce - I think this is resolved.

I'm going to close this now, but if you still see the same error using Xcode 12.5 please share steps to reproduce and I'll re-open the issue!

@firebase firebase locked and limited conversation to collaborators May 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: core SwiftUI Issues directly related to Apple's SwiftUI framework
Projects
None yet
Development

No branches or pull requests