Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RN 0.71.4 with New Architecture enabled and react-native-geolocation 3.0.5 C++ build error #245

Closed
iozzyi opened this issue Mar 27, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@iozzyi
Copy link

iozzyi commented Mar 27, 2023

Environment

System:
    OS: macOS 13.2.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 33.29 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.14.2 - ~/.nvm/versions/node/v18.14.2/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm
    Watchman: 2023.03.13.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.0, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
    Android SDK:
      API Levels: 26, 28, 29, 30, 33
      Build Tools: 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0
      System Images: android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.2 AI-202.7660.26.42.7351085
    Xcode: 13.0/13A5154h - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.18 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.4 => 0.71.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Platforms

iOS - npx react-native run-ios

Versions

  "dependencies": {
    "@react-native-community/geolocation": "^3.0.5",
    "react": "18.2.0",
    "react-native": "0.71.4",
    ...
  },

Description

After installing @react-native-community/geolocation the iOS build started failing on a C++ compilation error.

Steps to reproduce

  1. Follow the RN docs to create a new RN app with the New Architecture enabled on RN v0.71.4
  2. Check that the app builds fine on iOS
  3. Install @react-native-community/geolocation with yarn add @react-native-community/geolocation as per the README
  4. Uninstall the app from the simulator
  5. Open XCode, Select Product > Clean build folder
  6. Run cd ios && RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
  7. Run npx react-native run-ios
  8. Check the terminal output:
...tor/react-native-geolocation.build/Objects-normal/x86_64/RNCGeolocati[1940/1940]
/Users/xxxxxx/Desktop/projects/AwesomeProject/node_modules/@react-native-community/geolocation/ios/RNCGeolocation.mm:393:23: error: property 'sourceInformation' not found on object of type 'CLLocation *'
    mocked = location.sourceInformation.isSimulatedBySoftware;
                      ^
1 error generated

...

The following build commands failed:
        CompileC /Users/xxxxxx/Library/Developer/Xcode/DerivedData/AwesomeProject-xxxxxx/Build/Intermediates.noindex/Pods.build/Debug
-iphonesimulator/react-native-geolocation.build/Objects-normal/x86_64/RNCGeolocation.o /Users/xxxxxx/Desktop/projects/AwesomeProject/node_modules/@react-native-community/geolocation/ios/RNCGeolocation.mm normal x86_64 objective-c++ com
.apple.compilers.llvm.clang.1_0.compiler (in target 'react-native-geolocation' from project 'Pods')
(1 failure)

Also tried clearing the pod cache and rebuilding from scratch, same result.

  1. Run rm -rf ~/Library/Caches/CocoaPods && rm -rf ~/Library/Developer/Xcode/DerivedData/* && cd ios && rm -rf Pods && pod deintegrate && pod setup && RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
  2. Run npx react-native run-ios
  3. Check the terminal output:
The following build commands failed:
        CompileC /Users/xxxxxx/Library/Developer/Xcode/DerivedData/AwesomeProject-xxxxxx/Build/Intermediates.noindex/Pods.build/Debug
-iphonesimulator/react-native-geolocation.build/Objects-normal/x86_64/RNCGeolocation.o /Users/xxxxxx/Desktop/projects/AwesomeProject/node_modules/@react-native-community/geolocation/ios/RNCGeolocation.mm normal x86_64 objective-c++ com
.apple.compilers.llvm.clang.1_0.compiler (in target 'react-native-geolocation' from project 'Pods')
(1 failure)
@iozzyi iozzyi added the bug Something isn't working label Mar 27, 2023
@iozzyi
Copy link
Author

iozzyi commented Mar 27, 2023

I've created a patch commenting-out the line of code causing the issue and it seems to work now:

patches/@react-native-community+geolocation+3.0.5.patch

diff --git a/node_modules/@react-native-community/geolocation/ios/RNCGeolocation.mm b/node_modules/@react-native-community/geolocation/ios/RNCGeolocation.mm
index 5403680..9bfa163 100644
--- a/node_modules/@react-native-community/geolocation/ios/RNCGeolocation.mm
+++ b/node_modules/@react-native-community/geolocation/ios/RNCGeolocation.mm
@@ -389,9 +389,9 @@ - (void)locationManager:(CLLocationManager *)manager
   CLLocation *location = locations.lastObject;
 
   BOOL mocked = NO;
-  if (@available(iOS 15.0, *)) {
-    mocked = location.sourceInformation.isSimulatedBySoftware;
-  }
+  // if (@available(iOS 15.0, *)) {
+  //   mocked = location.sourceInformation.isSimulatedBySoftware;
+  // }
 
   _lastLocationEvent = @{
                          @"mocked": @(mocked),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant