amplitude / Amplitude-ReactNative

Official Amplitude React Native SDK
MIT License
81 stars 20 forks source link

Unable to build on arm64 (m1 chip) #104

Closed thinkmorebetter closed 2 years ago

thinkmorebetter commented 2 years ago

Hello,

I'm unable to build my project after adding the amplitude library.

Xcode 13.1 iOS target: 14.0 react-native: 0.64.2 @amplitude/react-native: 2.6.0

ld: warning: Could not find or use auto-linked library 'swiftSwiftOnoneSupport'
ld: warning: Could not find or use auto-linked library 'swiftObjectiveC'
ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find or use auto-linked library 'swiftCore'
ld: warning: Could not find or use auto-linked library 'swiftQuartzCore'
ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find or use auto-linked library 'swiftDispatch'
ld: warning: Could not find or use auto-linked library 'swiftDarwin'
ld: warning: Could not find or use auto-linked library 'swiftUIKit'
ld: warning: Could not find or use auto-linked library 'swiftCoreImage'
ld: warning: Could not find or use auto-linked library 'swiftFoundation'
ld: warning: Could not find or use auto-linked library 'swiftMetal'
Undefined symbols for architecture arm64:
"_*swift_FORCE_LOAD*$_swiftQuartzCore", referenced from:
_*swift_FORCE_LOAD*$*swiftQuartzCore*$_amplitude_react_native in libamplitude-react-native.a(AmplitudeReactNative-f2b6b898a0d57adfdea7aa2834ea3141.o)
(maybe you meant: _*swift_FORCE_LOAD*$*swiftQuartzCore*$_amplitude_react_native)
"_*swift_FORCE_LOAD*$_swiftMetal", referenced from:
_*swift_FORCE_LOAD*$*swiftMetal*$_amplitude_react_native in libamplitude-react-native.a(AmplitudeReactNative-f2b6b898a0d57adfdea7aa2834ea3141.o)
(maybe you meant: _*swift_FORCE_LOAD*$*swiftMetal*$_amplitude_react_native)
...
...
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

image

After searching around, I've tried a number of things, such as:

Any other suggestions?

Thanks for your help!

yuhao900914 commented 2 years ago

Hi @thinkmorebetter, I think that error is related to your local env. Can you check if any of these solutions can fix the issue? https://stackoverflow.com/questions/19213782/undefined-symbols-for-architecture-arm64

thinkmorebetter commented 2 years ago

Hi @yuhao900914, any chance you can be more specific? The thread you linked is from 2013.

My config includes:

LIBRARY_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)" "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)" "$(inherited)"

OTHER_LDFLAGS = $(inherited) -ObjC -lc++

Have you been able to build for arm64? I'm on an M1.

thinkmorebetter commented 2 years ago

This issue was resolved on react-native 0.66+: https://github.com/facebook/react-native/issues/31941