-
Notifications
You must be signed in to change notification settings - Fork 39
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
[TEALIUM SWIFT BUG]: Unable to preview a SwiftUI view when Tealium is integrated using SwiftPM #137
Comments
@danielbyon the Location module is only supported on iOS at present. Can you remove this from your tvOS target and try again? Swift PM doesn't have a way to have different modules specified for different platforms in the same Package.swift spec, unfortunately (though I will look into the conditional compilation option - I wasn't aware that was supported in Package.swift). |
We don't import the Location module in any of our app/framework targets, but it appears Xcode builds every target anyways We import:
|
OK, thanks for the info. We'll take a look and see what's possible. |
I re-read your response, you can't do |
@danielbyon I'm with you now - thank you. Will get back to you shortly on this. |
@danielbyon The release is up now that includes this fix. Thanks again for the suggestion. It's a shame the #ifdef is necessary, but hopefully this might be improved in future SPM releases. The fact that the target builds fine and only fails when you do a SwiftUI preview definitely feels like an Xcode bug to me. I'll file a bug report with Apple and see if it gets anywhere. |
Confirmed with a new SwiftUI project for both iOS/tvOS. Created the project, added tealium as a package dependency, and resumed the preview in the template ContentView.swift. Thanks for the fix! |
Your Environment
Fill out as appropriate.
iOS Version(s) [e.g. 12.1]: tvOS 13
Xcode version [Xcode> About Xcode e.g. 10.1 (10B61)]: 11.3.1
Swift version [e.g. 4.2]: 5.2
Tealium Swift library version [e.g. 1.6.7]: 1.9.1
Dependency manager [None/Carthage/CocoaPods]: SwiftPM
Dependency manager version:
Describe the bug
I am trying to implement a SwiftUI view in my main tvOS app target, and while I can build the project normally, when building for a canvas preview, multiple errors occur across multiple Tealium targets.
Does a workaround exist?
No workaround, I tried moving the SwiftUI view to a separate framework that is imported by the app target, and also trying it as a separate SwiftPM package. It appears being in the same workspace/project that also integrates Tealium using SwiftPM results in this error.
To Reproduce
Expected behavior
Preview builds and shows the default Apple stub code for a SwiftUI view
Actual behavior
Preview fails to compile. Attached error log
Tealium SwiftUI errors.txt
Screenshots
Additional context
This could also occur on iOS, but since we don't yet set iOS 13 as the deployment target, we can't use SwiftUI on that platform so I didn't try.
I noticed that even though my SwiftUI view didn't import Tealium, Xcode still rebuilt all packages (including Tealium). This happens even when I tried to isolate my SwiftUI view in a separate SwiftPM local package that lived in the same project file.
Some of the errors relate to symbols not being available on tvOS, such as
CLRegionState
. The fix could possibly be to explicitly wrap those code blocks using#if os(iOS)
, that way SwiftPM knows not to compile that for tvOS. Also some errors relate toUNNotificationCenter
APIs, which require tvOS 10 or newer, and I noticed the Package.swift file specifies tvOS 9.The text was updated successfully, but these errors were encountered: