microsoft / appcenter-sdk-apple

Development repository for the App Center SDK for iOS, macOS and tvOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SwiftUI Previews in Xcode 14 failed to run when adding AppCenterCraches through SPM

pyby opened this issue · comments

Description

An iOS project doesn't work anymore for SwiftUI Preview with Xcode 14 RC.
The project builds and runs fine, but Preview never works. The error message is as follows:

HumanReadableSwiftError

SettingsError: noExecutablePath(<IDESwiftPackageStaticLibraryProductBuildable:ObjectIdentifier(0x0000600279d29500):'AppCenterCrashes'>)

AppCenterCrashes is added thought PSM. SwiftUI Preview with Xcode 13.4.1 works.

It was mentioned during Xcode 14 beta version here:
https://developer.apple.com/forums/thread/707569?page=2

I opened a radar to Apple, but as the issue is not on all SPM packages, I'm not sure that Apple will fix it.
Any idea?

Repro Steps

With Xcode 14 RC:

  1. Create a new project (command+Shift+N)
  2. Choose iOS app / Swift UI / swift
  3. Click on "ContentView" file
  4. Display Canevas and run the Preview with a simulator device

"Hello, world!" preview is displayed.

  1. In Project / Package dependencies, add https://github.com/microsoft/appcenter-sdk-apple.git, Up to next major version, 4.0.0
  2. Add AppCenterCrashes product to the target.
  3. Click on "ContentView" file to display the preview again.

"Unexpected error occured".

Details

  1. Which SDK version are you using?
    • 4.4.3
  2. Which OS version did you experience the issue on?
    • Any. Xcode 14 with iOS16 / tvOS 16 SDK.
  3. Which Xcode version did you build the app with?
    • e.g. Xcode 14.0 RC (beta 4, 5, 6 as well).
  4. Which Cocoapods version are you using (run pod --version)?
    • None
  5. What device version did you see this error on? Were you using an emulator or a physical device?
    • Phone or Apple TV simulator, SwitUI preview.
  6. What language are you using?
    • Swift
  7. What third party libraries are you using?
    In this example, no one: just AppCenterCrashes.

In our project, other libraries (binaries or to compile) has no impacts with SwiftUI preview build.

@pyby Hello. You mean if to exclude AppCenterCrashes from the project, then everything is working as expected?
And another question, what if not to launch Preview, but just start the application on a simulator?

commented

Thank you for the report! I'm marking it as a bug.

Having the same issue on Xcode 14.0 (14A309).

@pyby Hello. You mean if to exclude AppCenterCrashes from the project, then everything is working as expected?

And another question, what if not to launch Preview, but just start the application on a simulator?

  1. Yes. The SwiftUI previews build succeed and the previews in Xcode are ok.

  2. Build and run the application in the simulator starts as expected. Also for release build on devices or for AppStore submission.

The issue impacts developers using the previewing SwiftUI feature in Xcode.

The same issue on Xcode 14.0 (14A309).

As the issue seems to be linked to "Static Library ProductBuildable", we tried to remove the type: .static declaration for product libraries.

SwiftUI previews build succeed again with Xcode 14.0 (14A309).

I'm not sure if we can create a PR with this change without a validation from the core team:

  • Should we have a third Packages.swift file for Swift 5.7 (Xcode 14) without the static type only for new Xcode version?
  • Why AppCenter libraries are delivered as static libraries with SPM?

Same issue with Xcode 14.1 beta (14B5024h).

https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html

/// If possible, don't declare the type of library explicitly to let 
/// the Swift Package Manager choose between static or dynamic linking based
/// on the preference of the package's consumer.

It would be great for the libraries to re-evaluate why it's static only.

Any update on a fix or suggestions about how to resolve this? Is the only option to fork this repo and remove the library types in package.swift?

commented

I ran into the same issue. Removing AppCenter from code and the list of embedded libraries did "fix" the previews.

Any solution to get previews and App Center work together would be great.

I ran into the same issue. Removing AppCenter from code and the list of embedded libraries did "fix" the previews.

Any solution to get previews and App Center work together would be great.

Previews in Xcode work when AppCenter is added via CocoaPods.

I've prepared PR with a fix of this issue: #2433
The fix will be released soon, as a workaround you can use the fork which is mentioned in comments above.

Anybody know an ETA when the fix will be merged?

I have the same issue with Xcode version 14.0.1 (14A400).
Even though I removed the static type, I could not solve this issue completely, as now AppCenterCrashes is causing SwiftUI preview problems. I removed the static type there as well but still. This is annoying, and I cannot simply use a forked package on this project. Any ETA?

Hi there
The release is expected this month.

It still an issue with Xcode version 14.1 (14B47).

HumanReadableSwiftError

SettingsError: noExecutablePath(<IDESwiftPackageStaticLibraryProductBuildable:ObjectIdentifier(0x000060006329fc90):'AppCenterDistribute'>)

Thank you @AnatolyPristensky for the PR and MS team for the future release.

@aleksandr-dorofeev We are already in the dawn of the next month... When can we expect a release?

Hi @honkmaster, the apple SDK is planned to be released within two weeks.

Hi @honkmaster, the apple SDK is planned to be released within two weeks.

This was 2 weeks ago. Any update?

Same for us. Our SwiftUI previews do not work, just because we integrated AppCenter. We would love for the previews to work again :)

Hi @zulfishah and @mreichelt the update is already available for some days now under version 5.0.0. I suppose you already have version 4.4.3 installed and you are using Swift Package Manager (SPM) under Xcode. The package manager updates the packages for one major release, when the major release number changes the updates are not done automatically. So, in order to get the latest version you have to remove the package and install it again, or you have to go and manually enter version 5.0.0 (the new major release) as shown in the screenshot below:

Screenshot 2022-11-17 at 00 45 09

Oh, I didn't see that a new version was out - or that it would include the fix for this! Thank you so much @summongr - I'll test it as soon as I get around to it and provide feedback 👍

I just tried it locally with version 5.0.0 - and indeed the previews appear again! Thank you so much! 🎉

Release 5.0.0 is ready! I am closing this issue.