question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Xcode Build fails upon adding new target

See original GitHub issue

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

Upon adding a new target to a fresh react-native app (in my case an iOS 14 Widget). Xcode fails to build the app. With two errors:

  1. Undefined symbol: _swift_getOpaqueTypeConformance
  2. Undefined symbol: _swift_getTypeByMangledNameInContextInMetadataState

The latter error points to #29246. However the suggested fix did not help.

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)\"",
 );

_Originally posted by @hengkx in https://github.com/facebook/react-native/issues/29246#issuecomment-663986438_

Bumping the Swift version to 5.2 led to 23 further undefined symbol errors mostly of type FORCE_LOAD… eg: Undefined symbol: __swift_FORCE_LOAD_$_swiftObjectiveC

React Native version:

    OS: macOS 11.0
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
    Memory: 36.74 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.4.0 - ~/.nvm/versions/node/v14.4.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.5 - ~/.nvm/versions/node/v14.4.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.1, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6821437
    Xcode: 12.1/12A7403 - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: ~0.63.3 => 0.63.3 
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Instantiate a new react-native app: react-native init myProj
  2. In Xcode, file > new > target > Widget Extension
  3. Try to build app an observe described behaviour

Expected Results

The app should continue to build normally after adding a new target

Snack, code example, screenshot, or link to a repository:

n/a

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
doylemarkcommented, Nov 29, 2020

Resolved, solution is to make the following changes to the WidgetExtension target not project.

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)\"",
 );
2reactions
timothyaccommented, Dec 12, 2020

I might be missing it, but it doesn’t look my widget target has the LIBRARY_SEARCH_PATHS. I do see two in the settings, but one is for the debug version of the app target, and one is for the release version of the app target. Not sure if I’m doing something wrong when adding the widget to the project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Xcode build error after changing project target iOS major version
I am using Xcode 14.0.1, and testing on an iPhone 12 mini with IOS 16.0. My project target was IOS 14.0. I need...
Read more >
Adding new target in xcode causes compilation errors
After i added an identical new target with an old one I started getting some compilation errors like : Value of type 'UIView?'...
Read more >
Oh dear! Build errors? - LoopDocs - GitHub Pages
Solution: Go to your Xcode -> Preferences (or Settings) and under the Locations tab, select your Xcode version (the figure shows 14.0.1 -...
Read more >
[Solved]-Xcode - duplicate Target - new Target fails to build
I've always been able to get rid of this error by deleting the file in question and just recreating it. I have no...
Read more >
Managing different Environments using XCode Build ...
A testing target can add bunch of tests that you can run and project contains one or more target . They can depend...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found