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

Build failed with error '_swift_getTypeByMangledNameInContextInMetadataState' when adding Notification Content Extension to iOS project. #29246

Closed
SunskyXH opened this issue Jun 29, 2020 · 13 comments
Labels
Needs: Triage 🔍 Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.

Comments

@SunskyXH
Copy link

Description

Build failed with an error when adding Notification Content Extension to iOS project.

Undefined symbols for architecture arm64:
  "_swift_getTypeByMangledNameInContextInMetadataState", referenced from:
      ___swift_instantiateConcreteTypeFromMangledNameAbstract in NotificationViewController.o

React Native version:

react-native info result
System:
    OS: macOS 10.16
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Memory: 107.45 MB / 16.00 GB
    Shell: 2.7.1 - /usr/local/bin/fish
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.22.4 - ~/.yarn/bin/yarn
    npm: 6.10.3 - ~/.nvm/versions/node/v10.16.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 23, 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-25 | Google APIs ARM EABI v7a, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6514223
    Xcode: 11.5/11E608c - /usr/bin/xcodebuild
  npmPackages:
    @react-native-community/cli: 4.9.0 => 4.9.0 
    react: ^16.13.1 => 16.13.1 
    react-native: 0.62.2 => 0.62.2 
  npmGlobalPackages:
    create-react-native-module: 0.16.0

Steps To Reproduce

  1. in Xcode, select File -> New -> Target and choose Notification Content Extension.
  2. Build project and error occurs.

Expected Results

Add Notification Content Extension to React Native project and build it successfully.

@fabioglimb
Copy link

Same here, but when trying to implement Apollo for Graphql as a swift package

@hengkx
Copy link

hengkx commented Jul 26, 2020

Undefined symbols for architecture x86_64:
  "_swift_getTypeByMangledNameInContextInMetadataState", referenced from:
      ___swift_instantiateConcreteTypeFromMangledNameAbstract in ShareViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@hengkx
Copy link

hengkx commented Jul 26, 2020

how to resolve?

@hengkx
Copy link

hengkx commented Jul 26, 2020

I use the following method to solve the problem

LIBRARY_SEARCH_PATHS = (
   "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
-  "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"",
+  "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.2/$(PLATFORM_NAME)\"",
   "\"$(inherited)\"",
 );

@aguglie
Copy link

aguglie commented Jul 28, 2020

@hengkx cool, now it builds 😃

@mluisbrown
Copy link

mluisbrown commented Aug 1, 2020

I also had this issue and asked about it on the Swift forums. The cause is trying to link against an older Swift runtime while targeting a newer version of the OS.

You should be able to just remove those LIBRARY_SEARCH_PATH entries entirely (or just leave $(inherited)) and that will fix the problem. This is a bug in the ReactNative template for iOS.

As mentioned in the above Swift forums thread:

You shouldn't need to add the toolchain library paths to LIBRARY_SEARCH_PATHS yourself, because Xcode will automatically include those libraries if your minimum deployment target is old enough to need them.

@SunskyXH
Copy link
Author

SunskyXH commented Aug 3, 2020

@hengkx, it works for me! Thanks a lot!

@SunskyXH SunskyXH closed this as completed Aug 3, 2020
@mrousavy
Copy link
Contributor

mrousavy commented Sep 17, 2020

Sorry for commenting on a closed issue, but I'm still experiencing this problem and nothing seems to help. I've tried changing my IPHONEOS_DEPLOYMENT_TARGET to 9.0, 10.0, 11.0 and 13.5, nothing works. I've tried @hengkx 's fix, didn't work. I've tried leaving only inherited in there, and removing it entirely, still didn't work. Can anyone help me out here?

Screenshot 2020-09-17 at 13 35 43

EDIT: Fixed it! My notification service extension had a different deployment target version than the RN app.

@doylemark
Copy link

Same issue here, adding a WidgetExtension to a blank react-native app causes this issue. None of the above fixes seem to work

@mcoevert
Copy link

I also had this issue and asked about it on the Swift forums. The cause is trying to link against an older Swift runtime while targeting a newer version of the OS.

You should be able to just remove those LIBRARY_SEARCH_PATH entries entirely (or just leave $(inherited)) and that will fix the problem. This is a bug in the ReactNative template for iOS.

As mentioned in the above Swift forums thread:

You shouldn't need to add the toolchain library paths to LIBRARY_SEARCH_PATHS yourself, because Xcode will automatically include those libraries if your minimum deployment target is old enough to need them.

👆 This is the real fix

@anhtuank7c
Copy link

@mcoevert true. I just remove those LIBRARY_SEARCH_PATH entries completely, it'll fix the problem

@NathanNovak
Copy link

I use the following method to solve the problem

LIBRARY_SEARCH_PATHS = (
   "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
-  "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"",
+  "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.2/$(PLATFORM_NAME)\"",
   "\"$(inherited)\"",
 );

Thank You! This solved it! Holy S@#%!

@patrikmasiar
Copy link

I use the following method to solve the problem

LIBRARY_SEARCH_PATHS = (
   "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
-  "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"",
+  "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.2/$(PLATFORM_NAME)\"",
   "\"$(inherited)\"",
 );

Works well! Thank you 🙏

@facebook facebook locked as resolved and limited conversation to collaborators Oct 1, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests