react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

`Undefined symbols: _OBJC_CLASS_$_TSBackgroundFetch` when compiling with Rosetta 2 Xcode to x86 iOS Simulator

Open noway opened this issue 1 year ago • 4 comments

Your Environment

  • Plugin version: 4.13.2
  • Platform: iOS
  • OS version: iOS 17.3
  • Device manufacturer / model: iOS Simulator
  • React Native version (react-native -v): 0.68.2
  • Plugin config
not relevant

Expected Behavior

Compilation to succeed

Actual Behavior

Compilation fails on link step

Steps to Reproduce

  1. use an Apple Silicon Mac
  2. bundle exec pod repo update && bundle exec pod install
  3. arch -x86_64 /Applications/Xcode.app/Contents/MacOS/Xcode
  4. set target to an iOS Simulator device (e.g. iPad)
  5. click Run

Context

  • I'm trying to use the package with x86 iOS Simulator through Rosetta 2.
  • The package compiles fine when building from Arm to Arm (Apple Silicon Mac to iPhone).
  • Tried both arch -x86_64 bundle exec pod repo update && arch -x86_64 bundle exec pod install and bundle exec pod repo update && bundle exec pod install - same error.
  • clean build doesn't help
  • use_frameworks! is NOT used
  • we can't use Arm iOS Simulator unfortunately because other packages are broken in it.

Debug logs

Logs
ld: warning: ignoring duplicate libraries: '-lc++', '-lsqlite3', '-lz'
ld: warning: ignoring file '/Users/ilia/stqry/stqry-rn/node_modules/react-native-background-fetch/ios/RNBackgroundFetch/TSBackgroundFetch.xcframework/ios-arm64_armv7/TSBackgroundFetch.framework/TSBackgroundFetch': fat file missing arch 'x86_64', file has 'arm64,armv7'
ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
ld: Undefined symbols:
  _OBJC_CLASS_$_TSBackgroundFetch, referenced from:
       in RNBackgroundFetch+AppDelegate.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

noway avatar Jan 10 '24 19:01 noway

I can reproduce this on version 4.14.6 of react-native-background-geolocation as well.

noway avatar Feb 15 '24 19:02 noway

I'll have a look at xcframework build-script.

christocracy avatar Feb 15 '24 20:02 christocracy

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Apr 17 '24 01:04 github-actions[bot]

This issue is not stale and still affects us.

noway avatar Apr 17 '24 02:04 noway

@christocracy sorry for bugging you, but is there any way to get this fixed? We use Rosetta 2 iOS Simulator on our Apple Silicon machines to create screenshots. We can't use ARM64 iOS Simulator since some of our other react-native packages are broken on ARM64 iOS Simulator. But on Rosetta 2 iOS Simulator, only react-native-background-geolocation is broken.

It's a big workflow friction point for us.

noway avatar May 14 '24 18:05 noway

@noway How were you able to compile at all, I am also having this issue and I can't seem to compile both on my physical device and simulator.

akinlekan28 avatar May 23 '24 13:05 akinlekan28

@akinlekan28 youre using Rosetta 2?

christocracy avatar May 23 '24 13:05 christocracy

@akinlekan28 youre using Rosetta 2?

Yes

akinlekan28 avatar May 23 '24 13:05 akinlekan28

How are you running with Rosetta 2? I'm able to launch my demo app in a simulator iPhone 15 Pro (Rosetta, 17.2).

Screenshot 2024-05-23 at 10 08 33 AM Screenshot 2024-05-23 at 10 12 20 AM

christocracy avatar May 23 '24 14:05 christocracy

How are you running with Rosetta 2? I'm able to launch my demo app in a simulator iPhone 15 Pro (Rosetta, 17.2).

Screenshot 2024-05-23 at 10 08 33 AM Screenshot 2024-05-23 at 10 12 20 AM

Screenshot 2024-05-23 at 15 48 28 Here's me trying to run it with rosetta

akinlekan28 avatar May 23 '24 14:05 akinlekan28

@akinlekan28 what's your React Native version?

@christocracy I'm opening Xcode and selecting a Rosetta simulator. Screenshot 2024-05-23 at 11 56 52 AM Here's my Xcode: image I'm using React Native 0.70.15 at the moment.

noway avatar May 23 '24 16:05 noway

@akinlekan28 what's your React Native version?

@christocracy I'm opening Xcode and selecting a Rosetta simulator. Screenshot 2024-05-23 at 11 56 52 AM Here's my Xcode: image I'm using React Native 0.70.15 at the moment.

0.74.1

akinlekan28 avatar May 23 '24 16:05 akinlekan28

My demo app uses react-native @ 0.73.0

I'm using XCode 15.3.

christocracy avatar May 23 '24 16:05 christocracy

@akinlekan28 do you have __apply_Xcode_12_5_M1_post_install_workaround enabled in your Podfile?

noway avatar May 23 '24 16:05 noway

@akinlekan28 do you have __apply_Xcode_12_5_M1_post_install_workaround enabled in your Podfile?

I removed it since it's not needed for newer version of RN

akinlekan28 avatar May 23 '24 16:05 akinlekan28

I updated to XCode 15.4. Demo App runs fine with Simulator iPhone 15 Pro (Rosetta, 17.4).

I suggest you try testing in a freshly generated, simple hello-world.

Screenshot 2024-05-23 at 12 19 58 PM

christocracy avatar May 23 '24 16:05 christocracy

I updated to XCode 15.4. Demo App runs fine with Simulator iPhone 15 Pro (Rosetta, 17.4).

I suggest you try testing in a freshly generated, simple hello-world.

Screenshot 2024-05-23 at 12 19 58 PM

I've been able to get this to work on both the simulator and physical device. I had to create a new app though.

akinlekan28 avatar May 23 '24 20:05 akinlekan28

Ok, got it to work too. Seems like RNBackgroundFetch+AppDelegate.m is not (no longer?) needed and react-native-background-fetch has to be present in package.json.

noway avatar May 23 '24 21:05 noway

Seems like RNBackgroundFetch+AppDelegate.m is not (no longer?)

Read about it here

and react-native-background-fetch has to be present in package.json.

As directed by the Setup Instructions

christocracy avatar May 23 '24 21:05 christocracy

@christocracy oh I see, RNBackgroundFetch+AppDelegate.m is deprecated, not fully removed. I added it back and the build still works!

It looks like merely doing yarn add react-native-background-fetch@^4.2.1 is enough.

Thank you!

noway avatar May 23 '24 21:05 noway

Unfortunately, RN doesn’t auto-link transitive dependencies of a plugin.

even though background-fetch is declared as a dependency within package.json, you’re forced to manually yarn add it in order for it to be auto-linked.

christocracy avatar May 23 '24 21:05 christocracy