Skip to content
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

FirebaseAnalyticsSwift-Beta: Failure to Build/Archive with Xcode #7785

Closed
cpdunphy opened this issue Mar 25, 2021 · 14 comments
Closed

FirebaseAnalyticsSwift-Beta: Failure to Build/Archive with Xcode #7785

cpdunphy opened this issue Mar 25, 2021 · 14 comments

Comments

@cpdunphy
Copy link

Describe your environment

  • Xcode version: 12.4
  • Firebase SDK version: 7.9.1
  • Installation method: Swift Package Manager
  • Firebase Component: FirebaseAnalyticsSwift-Beta

Describe the problem

Xcode Archive fails when using the FirebaseAnalyticsSwift-Beta component. Building and installing the app with the dependency works so far as expected, the trouble is with archiving.

Note: the archive will succeed if you copy/add the source file (Analytics+SwiftUI.swift) to your local project, remove the troubled component (FirebaseAnalyticsSwift-Beta), and then attempt an archive. Due to this, I am led to believe this is a configuration issue, not (another) issue with SwiftUI.

Additionally, as noted by the Firebase SPM documentation, there is a preexisting issue (#6472) that also deals with analytics archive errors. Since the issue I'm detailing seems to be contained to the FirebaseAnalyticsSwift-Beta component, I do not currently have reason to believe the other is relevant.

Steps to reproduce:

  1. Create a new project
  2. Add "https://github.com/firebase/firebase-ios-sdk.git" as a Package Dependency (V 7.9.1)
  3. Select the desired components: FirebaseAnalyticsSwift-Beta and FirebaseAnalytics
  4. Archive

Relevant Error Messages:

FirebaseAnalyticsSwift Group
Swift Compiler Error Group
- Analytics+SwiftUI.swift:35:41: Cannot find type 'View' in scope
- Analytics+SwiftUI.swift:35:24: Cannot find type 'Content' in scope
- Analytics+SwiftUI.swift:25:44: Cannot find type 'ViewModifier' in scope
- Analytics+SwiftUI.swift:53:20: Cannot find type 'View' in scope
Uncategorized Group
- Command CompileSwift failed with a nonzero exit code

I'd like to note this additional warning. It does not (always) seem to impede the completion of a build, but does also popup along side the error above and seems contained to the FirebaseAnalyticsSwift-Beta component.

Skipping duplicate build file in Copy Files build phase: /Users/{user}/Library/Developer/Xcode/DerivedData/{project}/SourcePackages/artifacts/Firebase/FirebaseAnalytics.xcframework/ios-arm64_armv7/FirebaseAnalytics.framework
Skipping duplicate build file in Copy Files build phase: /Users/{user}/Library/Developer/Xcode/DerivedData/{project}/SourcePackages/artifacts/GoogleAppMeasurement/GoogleAppMeasurement.xcframework/ios-arm64_armv7/GoogleAppMeasurement.framework
@google-oss-bot
Copy link

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@ryanwilson
Copy link
Member

Thanks for the report and sorry for the troubles!

The workaround of copying the file manually sounds like a good approach for now while we figure out what's going on. I'm not sure why that's an issue though off the top of my head, as we're conditionally checking if SwiftUI can be imported here:

Thanks again, we'll try to reproduce and report back with progress.

@ryanwilson
Copy link
Member

Haven't tested this yet but I think adding a linkedFramework may be the solution here, similar to this inclusion of StoreKit:

.linkedFramework("StoreKit"),

@cpdunphy
Copy link
Author

@ryanwilson Thanks for taking a look! Obviously the component is in beta and issues are a given, but I figured it is worth mentioning. Let me know if you're able to reproduce it.

@ryanwilson
Copy link
Member

@ryanwilson Thanks for taking a look! Obviously the component is in beta and issues are a given, but I figured it is worth mentioning. Let me know if you're able to reproduce it.

Thanks, I can definitely reproduce it but the fix isn't as simple as I had originally hoped. Even with adding it as an explicitly linked framework, I'm still seeing the issue. I temporarily removed the #if canImport(SwiftUI and still running into the issue, despite importing SwiftUI on line 17.

I'll keep digging, thanks again for the report!

@ryanwilson
Copy link
Member

Hmm, I suspect this is the issue:

platforms: [.iOS(.v10), .macOS(.v10_12), .tvOS(.v10), .watchOS(.v6)],

If I change that to .iOS(.v13) I'm able to successfully archive with a few local changes. That's a no-go in general though since the rest of the SDKs still need to support older iOS versions. I suspect it could be a bug on Apple's side, since everything should be marked appropriately and we're gating the import but maybe this is working as intended. I'll try to assemble a minimal repro for now and update the thread on any results.

In the meantime, the workaround of adding the file to your app manually is a good approach.

Re: warnings of duplicate build files, when this eventually works you can remove the FirebaseAnalytics target as it gets included automatically when you depend on FirebaseAnalyticsSwift-Beta, although that's not abundantly clear and only due to FirebaseAnalytics being a binary dependency.

@paulb777
Copy link
Member

paulb777 commented Apr 5, 2021

Besides archiving this is also a problem for building FirebaseAnalyticsSwift-Beta for Any iOS Device.

@cpdunphy cpdunphy changed the title FirebaseAnalyticsSwift-Beta: Failure to Archive with Xcode FirebaseAnalyticsSwift-Beta: Failure to Build/Archive with Xcode Apr 6, 2021
@Panajev
Copy link

Panajev commented Apr 26, 2021

I had to revert to Firebase 7.10.0 from 7.11.0 as it would not build with the Xcode 12.5 RC build (SwiftPM integration).

Tried to fully remove Firebase and then re-add it via SwiftPM and could only re-add 7.10.0, Xcode would throw up an error and refuse to add 7.11.0. I think this is pretty important as Xcode 12.5 will go live very shortly as iOS 14.5 goes live this week.

@ryanwilson
Copy link
Member

@Panajev thanks for the additional report - looking into this now.

Was the error you're seeing similar to the screenshot below? If so, that's a different error but needs attention. I've filed #7962 to track this.

Installation error in Xcode

@ryanwilson
Copy link
Member

TODO for solving the original issue: create a minimal repro to report to the Swift forums / Apple's Feedback system, or ideally find a solution based on the minimal repro.

@Panajev
Copy link

Panajev commented Apr 26, 2021 via email

@ryanwilson
Copy link
Member

I was able to create a small sample project that reproduces this issue (outside of Firebase).

Observation: moving the minimum iOS version in Package.swift to 11.0 eliminates the issue. I suspect it has something to do with dropping 32 bit support and the armv7 slice, as we've seen with building the zip file on iOS and AppCheck.

@ryanwilson
Copy link
Member

I've created a repro at https://github.com/ryanwilson/Repro-SwiftPMMinVersionBuild and posted it to the Swift forums: https://forums.swift.org/t/error-building-for-device-while-supporting-older-ios-versions/47890.

Next step is to bump the minimum supported iOS version to 11 as a workaround.

ryanwilson added a commit that referenced this issue May 4, 2021
This is to avoid an issue with newer APIs being unable to compile when
building for device while this manifest targets iOS 10.

See #7785 (comment)
for more details on the issue and a reproduction. This should be
re-evaluated if Xcode ever fixes the issue.
ryanwilson added a commit that referenced this issue May 4, 2021
This is to avoid an issue with newer APIs being unable to compile when
building for device while this manifest targets iOS 10.

See #7785 (comment)
for more details on the issue and a reproduction. This should be
re-evaluated if Xcode ever fixes the issue.
@ryanwilson
Copy link
Member

Going to close this now that it's merged into master - this will be fixed for Firebase 8.0.

Thanks for the report!

@firebase firebase locked and limited conversation to collaborators Jun 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants