# Undefined symbol \_swift\_getFunctionReplacement

**URL:** <https://forums.swift.org/t/undefined-symbol-swift-getfunctionreplacement/30495>\
**Category:** Using Swift\
**Created:** [November 5, 2019, 1:19pm UTC](https://forums.swift.org/t/undefined-symbol-swift-getfunctionreplacement/30495 "2019-11-05T13:19:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![beefon](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/beefon/32/13391_2.png) [@beefon](https://forums.swift.org/u/beefon)\
**Post date:** [November 5, 2019, 1:19pm UTC](https://forums.swift.org/t/undefined-symbol-swift-getfunctionreplacement/30495/1 "2019-11-05T13:19:12Z")

</div>

Hello,

We're struggling with building our app. We are updating to Xcode 11.1, and linker always fails with the error:

```swift
Undefined symbols for architecture x86_64:
  "_swift_getFunctionReplacement", referenced from:
      _swift_getFunctionReplacement50 in libswiftCompatibilityDynamicReplacements.a(DynamicReplaceable.cpp.o)

```

 ![image%20(1)](https://global.discourse-cdn.com/swift/original/2X/9/9fd13ccebfcaa6f98d92d220d093f2be51a73226.jpeg)

Apparently it implicitly adds `libswiftCompatibilityDynamicReplacements.a` to linker and that library needs these 2 functions (`_swift_getFunctionReplacement` and `_swift_getOrigOfReplaceable`) to be available, but for some reason they are missing.

Could you please provide any advice how to solve this issue?

---

<div class="post-metadata">

**Author:** ![suyashsrijan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/suyashsrijan/32/5292_2.png) [@suyashsrijan](https://forums.swift.org/u/suyashsrijan)\
**Post date:** [November 5, 2019, 8:19pm UTC](https://forums.swift.org/t/undefined-symbol-swift-getfunctionreplacement/30495/2 "2019-11-05T20:19:28Z")

</div>

> [@beefon](#):
>
> libswiftCompatibilityDynamicReplacements

Have you tried Xcode 11.2?

---

<div class="post-metadata">

**Author:** ![artyom-razinov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/artyom-razinov/32/19462_2.png) [@artyom-razinov](https://forums.swift.org/u/artyom-razinov)\
**Post date:** [November 6, 2019, 1:35am UTC](https://forums.swift.org/t/undefined-symbol-swift-getfunctionreplacement/30495/3 "2019-11-06T01:35:03Z")

</div>

I'm investigating the issue, my current guess is that we accidentally linked wrong dependencies to an application target (special app for internal use). They were dependencies for UnitTests and they themselves were dependent upon XCTest, which I think is not the exact cause of the problem. I can not say what is the root cause of the problem at the moment.

It somehow worked in Xcode 10 and stopped working in Xcode 11.1. Put this issue on hold.

---

<div class="post-metadata">

**Author:** ![artyom-razinov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/artyom-razinov/32/19462_2.png) [@artyom-razinov](https://forums.swift.org/u/artyom-razinov)\
**Post date:** [November 6, 2019, 8:28pm UTC](https://forums.swift.org/t/undefined-symbol-swift-getfunctionreplacement/30495/4 "2019-11-06T20:28:39Z")

</div>

The issue was caused by this line: `'LIBRARY_SEARCH_PATHS' => '$(TOOLCHAIN_DIR)/usr/lib/swift-$(SWIFT_VERSION)/$(PLATFORM_NAME) $(inherited)'` in a podspec of testing framework.

The line was added, because it was the only way to link with XCTest properly on Xcode 11. It is the only way I found on the internet so far and I was working on this problem for a long time.

It would be nice to know a better way to make a cocoapods pod that links with XCTest.

Example of pull request with fix: [Switch swift\_version to 5.0 and add LIBRARY\_SEARCH\_PATHS in xcconfig by artyom-razinov · Pull Request #315 · Brightify/Cuckoo · GitHub](https://github.com/Brightify/Cuckoo/pull/315) (this fixed linking in runtime if tests are built with Xcode 11).

Similar issue (making pod for testing): [RxTest referencing to invalid libswiftXCTest.dylib · Issue #2072 · ReactiveX/RxSwift · GitHub](https://github.com/ReactiveX/RxSwift/issues/2072)

---

<div class="post-metadata">

**Author:** ![beefon](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/beefon/32/13391_2.png) [@beefon](https://forums.swift.org/u/beefon)\
**Post date:** [November 7, 2019, 1:57pm UTC](https://forums.swift.org/t/undefined-symbol-swift-getfunctionreplacement/30495/5 "2019-11-07T13:57:07Z")

</div>

Yes, we've tried Xcode 11.2, same issue appears.

---

<div class="post-metadata">

**Author:** ![artyom-razinov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/artyom-razinov/32/19462_2.png) [@artyom-razinov](https://forums.swift.org/u/artyom-razinov)\
**Post date:** [November 7, 2019, 6:30pm UTC](https://forums.swift.org/t/undefined-symbol-swift-getfunctionreplacement/30495/6 "2019-11-07T18:30:50Z")

</div>

We also want to link with XCTAutomationSupport to use some really awesome private APIs for custom searching of elements (XCElementSnapshot) and many many more. I know it was a risky idea, but without it we wouldn't be able to get where we are now in UI testing.

---

<div class="post-metadata">

**Author:** ![artyom-razinov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/artyom-razinov/32/19462_2.png) [@artyom-razinov](https://forums.swift.org/u/artyom-razinov)\
**Post date:** [November 12, 2019, 4:55pm UTC](https://forums.swift.org/t/undefined-symbol-swift-getfunctionreplacement/30495/7 "2019-11-12T16:55:07Z")

</div>

The problem was solved by setting DEAD\_CODE\_STRIPPING to YES

---

<div class="post-metadata">

**Author:** ![HamGuy](https://avatars.discourse-cdn.com/v4/letter/h/898d66/32.png) [@HamGuy](https://forums.swift.org/u/HamGuy)\
**Post date:** [July 3, 2020, 7:31am UTC](https://forums.swift.org/t/undefined-symbol-swift-getfunctionreplacement/30495/8 "2020-07-03T07:31:11Z")

</div>

Not worked for me, same issue 😢
