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

Unable to build app for iOS simulator #362

Closed
jnurkka opened this issue Oct 1, 2021 · 20 comments
Closed

Unable to build app for iOS simulator #362

jnurkka opened this issue Oct 1, 2021 · 20 comments

Comments

@jnurkka
Copy link

jnurkka commented Oct 1, 2021

Your Environment

  • Plugin version: 4.0.3
  • Platform: iOS
  • OS version: 14.5
  • Device manufacturer / model: Simulator (Macbook Pro - both Intel and M1 CPUs)
  • React Native version (react-native -v): 0.63.4
  • Plugin config

Expected Behavior

App builds for iOS regardless if running on a simulator or a physical device

Actual Behavior

App builds only when building for a physical device

Steps to Reproduce

  1. yarn install
  2. cd ios && pod install
  3. Open Xcode
  4. Select a simulator (see spec above)
  5. Run

Context

Just trying to test my app on an ios simulator

Debug logs

ld: warning: ignoring file ../node_modules/react-native-background-fetch/ios/RNBackgroundFetch/TSBackgroundFetch.xcframework/ios-arm64_armv7/TSBackgroundFetch.framework/TSBackgroundFetch, missing required architecture x86_64 in file ../node_modules/react-native-background-fetch/ios/RNBackgroundFetch/TSBackgroundFetch.xcframework/ios-arm64_armv7/TSBackgroundFetch.framework/TSBackgroundFetch (2 slices)
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_TSBackgroundFetch", referenced from:
      objc-class-ref in AppDelegate.o
      objc-class-ref in libRNBackgroundFetch.a(RNBackgroundFetch.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

As mentioned above, there are no problems when performing exactly the same steps but selecting a physical device as the target to run the app on. Archiving a production build obviously also works.

@mikehardy
Copy link
Contributor

Strange, it's raining M1 issues 😅
Examine this comment and the entire related thread, it has a set of workarounds that should get you moving: transistorsoft/react-native-background-geolocation#1395 (comment)

@jnurkka
Copy link
Author

jnurkka commented Oct 1, 2021

Thanks @mikehardy for your fast response! Unfortunately this issue is not only appearing on M1 Macbooks but also on old ones with an Intel CPU.

@mikehardy
Copy link
Contributor

Sure, it will happen with Xcode 12.5 even. I'm not sure react-native 0.63.4 is worth supporting at all at this point, I can only deterministically say how to get it working with react-native 0.65.1 and upcoming 0.66.0

reference facebook/react-native#31941 and facebook/react-native#31480

I won't be able to comment further, I know that stanza works, if you're using up to date react-native

@christocracy
Copy link
Member

@jnurkka Try building the /example app in this repo.

@jnurkka
Copy link
Author

jnurkka commented Oct 1, 2021

@jnurkka Try building the /example app in this repo.

Running into this build issue in RCTxxBridge there:
Cannot initialize a parameter of type 'NSArray<Class> *' with an lvalue of type 'NSArray<id<RCTBridgeModule>> *__strong'

@mikehardy
Copy link
Contributor

Interesting - that's probably an Xcode 13 issue, c.f. thebergamo/react-native-fbsdk-next#97 - those types changed a bit I think

@christocracy I'm not sure react-native 0.61.5 is a valid base to build on vs Xcode 13, I'm surprised it's built this long!

"react-native": "0.61.5",

@christocracy
Copy link
Member

christocracy commented Oct 1, 2021

Googling that error, I found this magic spell.

however, now I get

Showing Recent Messages
File /Volumes/Glyph2TB/Users/chris/Library/Developer/Xcode/DerivedData/example-axygzpbkbfismbfdluvpwuefxwvu/Build/Products/Release-iphonesimulator/example.app/main.jsbundle does not exist. This must be a bug with

Yea, the /example hasn't been booted in ages. I updated the background-geolocation demo for latest RN (not yet pushed), so I'll do that for background-fetch soon too.

@christocracy
Copy link
Member

This must be a bug with


The suspense is killing me...

@mikehardy
Copy link
Contributor

That magic spell should not be needed in 0.65.1? Other magic spells (which I've posted) but not that one :-)
For repos that are don't have fancy things (like, react-native-windows or react-native-macos, which require lots of example hacking) I must admit I strongly prefer scripting the whole example construction so you don't blow time updating it, e.g. https://github.com/invertase/notifee/blob/master/packages/react-native/refresh-example.sh

(that one is probably all busted since since Notifee went fully open source and the repos are all re-arranged, but it gives the idea)

@christocracy
Copy link
Member

Good idea for autogenerating a fresh example instance. I whipped up a simple Node cli for most of my repos in /bin folder for performing tasks. I'll add a new task for doing this.

@jnurkka
Copy link
Author

jnurkka commented Oct 3, 2021

For reference, the issue still persist after upgrading to RN 0.65.1. Build succeeds when target is a physical device, fails with above errors for simulators

@mikehardy
Copy link
Contributor

@jnurkka that's to be expected I bet, and still not the fault of this module. You need to very very carefully play with ACTIVE_ARCHS / EXCLUDED_ARCHS etc settings so that you have the correct settings for the combination of your build environment and release environment.

@mikehardy
Copy link
Contributor

I did a bunch of unrelated compile testing and I am certain release mode works for instance, as I just updated this react-native-firebase build test script, and it probes release mode:

https://github.com/mikehardy/rnfbdemo/blob/ed5fa912169a9e17bdd50ca68b9ec643efe47efa/make-demo.sh#L182

It works on an M1 mac and an Intel mac.

@christocracy
Copy link
Member

That's quite a script.

@akmjenkins
Copy link

Googling that error, I found this magic spell.

That magic spell fixed the example app for me eact-native 0.65.1 (Xcode 13).

@mikehardy
Copy link
Contributor

That's quite a script.

Proper integration of react-native-firebase is involved enough, and I was typing the same answers enough that I finally resolved to turn myself into a robot, as it were, and now I just point people to that and say "these are the exact steps that result in a buildable project". My issues workload over there has probably been cut to a 1/3rd of what it was since

@jnurkka
Copy link
Author

jnurkka commented Oct 6, 2021

Seems like the issue had to do with library search paths. I compared the project.pbxproj file to that of a working RN app. Taking over the diff of build settings made the simulator builds work again.

Thanks anyway for your help!

Does anyone have any tips to avoid the file in question becoming corrupted over time as it is a pain to update on each RN version upgrade?

@jnurkka jnurkka closed this as completed Oct 6, 2021
@christocracy
Copy link
Member

How long ago was your RN app generated from react-native init?

@jnurkka
Copy link
Author

jnurkka commented Oct 6, 2021

How long ago was your RN app generated from react-native init?

Around 4 years ago 🤷‍♂️

@christocracy
Copy link
Member

That's your problem. In the early days of RN (2016, 2017), manually adding Framework Search Paths used to be part of the Setup Steps.

It's probably a good idea to re-generate a fresh RN app and migrate your JS code and dependencies into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants