2021-01-12 13:13

fix: building issue on tvOS / header on iOS


Fixed a build issue on tvOS in xcode 10.2. tvOS Header Search Paths were missing and couldn't find the <React/RCTUtils.h>. Also, batteryState is not available for tvOS and xcode failed to build, so I updated the if statement.


| OS | Implemented | | ------- | :---------: | | iOS | ✅ | | Android | ❌ | | Windows | ❌ |


  • [ ] I have tested this on a device/simulator for each compatible OS
  • [ ] I added the documentation in README.md
  • [ ] I mentioned this change in CHANGELOG.md
  • [ ] I updated the typings files (deviceinfo.d.ts, deviceinfo.js.flow)
  • [ ] I updated the dummy web/test polyfill (default/index.js)
  • [ ] I added a sample use of the API (example/App.js)


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • weixin_39617405 weixin_39617405 4月前

    If you think it's obvious to tvOS users then I am okay with not having the warning. I still like it for iOS at least. I definitely have problems with the same header search path issue in iOS - it builds but there is the error in XCode if you inspect, and I'm not alone as indicated in the stackoverflow, so if you could extend it to the iOS targets it should have everyone happy - I'd pull local, test and publish today

    点赞 评论 复制链接分享
  • weixin_39903375 weixin_39903375 4月前

    Thanks, I'll look into and see if I can fix it. Earliest can be tomorrow.

    点赞 评论 复制链接分享
  • weixin_39617405 weixin_39617405 4月前

    Since I'd need to test it locally anyway I went ahead and tried applying the same header block to the iOS targets and now for the example project I have a clean build (if I also apply #649 pointer type fixes). So I'd say this is basically good to go, I'll push my extra fix for iOS targets to your master then merge it in and publish. Thanks!

    点赞 评论 复制链接分享
  • weixin_39617405 weixin_39617405 4月前

    Okay - I have published this as v1.6.1 and I bundled #649 in as well. You are likely the most interested party and are using XCode, so when you get a chance if you could double-check it to make sure #649 didn't blow anything up, and that the work here was merged well, I would really appreciate it. Cheers!

    点赞 评论 复制链接分享
  • weixin_39903375 weixin_39903375 4月前

    Amazing. Thanks. I'll run some tests tomorrow and will let you how it goes.

    点赞 评论 复制链接分享
  • weixin_39903375 weixin_39903375 4月前

    Upgraded and all worked fine. Builds without a problem on tvOS and Android TV.

    However, when I specifically open Libraries/RNDeviceInfo.xcodeproj/RNDeviceInfo/RNDeviceInfo.m in xcode it shows a warning next to #import <React/RCTUtils.h> saying Lexical or Preprocessor Issue Group - React/RCTUtils.h' file not found.

    It still builds fine and does NOT show the error during or after the build process, only shows when I open that file in xcode.

    点赞 评论 复制链接分享
  • weixin_39617405 weixin_39617405 4月前

    I see that as well on the direct code open in the project directly, and likewise it builds fine (and without warnings other than upgrading to suggested settings now). I'm at a loss as to what's causing it but I'm happy there appears to be progress. 🤷‍♂ If after rumination you can think of what to do to make it better, I am obviously happy to merge things. Thanks!

    点赞 评论 复制链接分享
  • weixin_39903375 weixin_39903375 4月前

    I think there are still some dependency or header path issues. It builds fine, it's not a blocker. Anyway, when I got some time I'll look into and try to fix.

    点赞 评论 复制链接分享
  • weixin_39601794 weixin_39601794 4月前

    Hi! I am experiencing the same error ('React/RCTUtils.h' file not found) trying to build the app with react-native-device-info 1.6.1.

    Here is my podfile:

    target 'MyApp' do
        pod 'Fabric'
        pod 'Crashlytics'
        pod 'React', :path => '../node_modules/react-native', :subspecs => [
        'CxxBridge', # Include this for RN >= 0.47
        'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
        'RCTWebSocket', # Needed for debugging
        'RCTAnimation', # Needed for FlatList and animations running on native UI thread
        'RCTImage', # Needed for react-native-svg
        # Add any other subspecs you want to use in your project
        # Explicitly include Yoga if you are using RN >= 0.42.0
        pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
        # Third party deps podspec link
        pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
        pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
        pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
        pod 'react-native-video', :path => '../node_modules/react-native-video/react-native-video.podspec'
        pod 'GoogleSignIn', '~> 4.4.0'
        pod 'RNSVG', :path => '../node_modules/react-native-svg'
        pod 'react-native-orientation', :path => '../node_modules/react-native-orientation'
        pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'

    Tried unlinking/linking, re-installing pods etc. Also tried adding React header search paths to the ios project itself, but with no luck.

    Any other suggesstions?

    点赞 评论 复制链接分享
  • weixin_39601794 weixin_39601794 4月前

    OK, if I disable use_frameworks! flag, it works fine. I wonder why ¯\(ツ)

    点赞 评论 复制链接分享
  • weixin_39617405 weixin_39617405 4月前

    Hmm - that might be a clue to where the config is messed up - useful information, thank you

    点赞 评论 复制链接分享
  • weixin_39881760 weixin_39881760 4月前

    i don't have use frameworks! and still appearing same error, can't build my app

    点赞 评论 复制链接分享
  • weixin_39617405 weixin_39617405 4月前

    I am very excited about the header paths thing, I was in the area but hadn't fixed it yet. Does this fix it only for the tvOS target or for all targets, because it was a problem for the iOS build as well. And incidentally you can snag yourself some stackoverflow reputation easily for this one https://stackoverflow.com/questions/55790714/lexical-or-preprocessor-issue-in-react-native-while-building-ios-app-react-rctu

    secondly, bummer about the tvOS build fail - that is unexpected though, we had been thinking tvOS would return unknown, not fail the build. This mean that tvOS won't even show the warning though - do you develop for tvOS and have access to it? We'd like the warning to show up in dev mode for tvOS as well, but we obviously don't want the build to break

    点赞 评论 复制链接分享
  • weixin_39903375 weixin_39903375 4月前

    Well, I never had any issue with Header Search Paths on iOS with react-native-device-info, so this fix is only for tvOS.

    Regarding the build fail, we develop for tvOS and there is no batteryState for TV devices. I'm not sure if it's necessary to show a warning for TV as it quite obvious that there are no battery in TVs, but if you would like to I can spend some time to add the overlay without breaking the build.

    点赞 评论 复制链接分享