radarlabs / react-native-radar

React Native module for Radar, the leading geofencing and location tracking platform
https://radar.com
Apache License 2.0
170 stars 32 forks source link

Build failing on new version 2.0.0 #31

Closed noahtallen closed 6 years ago

noahtallen commented 6 years ago

After updating react-native-radar to version 2.0, I've been getting some strange build errors:

While building module 'Foundation' imported from ../../../ios/Pods/Headers/Public/RadarSDK/RadarSDK/RadarSDK.h:8:
While building module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
In file included from <module-includes>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:43:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:72:
In file included from ../../../ios/Pods/leveldb-library/table/Block.h:10:
In file included from ../../../ios/Pods/leveldb-library/include/leveldb/iterator.h:18:
../../../ios/Pods/leveldb-library/include/leveldb/slice.h:21:10: fatal error: 'string' file not found
#include <string>
         ^~~~~~~~
1 error generated.
While building module 'Foundation' imported from ../../../ios/Pods/Headers/Public/RadarSDK/RadarSDK/RadarSDK.h:8:
In file included from <module-includes>:1:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:10: fatal error: could not build module 'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
 ~~~~~~~~^
While building module 'Foundation' imported from ../../../ios/Pods/Headers/Public/RadarSDK/RadarSDK/RadarSDK.h:8:
While building module 'Security' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLCredential.h:9:
In file included from <module-includes>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.h:27:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h:28:10: fatal error: could not build module 'CoreFoundation'
#include <CoreFoundation/CFBase.h>
 ~~~~~~~~^
1 error generated.
While building module 'Foundation' imported from ../../../ios/Pods/Headers/Public/RadarSDK/RadarSDK/RadarSDK.h:8:
While building module 'CFNetwork' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLError.h:9:
In file included from <module-includes>:1:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h:18:10: fatal error: could not build module 'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
 ~~~~~~~~^
1 error generated.
4 errors generated.
In file included from /Users/ntomallen/source/zonder-mobile-app/node_modules/react-native-radar/ios/RNRadar.m:1:
In file included from /Users/ntomallen/source/zonder-mobile-app/node_modules/react-native-radar/ios/RNRadar.h:1:
../../../ios/Pods/Headers/Public/RadarSDK/RadarSDK/RadarSDK.h:8:9: fatal error: could not build module 'Foundation'
#import "Foundation/Foundation.h"
 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
While building module 'CoreLocation' imported from ../../../ios/Pods/Headers/Public/RadarSDK/RadarSDK/Radar.h:8:
In file included from <module-includes>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreLocation.framework/Headers/CoreLocation.h:18:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreLocation.framework/Headers/CLErrorDomain.h:9:9: fatal error: could not build module 'Foundation'
#import <Foundation/Foundation.h>
 ~~~~~~~^
1 error generated.

** BUILD FAILED **

I also followed the migration instructions for updating the iOS and Android modules as well. Everything seems to be working correctly on Android.

I've also been researching this error, and I none of the suggested solutions for this error worked.

russellcullen commented 6 years ago

Thanks for the report, are you using Objective-C or Swift for your native code?

Have you tried these steps yet? https://github.com/react-native-community/react-native-google-signin/issues/361

noahtallen commented 6 years ago

We don't have any custom native code, so I believe it uses the react-native default (Objective-C). Based on the AppDelegate files, it's Objective-C. I was installing via Pods, and I also tried manually to see if it worked.

I also tried that (setting RNRadar.xcodeproj to build to Objective-C++), but it just results in a lot of errors like this:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:85:9: error: no member named 'strrchr' in the global namespace
using ::strrchr;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:86:9: error: no member named 'strspn' in the global namespace
using ::strspn;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:87:9: error: no member named 'strstr' in the global namespace
using ::strstr;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:89:9: error: no member named 'strtok' in the global namespace
using ::strtok;
      ~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]

I've tried most of the solutions like cleaning the build, deleting derived data, some changes to compiler settings, and re-installing Xcode, but get the same error every time. Even if that suggestion above worked, it would still cause errors on the next npm install since it's just an edit of a file provided from the package. :/

noahtallen commented 6 years ago

Want to add that I'm on react-native version 0.55.4.

One really strange thing is that while I was debugging this yesterday, I was able to get it to work by deleting Pods and running pod install again. HOWEVER, it only works with an Xcode build. The error still shows up when running react-native run-ios and it also still shows up on our Bitrise TestFlight build.

Edit: Xcode Archive also fails with the same error. Xcode run on simulator works for some reason though

noahtallen commented 6 years ago

This seems like it may be relevant, but I'm not sure what the SDK's codebase looks like: https://stackoverflow.com/a/30697222

russellcullen commented 6 years ago

Thanks for the investigations! Would you mind describing your setup to help us better reproduce locally?

Did you use create-react-native-app, create-react-app or react-native init (or something else?) to create the app?

And since everything was working before the upgrade I assume you've followed the documentation and ejected the app, if applicable?

noahtallen commented 6 years ago

Hi! Our app is pretty far along in development, I don't think it's very similar to any of those at this point. I think we started with react-native init. We've been ejected for a long time, too. What information would be valuable?

Here is our Podfile:

platform :ios, '9.0'

target 'zonder' do
  pod "yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'DevSupport',
    'RCTWebSocket',
    'RCTImage'
    # Add any other subspecs you want to use in your project
  ]

  # Required by the Facebook SDK:
  pod 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk/iOS'

  # Required by Firebase (see rnfirebase.io to add more Firebase features) 
  pod 'Firebase/Core', '~> 5.3.0'
  pod 'Firebase/Analytics', '~> 5.3.0'
  pod 'Firebase/Auth', '~> 5.3.0'
  pod 'Firebase/Firestore', '~> 5.3.0'
  pod 'Firebase/Messaging', '~> 5.3.0'
  pod 'Firebase/Storage', '~> 5.3.0'

  # For Crashlytics:
  pod 'Fabric', '~> 1.7.9'
  pod 'Crashlytics', '~> 3.10.5'

  # For react-native-maps
  rn_maps_path = '../node_modules/react-native-maps'
  pod 'react-native-maps', path: rn_maps_path
  pod 'react-native-google-maps', path: rn_maps_path
  pod 'GoogleMaps'
  pod 'Google-Maps-iOS-Utils'

  # Other random packages:
  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

  pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'

  pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen'

  pod 'RNSVG', :path => '../node_modules/react-native-svg'

  pod 'react-native-camera', :path => '../node_modules/react-native-camera'

  pod 'RadarSDK', '~> 2.0.0'

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-google-maps'
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end
    if target.name == "React"
      target.remove_from_project
    end
  end
end

I downgraded to the previous version, and the build errors go away, so it's definitely an issue with the update. Is there anything in particular I need to have configured in Xcode for the build to work correctly, or are there specific parts of the build process that changed between the old and new versions?

russellcullen commented 6 years ago

Thanks this info is super helpful! There's no changes that I know of in particular, but it's looking like I'm wrong on that one haha. Hopefully this helps me reproduce the issue.

Feel free to stay downgraded for the time being. While 2.0 is more optimized under the hood, you should see almost identical event and behavior with the previous version

noahtallen commented 6 years ago

Ok! We've been struggling on Android with enter/exit events not getting passed on to the JS code while the app is in the background, so I was hoping the update might help with that.

noahtallen commented 6 years ago

Update: You know how the react-native-radar xcodeproject gets linked to your own project? It turns out that if we remove the react-native-radar project from our own project, the build succeeds but results in the "native module is not defined" issue. But, if we keep the project there, the build fails with the errors above.

feargswalsh92 commented 6 years ago

Hey @coolbrow I'm working with Noah. Want to add a little more information. When we are working with 2.0. ,trying to make the app build results in the following error. Argument list too long: recursive header expansion failed at /Users/feargalwalsh/Downloads/zonder/zonder-mobile-app/node_modules/react-native-radar/ios/../../../ios/build/Index/DataStore/v5/records/76.

I tried all sorts of variations of the framework and header search paths in our app target and ended up deleting any references to radar and it was still giving me that error. Cleaning it and running npm cache verify restarting the packager closing opening Xcode and a bunch of other standard cache cleaning type stuff in the pods and node_modules had no effect. So then I tried downgrading on my own branch and I have all the errors Noah listed above now. It seems as if it would be easier to debug if I could get the first error fixed. Have you seen it before?

russellcullen commented 6 years ago

Thanks for the added info! Unfortunately I haven't seen any of these build issues before but I'm trying a bunch of different build configurations soon to see if I can reproduce.

All this info is super helpful and I appreciate your patience as we sort this out.

feargswalsh92 commented 6 years ago

image

No worries, appreciate the quick response. We're all in this together! Above is a screenshot of the errors I get when I select Objective C++, that's not new information but it seems as if this is the same issue outlined in this later comment.

https://github.com/react-native-community/react-native-google-signin/issues/361#issuecomment-406760747

Which below it seems to be solved by the selection of the @next branch of the GoogleSignIn node_module. Is there a version you have/ could code of React Native Radar that works like this next branch.

feargswalsh92 commented 6 years ago

Update

I got around that possibly temporarily by running yarn remove react-native-radar yarn add react-native-radar@next (just gave it a shot because I couldn't see a next branch on the google module so I thought it might be something else. It didn't find a @next version but it did ask me to choose a version of the module to install. The weird thing was that it didn't show any versions above 1.0.17 that were part of 1 release. Anyways I picked that one and now I'm getting a firebase error:

`

import "AppDelegate.h"

import

import <FBSDKCoreKit/FBSDKCoreKit.h>

import <React/RCTBundleURLProvider.h>

import <React/RCTRootView.h>

import "SplashScreen.h"

import "RNFirebaseNotifications.h" RNFirebaseNotifications.h' file not found

import "RNFirebaseMessaging.h"

import <RadarSDK/RadarSDK.h>

api keys are here

@import GoogleMaps; @implementation AppDelegate`

Which isn't your problem I don't think 😀

Here's the terminal sequence for selecting 1.0.17

Couldn't find any versions for "react-native-radar" that matches "next" ? Please choose a version of "react-native-radar" from this list: 1.0.17 [2/4] 🚚 Fetching packages... [3/4] 🔗 Linking dependencies... warning " > react-native@0.55.4" has incorrect peer dependency "react@16.3.1". warning " > react-native-firebase@4.3.7" has unmet peer dependency "fbjs@*". warning " > react-native-maps@0.21.0" has incorrect peer dependency "react-native@^0.51 || ^0.52 || ^0.53 || ^0.54". warning " > babel-jest@22.4.4" has unmet peer dependency "babel-core@^6.0.0 || ^7.0.0-0". warning "react-native-mock > react-dom@15.6.2" has incorrect peer dependency "react@^15.6.2". [4/4] 📃 Building fresh packages... success Saved lockfile. success Saved 1 new dependency. info Direct dependencies └─ react-native-radar@1.0.17 info All dependencies └─ react-native-radar@1.0.17 $ rm -f ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json ✨ Done in 23.75s.

noahtallen commented 6 years ago

@coolbrow I'm going to try to reproduce the issue in a repo that I can send to you. Basically gonna strip out all of the actual app and keep the dependencies and build configuration the same

noahtallen commented 6 years ago

Ok, I have it reproduced in this repo: https://github.com/ntomallen/radar_test

It's private, so let me know if you have any issues accessing it. I added @coolbrow and @feargswalsh92 as collaborators.

The very first commit should be the working version before the update. The second commit is everything that happened for the update to 2.0. Everything should just be iOS only. You can see some more details in the readme of the repo :)

russellcullen commented 6 years ago

Thanks so much, this is extremely helpful! I'll take a look at this and will get back to you asap

russellcullen commented 6 years ago

@ntomallen Good news! I was able to reproduce with that sample project (thanks again) and isolated the problem to the added search paths in this commit - https://github.com/radarlabs/react-native-radar/commit/f776c38389a8970cb1f587b9fad0d3938a52c885

Going to push a fix for this ASAP and release a new version.

russellcullen commented 6 years ago

Fixed in https://github.com/radarlabs/react-native-radar/releases/tag/2.0.2