How can I add ActivityKit extension for iPhone but not Mac in SwiftUI app?
Asked Answered
V

2

7

I have a SwiftUI app that is developed for all iOS devices and silicon Mac OS as well.

I have added ActivityKit Widget for the iOS devices and it works well. But when I submitted to the appStore I got the following error:

ITMS-90863: Macs with Apple silicon support issue - The app links with libraries that aren’t present in macOS:

/System/Library/Frameworks/ActivityKit.framework/ActivityKit

I don't wish to uncheck Mac because this app will be for Mac OS as well as iOS. How can I exclude the widget for only iOS to fix this warning?

Villalpando answered 10/2 at 23:56 Comment(1)
Have you found a solution? I'm facing the same issue.Twill
T
5

I fixed this issue in my project:

  • In Xcode select the project > your target > Build phases
  • In "Link Binary With Libraries" phase add ActivityKit and WidgetKit if they're not already there
  • Change their statuses to Optional

After those changes I was able to run the iOS app on macOS.

Twill answered 6/3 at 16:14 Comment(0)
C
1

One option is to add the ActivityKit as an optional library as this answer instructs. This did not work for me - the app still hangs on startup when downloading and opening it from TestFlight or App Store.

On top of that, you can try to add #if canImport(ActivityKit) to everywhere you reference to ActivityKit. It helps to momentarily add a Mac Catalyst destination for your iOS app and try to run that locally. If adding the canImport doesn't work (as it didn't for me), you can even start to distribute standalone macOS app with the Mac Catalyst build.

For me maintaining a standalone macOS distribution is not worth it so I had to just stop supporting macOS platform. This needs to be resolved Apple!

Clockwise answered 28/4 at 5:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.