Realm-js: [Bug report] Undefined symbols for architecture x86_64 on Xcode build

Created on 15 Sep 2020  路  25Comments  路  Source: realm/realm-js

Goals

We are getting several errors Undefined symbols for architecture x86_64 when try to build (play) the React Native app with Xcode for iOS.

Here I report the example of two apps, with two different versions of Realm and React Native, both with the same problem.

To solve, we need to:

cd ios
rm -rf Pods
pod install

This happens several times a day, we have not yet discovered the reason.

My guess is that this is related to branch exchange. However, when changing branches, neither React Native nor Realm versions are changed. (ios/Pods and node_modules are ignored on GIT)

React Native 0.62.2 and RealmJS 6.0.2

image

React Native 0.61.5 and RealmJS 3.6.5

image

Steps to Reproduce

Unfortunately, we still haven't found a standard behavior.

Code Sample

Both projects are created using react-native init, without any customization in themetro, babel orcocoapods scripts.

Version of Realm and Tooling

  • Realm JS SDK Version: 3.6.5 and 6.0.2
  • React Native: RN 0.61.5 and 0.62.2 both with cocoapods and autolinking
  • Cocoapods: 1.9.3
  • Xcode: 11.7 (11E801a)
  • Node: 12.16.3 with nvm
  • Client OS & Version: macOS Catalina 10.15.6 (19G2021)
  • Which debugger for React Native: None

Maybe related to https://github.com/realm/realm-js/issues/2271 https://github.com/realm/realm-cocoa/issues/2393

O-Community

Most helpful comment

Looks like it is happening every time there is a change in Pods (ie adding a new or upgrading a version of any pod, not Realm). Realm is 10.0.1.

The temporal solution is to clean the build and do pod install again (no need to remove pods or node_modules folder), but I agree that it is pretty time consuming

All 25 comments

Are you comitting your ios/Pods directory into Git?
Does it help to clean out the build folder? (either by rm -rf ios/build or via the Xcode UI?

Thanks for the quick reply!

The ios/Pods folder is ignored on GIT.

We use the build only within Xcode, we never use it with "react-native run-ios", so there is no ios/build folder.

Before we found out that the problem was only in Pods, our solution was:

  1. Xcode -> Product -> Clean
  2. Remove Xcode DerivedData.
  3. Remove node_modules
  4. Remove ios/Pods

So it works now?

Yes, as I said, removing the Pods folder and installing again temporarily resolves the issue.

But, we still don't know the reason, the problem appears again, in different projects, different versions, different machines.

I had this error after update from XCode 11.5 to XCode 12. Before this step, all works fine

I have the same error with [email protected].
Xcode version 11.7 and RN 0.63.2
Pretty annoying impossible to build/run the app

I have the same error with [email protected]
Xcode version 11.7 and RN 0.63.2

I wrote some hack for solve this issue for me for a while
We need clear build folder and pods, as @douglasjunior says. So, we can do it in postinstall step

bin/postInstall

#!/usr/bin/env node

const childProcess = require('child_process')
const os = require('os')
;[
  // Kill the metro bundler if it's running.
  { command: 'pkill -f "cli.js start" || set exit 0', onlyPlatforms: ['darwin', 'linux'] },

  // on iOS, make sure our native modules are installed
  { command: 'xcodebuild clean', cwd: 'ios', onlyPlatforms: ['darwin'] },
  {
    command: 'rm -rf ~/Library/Developer/Xcode/DerivedData/*',
    cwd: 'ios',
    onlyPlatforms: ['darwin'],
  },
  { command: 'pod install', cwd: 'ios', onlyPlatforms: ['darwin'] },
]
  .filter(({ onlyPlatforms }) => !onlyPlatforms || onlyPlatforms.includes(os.platform()))
  .forEach(commandAndOptions => {
    const { command, onlyPlatform: _, ...options } = commandAndOptions
    try {
      childProcess.execSync(command, {
        stdio: 'inherit',
        ...options,
      })
    } catch (error) {
      process.exit(error.status)
    }
  })

package.json

// other stuff
  "scripts": {
    "preinstall": "rm -rf node_modules && rm -rf ios/Pods",
    "postinstall": "node ./bin/postInstall"
   }
// other stuff

After this, I run project directly from XCode 12 and build success. This solution is not brilliant, but solve the issue

Looks like it is happening every time there is a change in Pods (ie adding a new or upgrading a version of any pod, not Realm). Realm is 10.0.1.

The temporal solution is to clean the build and do pod install again (no need to remove pods or node_modules folder), but I agree that it is pretty time consuming

+1 same issue here every time my pods change... not very ideal

Please guys, vote on the issue to increase its relevance (馃憤 ), so we can have attention from the Realm team. Adding random comments does not help the visibility of the issue.

It's totally broke my development process when I need install new library.
Realm ftw is going on? Any comments here?

You can add something like

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end

to your app's pod. See also https://stackoverflow.com/questions/63607158/xcode-12-building-for-ios-simulator-but-linking-in-object-file-built-for-ios

@kneth thanks for the tip, we will try asap.

However, our problem also happens in Xcode 11 and using a physical device, not just on simulator.

Any progress? This is making my RN upgrade flow much more time consuming than it should be :(

@sbrighiu Did you try to modify your iOS app's Podfile as outlined previously?

You can add something like

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end

to your app's pod. See also https://stackoverflow.com/questions/63607158/xcode-12-building-for-ios-simulator-but-linking-in-object-file-built-for-ios

Just bringing feedback, we added this snippet to our Podfile, but the problem keeps happening.

I did actually, the result is the same. The only thing that works is cleaning the project before I do a pod install (just to be safe i do it before i run too :) )

I've also been encountering this same problem for months now. Been happening on Realm V3, V6 and now V10, so it's definitely not something caused by some recent change. My solution has been the same, clean build, reinstall pods, but it's more time-consuming than it needs to be, since it happens every time I need to Pod Install, even if Realm itself doesn't change.

I dont have the time to check but does this happen when realm is not installed using cocoapods?

I also posted here, maybe related ... https://github.com/realm/realm-cocoa/issues/6069#issuecomment-770220016

I'm reposting here just to cover all topics,

Guys i think i had 2 versions of cocoapods ... i'm not 100% but I cleaned everything up and now im sure i have just one. This is me explaining how I found it https://superuser.com/a/1627412/1276003.

TL;DR - If you ever ran `sudo gem install cocoapods -n /usr/local/bin` you may have 2 cocoapods installed. 
For me whenever i would call pod --version it would say 1.10.1, but today, from nowhere it said 1.8.4. Just ran uninstall in both local and global (reference link above) and now I can run my `yarn` without cleaning 100 times.

I hope this helps someone. Please remember to only keep one cocoapods version. :)

Here we have cocopoads installed with homebrew only, we never install with gem install.

I just went in a day from 10 min debug/release build to 3 min release build and 2 min debug build by fixing this and removing Flipper from my project :) so I'm happy :)

This fixes the issue I had with Xcode randomly showing 100 errors and stopping in the last 1%. I hope it helps someone :)

Ok I had it happen again .. when that happens I simply clean, delete derived data, run yarn clean, and then yarn
"clean": "rm -rf node_modules && rm -f package-lock.json && rm -f yarn.lock && rm -rf ios/Pods && rm -rf ios/Podfile.lock",

It is less frequent than before .. and not so much of an annoyance, but still not fixed...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

max-zu picture max-zu  路  3Comments

fever324 picture fever324  路  4Comments

ashah888 picture ashah888  路  3Comments

kevinnguy picture kevinnguy  路  3Comments

matt2legit picture matt2legit  路  3Comments