react-native: Can't build react-native project for ios 11

Is this a bug report?

yes

Have you read the Contributing Guidelines?

yes

Environment

  1. react-native -v: react-native: 0.47.1
  2. node -v: v6.11.2
  3. npm -v: 3.10.10
  4. yarn --version: 0.27.5
  • Target Platform: ios 11
  • Development Operating System: macOS 10.12.6
  • Build tools: xCode Version 9.0 beta 6 (9M214v)

Steps to Reproduce

I created an expo app with create-react-native-app

and ejected it to use expokit: yarn eject. Goal was to use arkit in this project (IOS).

In xcode i run it on a real device.

Expected Behavior

It should build

Actual Behavior

Build in xcode fails with

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_RCTSRWebSocket", referenced from:
      objc-class-ref in libReact.a(RCTInspectorPackagerConnection.o)
  "_OBJC_CLASS_$_RCTReconnectingWebSocket", referenced from:
      objc-class-ref in libReact.a(RCTPackagerConnection.o)
ld: symbol(s) not found for architecture arm64

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 18 (3 by maintainers)

Most upvoted comments

I believe I managed to find a solution for this, the final issue is either 2 libReact.a during linkage, or 0.

My Podfile contains this now:

  pod 'DoubleConversion', :podspec => react_native_path + '/third-party-podspecs/DoubleConversion.podspec'
  pod 'GLog', :podspec => react_native_path + '/third-party-podspecs/GLog.podspec'
  pod 'Folly', :podspec => react_native_path + '/third-party-podspecs/Folly.podspec'

  pod "Yoga", :path => "#{react_native_path}/ReactCommon/yoga"
  pod 'React', :path => '../node_modules/react-native'

  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'DevSupport',
    'CxxBridge',
  ]

Also, with this in the end, to avoid libReact.a compiled in the Pod project:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

Then, my XCode project is using libReact.a and libRTCWebSocket.a: image

This way, I managed to finally be able to both run in Simulator and Archive for the store…

Using XCode 9, RN 0.48.4, compiling the xcodeworkspace.

@maraujop

I was having the same problem the and did not have a pod file, I was able to build the app by placing libRCTWebSocket.a before libReact.a

image

Ok, I got it to work adding all my podspecs dependencies as .xcodeproj to Libraries and linking them in binaries, the old fashioned way. I had to add RCTText, RCTNetwork, RCTWebSocket, RCTImage

When I do this it compiles perfect in my local machine, but now it fails in buddybuild with duplicate symbols:

ld: 295 duplicate symbols for architecture arm64

Errors like this one:

duplicate symbol _OBJC_IVAR_$_RCTWebSocketModule._sockets in

It is obvious to me, that something is wrong with my local cocoapods, not sure what. Buddybuild states to use the same version as in my Podfile.lock and iOS project settings are the same. So it has to be a bad local cache or some magic they do.

I’m getting the same errors after upgrading existing project to 0.48.3. I’m using a Podfile with only ‘Core’ and ‘DevSupport’ subspecs of react native. The other libraries are included via Xcode. I’ve tried removing CocoaPods entirely, but it keeps giving me the same error as above.