Setting GTM_BACKGROUND_TASK_FETCHING to 0 disables use of GTMUIApplicationProtocol

263 views
Skip to first unread message

Mike Welsh

unread,
Nov 21, 2016, 2:45:01 PM11/21/16
to google-toolbox-for-mac
I need to set GTM_BACKGROUND_TASK_FETCHING because I'm using GTMSessionFetcher inside several app extensions as well as our main application (through cocoapods)

Is there any reason GTMUIApplicationProtocol can't still be used while GTM_BACKGROUND_TASK_FETCHING ? It can still default to UIApplication when the preprocessor define isn't set to 0, but if it is why not allow applications to implement this to take advantage of background tasks?

Thomas Van Lenten

unread,
Nov 21, 2016, 2:54:27 PM11/21/16
to google-toolbox-for-mac
Last time I looked, the problem was how Apple tagged apis as extensions safe.  You can call an api tagged as not extension safe (the background task) only if the call site is also tagged that way.  But due to how the fetcher works, we end up calling it from the fetch starting places, and you need to also be able to call those from within an extension.  So the only ways I've seen to pull this off would be to skip the background support and share one compile of the fetcher or, directly compile it into the extension with support disabled and directly into the app with support enabled.

TVL

Mike Welsh

unread,
Dec 2, 2016, 7:54:50 PM12/2/16
to google-toolbox-for-mac
I'm not suggesting that the UIApplication be called directly though - just that the GTMUIApplicationProtocol protocol could still be implemented and used even with the GTM_BACKGROUND_TASK_FETCHING ifdef disabled.

That way you could support background tasks and link to both the main application and the extension while not violating the APPLICATION_EXTENSION_API_ONLY (since you don't call the UIApplication unsafe method directly in this case).

Happy to push a proposal change to GitHub if you'd like or happy to drop the issue as well.

Thomas Van Lenten

unread,
Dec 5, 2016, 10:14:54 AM12/5/16
to google-toolbox-for-mac
Ah, interesting approach.  Sure go ahead and take a shot at it in a PR.  Thanks.

TVL

Mike Welsh

unread,
Dec 5, 2016, 11:15:11 AM12/5/16
to google-toolbox-for-mac
Created https://github.com/google/gtm-session-fetcher/pull/70 - I wasn't able to run the tests locally (they're greyed out) but if there's something I can do to turn them on and run them, let me know. Or any tests you'd like to see added.

Thomas Van Lenten

unread,
Dec 5, 2016, 12:18:25 PM12/5/16
to google-toolbox-for-mac
Which scheme were you using?  It should "just work".

Mike Welsh

unread,
Dec 5, 2016, 1:28:12 PM12/5/16
to google-toolbox-for-mac
I was able to right click on each test (or suite of tests) and run it, but it wouldn't let me run all the tests together. I was using the iOSTestApp target. Switching to iOS Framework resolved that.
Reply all
Reply to author
Forward
0 new messages