4 Replies
      Latest reply on Nov 2, 2016 3:08 AM by eskimo
      waynehend Level 1 Level 1 (5 points)

        I've submitted a bug report for this issue but I'm hoping someone here may have seen or solved this already.


        I'm just getting started with background fetching for my iOS app and I've been following the excellent tutorial available from Ray Wenderlich.



        The tutorial code sample offered there works fine, after minor modification, in Xcode 7.3.1.  But Xcode 8 beta breaks it.   I let it auto-convert to Swift 3.  The app builds and runs on my attached iPhone 6, but the app crashes when I select "Simulate Background Fetch" form the debug menu in Xcode.


        I'm not getting enough information in the debugger to sort out the problem.  (Noob here, can't read most of it.)


        There is a view controller in the tutorial named "FetchViewController" containing functions updateUI() and fetch().  Here's a simpified version of the tutorial code that gets added to the AppDelegate class:


          func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void)
            print("Well waddya know, the Fetch was called")
            FetchViewController().fetch {


        As I said, this works fine and prints the text to the output console when the "Simulate Background Fetch" is selected.  The app is sent to the background and the text gets printed almost immediately.  And the called functions execute properly, as far as I can tell.


        In Xcode 8 beta, the app goes to the background but then crashes.  The text never prints.


        Maybe a clue?  I've added print lines to the AppDelegate to show when the app is changing state.  Examples:

        The app just became active

        The app is entering the background

        The app entered the background

        These work fine normally but never execute when I call for "Simulate Background Fetch", even though the app does retreat to the background.