question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Simulate Background Fetch" option grayed out in XCode

See original GitHub issue

Your Environment

  • Plugin version: 2.5.1
  • Platform: iOS
  • OS version: 11.4
  • Xcode version: 9.4
  • Device manufacturer / model: iPhone 8 Plus Simulator (but happens on others I’ve tested too)
  • React Native version (react-native -v): 0.57.1
  • Plugin config: minimumFetchInterval: 60 * 24

Expected Behavior

After following tutorial to setup the Plugin using CocoaPods (https://github.com/transistorsoft/react-native-background-fetch/blob/master/docs/INSTALL-COCOAPODS-IOS.md), we should be able to test our deployment using the Xcode Menu option Debug -> Simulate Background Fetch.

Actual Behavior

The option Debug -> Simulate Background Fetch is grayed out and impossible to use to test our deployment. image

As you can see in the logs below, BackgroundFetch is activated successfully. The problem is just the grayed out option to Simulate on Xcode.

Steps to Reproduce

Not sure, as I have just followed the tutorial.

Context

For now, just trying to log when a Fetch occurs, as following code:

  BackgroundFetch.configure(
    {
      enableHeadless: true,
      minimumFetchInterval: 60 * 24,
      startOnBoot: true,
      stopOnTerminate: false,
    },
    async () => {
      console.log('just fetched stuff');
      BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA);
    },
    error => {
      global.rollbar.error(error.message, { error, userId });
    },
  );
};

This function is called as a callback on a successful BackgroundGeolocation.start().

Debug logs

2019-04-01 16:53:54.417 [info][tid:main][RCTRootView.m:293] Running application pier ({
    initialProps =     {
    };
    rootTag = 1;
})
2019-04-01 16:53:54.686 [warn][tid:NSOperationQueue 0x60000023a040 (QOS: UNSPECIFIED)][RCTModuleData.mm:248] RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks
2019-04-01 16:53:55.829 [warn][tid:com.facebook.react.JavaScript] ListView is deprecated and will be removed in a future release. See https://fb.me/nolistview for more information
2019-04-01 16:53:55.958 [warn][tid:com.facebook.react.JavaScript] Use `shouldComponentUpdate` in an `observer` based component breaks the behavior of `observer` and might lead to unexpected results. Manually implementing `sCU` should not be needed when using mobx-react.
2019-04-01 16:53:56.013 [info][tid:com.facebook.react.JavaScript] Running application "pier" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2019-04-01 16:55:23.125 [info][tid:com.facebook.react.JavaScript] {}
2019-04-01 16:55:23.126 [info][tid:com.facebook.react.JavaScript] GeolocationTrack configuring...
2019-04-01 16:55:23.127 [info][tid:com.facebook.react.JavaScript] { url: 'http://192.168.15.25:8080/',
  headers: { authorization: 'XXX' },
  params: 
   { user_id: 'XXX',
     device_id: 'YYY' },
  extras: {},
  desiredAccuracy: -1,
  distanceFilter: 10,
  elasticityMultiplier: 1,
  stationaryRadius: 25,
  disableElasticity: false,
  stopAfterElapsedMinutes: 0,
  stopOnStationary: false,
  desiredOdometerAccuracy: 100,
  useSignificantChangesOnly: false,
  locationAuthorizationRequest: 'Any',
  disableLocationAuthorizationAlert: true,
  stopTimeout: 5,
  stopDetectionDelay: 0,
  disableStopDetection: false,
  pausesLocationUpdatesAutomatically: undefined,
  activityType: undefined,
  disableMotionActivityUpdates: true,
  stopOnTerminate: false,
  startOnBoot: true,
  heartbeatInterval: undefined,
  schedule: undefined,
  preventSuspend: false,
  debug: true,
  logLevel: 5,
  logMaxDays: 7,
  batchSync: true,
  autoSync: true,
  autoSyncThreshold: 2,
  maxBatchSize: 50,
  geofenceProximityRadius: 1000,
  geofenceInitialTriggerEntry: false,
  reset: true }
ℹ️-[TSConfig persist] 
πŸ”΅-[TSLocationManager ready] 
2019-04-01 16:55:23.136 [info][tid:com.facebook.react.JavaScript] GeolocationTrack configured and ready

╔═══════════════════════════════════════════════════════════
β•‘ -[TSHttpService flush:error:] 
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

╔═══════════════════════════════════════════════════════════
β•‘ -[TSHttpService finish:error:] Success: 1
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager start] 
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
ℹ️-[TSLocationManager doStart:] trackingMode: 1
ℹ️-[TSConfig persist] 
🎾-[TSGeofenceManager start] 
πŸ”΅-[TSLocationManager setPace:] 0
🎾-[TSLocationManager startUpdatingLocation] Location-services: ON

╔═══════════════════════════════════════════════════════════
β•‘ -[TSHttpService flush:error:] 
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

╔═══════════════════════════════════════════════════════════
β•‘ -[TSHttpService finish:error:] Success: 1
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
2019-04-01 16:55:23.153 [info][tid:com.facebook.react.JavaScript] 'GeolocationTrack started', { url: [Getter/Setter],
  headers: [Getter/Setter],
  params: [Getter/Setter],
  extras: [Getter/Setter],
  desiredAccuracy: [Getter/Setter],
  distanceFilter: [Getter/Setter],
  elasticityMultiplier: [Getter/Setter],
  stationaryRadius: [Getter/Setter],
  disableElasticity: [Getter/Setter],
  stopAfterElapsedMinutes: [Getter/Setter],
  stopOnStationary: [Getter/Setter],
  desiredOdometerAccuracy: [Getter/Setter],
  useSignificantChangesOnly: [Getter/Setter],
  locationAuthorizationRequest: [Getter/Setter],
  disableLocationAuthorizationAlert: [Getter/Setter],
  stopTimeout: [Getter/Setter],
  stopDetectionDelay: [Getter/Setter],
  disableStopDetection: [Getter/Setter],
  pausesLocationUpdatesAutomatically: [Getter/Setter],
  activityType: [Getter/Setter],
  disableMotionActivityUpdates: [Getter/Setter],
  stopOnTerminate: [Getter/Setter],
  startOnBoot: [Getter/Setter],
  heartbeatInterval: [Getter/Setter],
  schedule: [Getter/Setter],
  preventSuspend: [Getter/Setter],
  debug: [Getter/Setter],
  logLevel: [Getter/Setter],
  logMaxDays: [Getter/Setter],
  batchSync: [Getter/Setter],
  autoSync: [Getter/Setter],
  autoSyncThreshold: [Getter/Setter],
  maxBatchSize: [Getter/Setter],
  geofenceProximityRadius: [Getter/Setter],
  geofenceInitialTriggerEntry: [Getter/Setter],
  reset: [Getter/Setter] }
ℹ️-[TSLocationManager removeListeners] 
ℹ️-[TSLocationManager on:success:failure:] providerchange
ℹ️-[TSLocationManager on:success:failure:] powersavechange
ℹ️-[TSHttpService onConnectivityChange:] 
ℹ️+[LocationAuthorization run:onCancel:] status: 3
🎾-[TSLocationManager startMonitoringBackgroundFetch] BackgroundFetch: ON

╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager startMonitoringBackgroundFetch]_block_invoke Background fetch received
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

╔═══════════════════════════════════════════════════════════
β•‘ -[TSHttpService flush:error:] 
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

╔═══════════════════════════════════════════════════════════
β•‘ -[TSHttpService finish:error:] Success: 1
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
2019-04-01 16:55:23.180 [info][tid:com.apple.root.default-qos][RNBackgroundFetch.m:61] - RNBackgroundFetch Rx Fetch Event
2019-04-01 16:55:23.180 [info][tid:com.facebook.react.JavaScript] just fetched stuff

πŸ“<+37.41116820,-122.20078524> +/- 5.00m (speed 34.82 mps / course 291.80) @ 4/1/19, 4:55:24 PM Brasilia Standard Time

╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 0 | df: -1.0m | age: 0.0s
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
βœ…-[TSLocationManager locationManager:didUpdateLocations:] Acquired motionchange position: <+37.41116820,-122.20078524> +/- 5.00m (speed 34.82 mps / course 291.80) @ 4/1/19, 4:55:24 PM Brasilia Standard Time
πŸ”΅-[TSLocationManager startMonitoringStationaryRegion:radius:] Radius: 25
πŸ”΄-[TSLocationManager stopUpdatingLocation] 
πŸ”΅-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0
🎾-[TSLocationManager startMonitoringSignificantLocationChanges] 
βœ…-[TSLocationManager persistLocation:]_block_invoke INSERT: E5A85DBD-DFFF-4EAA-835A-3D78C60F7042

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
flaviomaxcommented, Apr 2, 2019

To add to this discussion, I found a parallel way to test BackgroundFetch:

When using XCode’s Time Profiler, you can select your app’s process and start recording activity. Then a command to Simulate Background Fetch pops up under the Instrument option in the menu.

Is this path as trustworthy as the one we were discussing previously?

0reactions
flaviomaxcommented, Apr 2, 2019

Nothing related to this issue, as far as I can tell. The log is as follows:

2019-04-02 13:58:17.198 [info][tid:main][RCTRootView.m:293] Running application pier ({
    initialProps =     {
    };
    rootTag = 1;
})
2019-04-02 13:58:18.335 [warn][tid:NSOperationQueue 0x600000234640 (QOS: UNSPECIFIED)][RCTModuleData.mm:248] RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks
2019-04-02 13:58:51.854 [warn][tid:com.facebook.react.JavaScript] ListView is deprecated and will be removed in a future release. See https://fb.me/nolistview for more information
2019-04-02 13:58:51.931 [warn][tid:com.facebook.react.JavaScript] Use `shouldComponentUpdate` in an `observer` based component breaks the behavior of `observer` and might lead to unexpected results. Manually implementing `sCU` should not be needed when using mobx-react.
2019-04-02 13:58:51.972 [info][tid:com.facebook.react.JavaScript] Running application "pier" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native: Simulate Background Fetch disabled
I got Simulate background fetch enabled by going to: Xcode Menu > Product > Scheme > Edit Scheme and change Executable from Ask...
Read more >
I can not simulate the background fetch on the device in xcode
when I simulate the background fetch in the simulator it works. But when I test the application on the device connected to xcode...
Read more >
Simulate Background Fetch iOS on VisualStudio - MSDN
I want to simulate my backgroundfetch in my iOS project but I don't know ... I am trying it on the real device...
Read more >
iOS background processing - Background App Refresh Task
Background App refresh setting: The user can toggle the setting to ... To simulate background fetch, from the tab bar > Debug >...
Read more >
Swift iOS BackgroundTasks framework β€” Background App ...
Go to the β€œBackground Modes” session of the app target and check β€œBackground fetch” and β€œBackground processing” options if BGAppRefreshTask andΒ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found