UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED - Ultimate Portfolio - sharedApplication unavailable to app extensions?

Forums > Articles

When making extensions for DataController to be used by a widget as mentioned in "Creating a simple widget", I get the error "'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead."

This error occurs in appLaunched() in the DataController.swift file, and in the video I can see that Paul has commented out at least the one offending line in the appLaunched() code. Unfortuanately vidoes don't scroll ;-)

Has anybody else experienced this error, and what was your workaround it?

5      

Not sure what the work around is yet, maybe that is a question for the next video, or a later Q&A session.

The lines are to do with inApp purchases and StoreKit, and the issue when adding a Quick Action to the app icon. See this video Add Quick Action to the icon at around 9:00 minutes.

6      

Hmm, for now it seems I have to choose between offering a review or a widget. Yep, waiting for the next episode seems like a good idea.

By the way the Apple Documentation explains what an app extension can do or not do: https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/index.html

And I've seen some suggest some build options settings that will supress the error, but that is hardly a solution…

5      

Well, the next video Creating a second widget did address this point, right at the end of the video.

With the explanation it is obvious what the workaround should be. I think that the workaround technique is a generally useful one, and can be applied to a great many situations.

5      

I wrote this question before that article came out, and it solves my question. Thanks for the input @Greenamberred 😀

5      

@loseth You're welcome. The Creating a second widget video only came out yesterday / last night.

5      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.