transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.56k stars 427 forks source link

Can't set it up #717

Closed kiddkevin00 closed 5 years ago

kiddkevin00 commented 5 years ago

Your Environment

Expected Behavior

After following your instruction to install react-native-background-geolocation, the app should still be able to run from XCode

Actual Behavior

I keep getting the following two errors when building the app from XCode:

Steps to Reproduce

  1. Init an Expo app
  2. Run $ npm run eject
  3. Setup react-native-background-geolocation by following your guides 3.1 react-native link Setup 3.2 Cocoapods 3.3 Manual Setup

Context

Install react-native-background-geolocation to my ejected Expo app and get it running on iPhone Simulator.

Debug logs

christocracy commented 5 years ago

Why manual setup? Use react-native link

christocracy commented 5 years ago

Show my your ios/Podfile

kiddkevin00 commented 5 years ago

I try react-native link first but it doesnt work so that why I then do manual setup on top of react-native link

kiddkevin00 commented 5 years ago
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

target 'pacesetter' do
  pod 'ExpoKit',
    :git => "http://github.com/expo/expo.git",
    :tag => "ios/2.8.4",
    :subspecs => [
      "Core"
    ],
    :inhibit_warnings => true
  pod 'EXAdsAdMob',
    :path => "../node_modules/expo-ads-admob/ios"
  pod 'EXSegment',
    :path => "../node_modules/expo-analytics-segment/ios"
  pod 'EXBarCodeScanner',
    :path => "../node_modules/expo-barcode-scanner/ios"
  pod 'EXBarCodeScannerInterface',
    :path => "../node_modules/expo-barcode-scanner-interface/ios"
  pod 'EXCamera',
    :path => "../node_modules/expo-camera/ios"
  pod 'EXCameraInterface',
    :path => "../node_modules/expo-camera-interface/ios"
  pod 'EXConstants',
    :path => "../node_modules/expo-constants/ios"
  pod 'EXConstantsInterface',
    :path => "../node_modules/expo-constants-interface/ios"
  pod 'EXContacts',
    :path => "../node_modules/expo-contacts/ios"
  pod 'EXCore',
    :path => "../node_modules/expo-core/ios"
  pod 'EXFaceDetectorInterface',
    :path => "../node_modules/expo-face-detector-interface/ios"
  pod 'EXFileSystem',
    :path => "../node_modules/expo-file-system/ios"
  pod 'EXFileSystemInterface',
    :path => "../node_modules/expo-file-system-interface/ios"
  pod 'EXFont',
    :path => "../node_modules/expo-font/ios"
  pod 'EXFontInterface',
    :path => "../node_modules/expo-font-interface/ios"
  pod 'EXGL-CPP',
    :path => "../node_modules/expo-gl-cpp/cpp"
  pod 'EXImageLoaderInterface',
    :path => "../node_modules/expo-image-loader-interface/ios"
  pod 'EXLocalAuthentication',
    :path => "../node_modules/expo-local-authentication/ios"
  pod 'EXLocation',
    :path => "../node_modules/expo-location/ios"
  pod 'EXMediaLibrary',
    :path => "../node_modules/expo-media-library/ios"
  pod 'EXPermissions',
    :path => "../node_modules/expo-permissions/ios"
  pod 'EXPermissionsInterface',
    :path => "../node_modules/expo-permissions-interface/ios"
  pod 'EXPrint',
    :path => "../node_modules/expo-print/ios"
  pod 'EXReactNativeAdapter',
    :path => "../node_modules/expo-react-native-adapter/ios"
  pod 'EXSensors',
    :path => "../node_modules/expo-sensors/ios"
  pod 'EXSensorsInterface',
    :path => "../node_modules/expo-sensors-interface/ios"
  pod 'EXSMS',
    :path => "../node_modules/expo-sms/ios"

  pod 'React',
    :path => "../node_modules/react-native",
    :inhibit_warnings => true,
    :subspecs => [
      "Core",
      "ART",
      "RCTActionSheet",
      "RCTAnimation",
      "RCTCameraRoll",
      "RCTGeolocation",
      "RCTImage",
      "RCTNetwork",
      "RCTText",
      "RCTVibration",
      "RCTWebSocket",
      "DevSupport",
      "CxxBridge",
      "RCTLinkingIOS",
      "RCTSettings"
    ]
  pod 'yoga',
    :path => "../node_modules/react-native/ReactCommon/yoga",
    :inhibit_warnings => true
  pod 'DoubleConversion',
    :podspec => "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec",
    :inhibit_warnings => true
  pod 'Folly',
    :podspec => "../node_modules/react-native/third-party-podspecs/Folly.podspec",
    :inhibit_warnings => true
  pod 'glog',
    :podspec => "../node_modules/react-native/third-party-podspecs/glog.podspec",
    :inhibit_warnings => true

  pod 'RNBackgroundGeolocation', :path => '../node_modules/react-native-background-geolocation'

  pod 'RNBackgroundFetch', :path => '../node_modules/react-native-background-fetch'

  post_install do |installer|
    installer.pods_project.main_group.tab_width = '2';
    installer.pods_project.main_group.indent_width = '2';

    installer.pod_targets.each do |target|

    if target.pod_name == 'ExpoKit'
      target.native_target.build_configurations.each do |config|
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'EX_DETACHED=1'

        # needed for GoogleMaps 2.x
        config.build_settings['FRAMEWORK_SEARCH_PATHS'] ||= []
        config.build_settings['FRAMEWORK_SEARCH_PATHS'] << '${PODS_ROOT}/GoogleMaps/Base/Frameworks'
        config.build_settings['FRAMEWORK_SEARCH_PATHS'] << '${PODS_ROOT}/GoogleMaps/Maps/Frameworks'
      end
    end

    if ['Amplitude-iOS','Analytics','AppAuth','Branch','CocoaLumberjack','FBSDKCoreKit','FBSDKLoginKit','FBSDKShareKit','GPUImage','JKBigInteger2'].include? target.pod_name
      target.native_target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
      end
    end
    # Can't specify this in the React podspec because we need
    # to use those podspecs for detached projects which don't reference ExponentCPP.
    if target.pod_name.start_with?('React')
      target.native_target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
        config.build_settings['HEADER_SEARCH_PATHS'] ||= ['$(inherited)']
      end
    end
    # Build React Native with RCT_DEV enabled and RCT_ENABLE_INSPECTOR and
    # RCT_ENABLE_PACKAGER_CONNECTION disabled
    next unless target.pod_name == 'React'
    target.native_target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_DEV=1'
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_ENABLE_INSPECTOR=0'
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'ENABLE_PACKAGER_CONNECTION=0'
    end

    end
  end
end
christocracy commented 5 years ago
$ cd ios
$ rm Podfile.lock
$ pod install

Show me the entire output.

kiddkevin00 commented 5 years ago
➜  ios git:(spike_geolocation) ✗ pod install
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `EXAdsAdMob` from `../node_modules/expo-ads-admob/ios`
Fetching podspec for `EXBarCodeScanner` from `../node_modules/expo-barcode-scanner/ios`
Fetching podspec for `EXBarCodeScannerInterface` from `../node_modules/expo-barcode-scanner-interface/ios`
Fetching podspec for `EXCamera` from `../node_modules/expo-camera/ios`
Fetching podspec for `EXCameraInterface` from `../node_modules/expo-camera-interface/ios`
Fetching podspec for `EXConstants` from `../node_modules/expo-constants/ios`
Fetching podspec for `EXConstantsInterface` from `../node_modules/expo-constants-interface/ios`
Fetching podspec for `EXContacts` from `../node_modules/expo-contacts/ios`
Fetching podspec for `EXCore` from `../node_modules/expo-core/ios`
Fetching podspec for `EXFaceDetectorInterface` from `../node_modules/expo-face-detector-interface/ios`
Fetching podspec for `EXFileSystem` from `../node_modules/expo-file-system/ios`
Fetching podspec for `EXFileSystemInterface` from `../node_modules/expo-file-system-interface/ios`
Fetching podspec for `EXFont` from `../node_modules/expo-font/ios`
Fetching podspec for `EXFontInterface` from `../node_modules/expo-font-interface/ios`
Fetching podspec for `EXGL-CPP` from `../node_modules/expo-gl-cpp/cpp`
Fetching podspec for `EXImageLoaderInterface` from `../node_modules/expo-image-loader-interface/ios`
Fetching podspec for `EXLocalAuthentication` from `../node_modules/expo-local-authentication/ios`
Fetching podspec for `EXLocation` from `../node_modules/expo-location/ios`
Fetching podspec for `EXMediaLibrary` from `../node_modules/expo-media-library/ios`
Fetching podspec for `EXPermissions` from `../node_modules/expo-permissions/ios`
Fetching podspec for `EXPermissionsInterface` from `../node_modules/expo-permissions-interface/ios`
Fetching podspec for `EXPrint` from `../node_modules/expo-print/ios`
Fetching podspec for `EXReactNativeAdapter` from `../node_modules/expo-react-native-adapter/ios`
Fetching podspec for `EXSMS` from `../node_modules/expo-sms/ios`
Fetching podspec for `EXSegment` from `../node_modules/expo-analytics-segment/ios`
Fetching podspec for `EXSensors` from `../node_modules/expo-sensors/ios`
Fetching podspec for `EXSensorsInterface` from `../node_modules/expo-sensors-interface/ios`
Pre-downloading: `ExpoKit` from `http://github.com/expo/expo.git`, tag `ios/2.8.4`
Fetching podspec for `Folly` from `../node_modules/react-native/third-party-podspecs/Folly.podspec`
Fetching podspec for `RNBackgroundFetch` from `../node_modules/react-native-background-fetch`
Fetching podspec for `RNBackgroundGeolocation` from `../node_modules/react-native-background-geolocation`
Fetching podspec for `React` from `../node_modules/react-native`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
Fetching podspec for `yoga` from `../node_modules/react-native/ReactCommon/yoga`
Downloading dependencies
Using Amplitude-iOS (3.14.1)
Using Analytics (3.6.10)
Using AppAuth (0.95.0)
Using Bolts (1.9.0)
Using Branch (0.24.2)
Using CocoaLumberjack (3.2.1)
Using Crashlytics (3.12.0)
Using DoubleConversion (1.1.5)
Using EXAdsAdMob (1.0.0)
Using EXBarCodeScanner (1.0.0)
Using EXBarCodeScannerInterface (1.0.0)
Using EXCamera (1.1.1)
Using EXCameraInterface (1.0.2)
Using EXConstants (1.0.2)
Using EXConstantsInterface (1.0.2)
Using EXContacts (1.0.0)
Using EXCore (1.1.0)
Using EXFaceDetectorInterface (1.0.2)
Using EXFileSystem (1.0.2)
Using EXFileSystemInterface (1.0.2)
Using EXFont (1.0.0)
Using EXFontInterface (1.0.0)
Using EXGL-CPP (1.0.2)
Using EXImageLoaderInterface (1.0.0)
Using EXLocalAuthentication (1.0.0)
Using EXLocation (1.0.0)
Using EXMediaLibrary (1.0.0)
Using EXPermissions (1.1.0)
Using EXPermissionsInterface (1.1.0)
Using EXPrint (1.0.0)
Using EXReactNativeAdapter (1.1.1)
Using EXSMS (1.0.2)
Using EXSegment (1.0.0)
Using EXSensors (1.0.2)
Using EXSensorsInterface (1.0.2)
Installing ExpoKit 2.8.4
Using FBAudienceNetwork (4.99.0)
Using FBSDKCoreKit (4.40.0)
Using FBSDKLoginKit (4.40.0)
Using FBSDKShareKit (4.40.0)
Using Fabric (1.9.0)
Using Folly (2016.09.26.00)
Using Google-Maps-iOS-Utils (2.1.0)
Using Google-Mobile-Ads-SDK (7.22.0)
Using GoogleAppUtilities (1.1.2)
Using GoogleAuthUtilities (2.0.2)
Using GoogleMaps (2.5.0)
Using GoogleNetworkingUtilities (1.2.2)
Using GoogleSignIn (3.0.0)
Using GoogleSymbolUtilities (1.1.2)
Using GoogleUtilities (1.3.2)
Using JKBigInteger2 (0.0.5)
Using RNBackgroundFetch (2.5.4)
Using RNBackgroundGeolocation (3.0.2)
Using React (0.55.4)
Using boost-for-react-native (1.63.0)
Using glog (0.3.4)
Using lottie-ios (2.5.2)
Using yoga (0.55.4.React)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 49 dependencies from the Podfile and 59 total pods installed.
christocracy commented 5 years ago
kiddkevin00 commented 5 years ago

One error this time:

Screen Shot 2019-05-08 at 12 12 55 PM
christocracy commented 5 years ago

Remove react-native-background-geolocation and get your app to boot without it first.

kiddkevin00 commented 5 years ago

Yes, it is able to run before I install react-native-background-geolocation. You saying I need to revert back?

christocracy commented 5 years ago

Google the error

kiddkevin00 commented 5 years ago

Yes I saw this and I try the solution there but still same error and this is what I have:

Screen Shot 2019-05-08 at 12 50 35 PM
kiddkevin00 commented 5 years ago

What else should I do now? If I revert back, can you give me step by step how to set it up?

kiddkevin00 commented 5 years ago

I am asking this because I have been re-trying several times following your guide for the past couple days and still going nowhere.

christocracy commented 5 years ago

No idea. I hate Expo.

I suggest you first try a Hello World project with only background-geolocation installed in isolation.

kiddkevin00 commented 5 years ago

But I've ejected from Expo. Ejected Expo app should just be a React Native app with some library on top of it. So you saying there is no way to integrate background-geolocation with ejected Expo app?

christocracy commented 5 years ago

So you saying there is no way to integrate background-geolocation with ejected Expo app?

No that's not what I'm saying.

Create a Hello World Expo app.

kiddkevin00 commented 5 years ago

Ok and then npm run eject, npm install background-geolocation, react-native link, then build/run on XCode, right?

christocracy commented 5 years ago

yes

kiddkevin00 commented 5 years ago

Run in foo.xcodeproj or foo.xcworkspace ?

christocracy commented 5 years ago

If your app has a Podfile, you always use .xcworkspace

kiddkevin00 commented 5 years ago

after npm run eject, npm install background-geolocation, react-native link, I build/run on XCode, and I got this Screen Shot 2019-05-08 at 2 06 32 PM

christocracy commented 5 years ago

And use react-native link after your Podfile exists.

And of course, after using react-native link, one always run pod install.

kiddkevin00 commented 5 years ago

ok the above is from .xcworkspace. after react-native link. It doesnt generate anything in Pods folder so it is still empty

kiddkevin00 commented 5 years ago

how to make Podfile exist? pod init?

christocracy commented 5 years ago

It's assumed you have a valid, non-empty Podfile before you install the plugin.

christocracy commented 5 years ago

if you don't have a Podfile, open xcodeproj

kiddkevin00 commented 5 years ago

Then I get this:

Screen Shot 2019-05-08 at 2 12 09 PM

christocracy commented 5 years ago

destroy your app and start all over again.

Does an ejected Hello World Expo app contain an ios/Podfile. I know nothing of Expo, except that I hate it.

kiddkevin00 commented 5 years ago

It does have a pod file inside ios folder Screen Shot 2019-05-08 at 2 19 35 PM

After react-native link should i do pod install?

kiddkevin00 commented 5 years ago

I got this error when running react-native link react-native-background-geolocation: Screen Shot 2019-05-08 at 2 28 19 PM What should I do?

christocracy commented 5 years ago

Failed here

kiddkevin00 commented 5 years ago

Ok but why and most importantly how to resolve it? Screen Shot 2019-05-08 at 2 44 23 PM

christocracy commented 5 years ago

Ah...don't use the word "test" when naming your project. The install script gets confused with the Test iOS Target

kiddkevin00 commented 5 years ago

Got it. Create a new project called foo this time. The first link passed but not the second - react-native link react-native-background-fetch Screen Shot 2019-05-08 at 3 01 10 PM

christocracy commented 5 years ago

Failing here

groupName = xcodeProjectDirectory.replace('.xcodeproj', '');
const projectGroup = project.findPBXGroupKey({ name: groupName });
project.addSourceFile(
    pathToAppdelegateExtension,
    { target: project.getFirstTarget().uuid },
    projectGroup
);

Edit node_modules/react-native-background-fetch/scripts/postlink.js and send out some console.log of those variables being referenced. Find out which of them is null.

After making a change:

$ react-native unlink react-native-background-fetch
$ react-native link react-native-background-fetch

You will probably see a similar error each time you unlink, ignore it.

kiddkevin00 commented 5 years ago

projectGroup is undefined

christocracy commented 5 years ago

show me the output of groupName

kiddkevin00 commented 5 years ago

groupName is foo

kiddkevin00 commented 5 years ago

pathToAppdelegateExtension is ../node_modules/react-native-background-fetch/ios/RNBackgroundFetch/RNBackgroundFetch+AppDelegate.m

kiddkevin00 commented 5 years ago

uuis is B56386401DB9693800A0598C

christocracy commented 5 years ago

You created this foo app from scratch after test failed? You didn't just try to rename it?

kiddkevin00 commented 5 years ago

I create a new one from scratch expo init foo npm run eject npm i background... react-native link ..background react-native link ..fetch

christocracy commented 5 years ago
cp -R foo foo2
cd foo2
rm -rf node_modules

zip up foo2 and email it to me @ chris@transistorsoft.com

christocracy commented 5 years ago

and just for kicks, create a vanilla RN project:

$ react-native init rnfoo

Link the plugins as you've been doing. Open the xcodeproj

kiddkevin00 commented 5 years ago

I sent to your email and yes, react-native init rnfoo is woking fine in my mac

kiddkevin00 commented 5 years ago

Are each of these setups mutually exclusive?

christocracy commented 5 years ago

When react-native link detects a Podfile, it will automatically perform the Cocoapod install.

react-native link does it all.

kiddkevin00 commented 5 years ago

Ok but using manual setup + pod install should still work right?

christocracy commented 5 years ago

Ok but using manual setup + pod install should still work right?

You pick 1 of the 3 install methods and follow the directions.