Solution: Upgrading from 0.61.5 to 0.62.0 "Undefined symbol: _swift_getFunctionReplacement"
See original GitHub issueEnvironment
System:
OS: macOS 10.15.3
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 123.51 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.14.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 23, 25, 26, 27, 28, 29
Build Tools: 23.0.1, 25.0.3, 26.0.1, 27.0.3, 28.0.3, 29.0.0
System Images: android-19 | ARM EABI v7a, android-19 | Google APIs ARM EABI v7a, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 11.4/11E146 - /usr/bin/xcodebuild
npmPackages:
react: 16.11.0 => 16.11.0
react-native: 0.62.0 => 0.62.0
npmGlobalPackages:
react-native-clean-project: 3.2.4
react-native-cli: 2.0.1
react-native-create-library: 3.1.2
react-native-template-typescript: 5.2.0
react-native: 0.60.4
Upgrading version
Upgrading from 0.61.5 to 0.62.0
Problem
Initial upgrade steps
-
I started by following the 0.61.5 to 0.62.0 RN upgrade helper. I performed all the changes shown in the diffs from the upgrade helper tool.
-
For the
project.pbxproj
changes, I proceeded to follow all four steps in the React Native 0.62 upgrade explanation in this repo.
I encountered the following errors when attempting to build iOS
Showing All Errors Only
Undefined symbol: _swift_getFunctionReplacement
Undefined symbol: _swift_getOrigOfReplaceable
More detailed error
Undefined symbols for architecture x86_64:
"_swift_getFunctionReplacement", referenced from:
_swift_getFunctionReplacement50 in libswiftCompatibilityDynamicReplacements.a(DynamicReplaceable.cpp.o)
(maybe you meant: _swift_getFunctionReplacement50)
"_swift_getOrigOfReplaceable", referenced from:
_swift_getOrigOfReplaceable50 in libswiftCompatibilityDynamicReplacements.a(DynamicReplaceable.cpp.o)
(maybe you meant: _swift_getOrigOfReplaceable50)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I found that some folks with the same error details in this issue thread from TelegramMessenger (completely unrelated to my app) but they seemed to find a solution by enabling dead code stripping.
I enabled Dead Code Stripping in Build Settings for DEBUG in EACH target of my project (we have 4). Dead code stripping was already enabled in the release configuration for all the targets and in the project build settings/
After enabling dead code stripping, I was able to build but the app would crash immediately with the following error
This copy of libswiftCore.dylib requires an OS version prior to 12.2.0
In order to fix this, I followed the steps in this SO answer, namely:
- Added a
Dummy.swift
file to the project (I already had bridging header files from following the steps in issue #13 of this repo. - Set
Always Embed Swift Standard Libraries
toYES
in the build settings for my project and all my targets.
Solution
So in summary, my complete upgrade steps were
-
Follow the 0.61.5 to 0.62.0 RN upgrade helper.
-
For the
project.pbxproj
changes, follow all four steps in the React Native 0.62 upgrade explanation in this repo. -
Enable Dead Code Stripping in Build Settings for both debug and release in each project target
-
Set
Always Embed Swift Standard Libraries
toYES
in the build settings for my project and all my targets. -
Either add a
Dummy.swift
file to the project, or don’t delete the dummy swift file that you created in step 2 (the issue #13 in this repo).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:233
- Comments:30
Top GitHub Comments
Following the SOLUTIONS in the topic works for me, just one thing:
Enable Dead Code Stripping --> This needed to be done for the TARGETS level, not PROJECT level
setting DEAD_CODE_STRIPPING to TRUE solved it for me 🙏