Cocoapods: Unable to see XCode/SwiftUI Previews within CocoaPods frameworks

Created on 20 Oct 2019  ·  52Comments  ·  Source: CocoaPods/CocoaPods

Report

What did you do?

Sample project https://github.com/jayayres/cocoapodsswiftuipreviewbugreport
git clone https://github.com/jayayres/cocoapodsswiftuipreviewbugreport.git
cd cocoapodsswiftuipreviewbugreport ; bundle install --binstubs ; bundle exec pod install
Open in Xcode 11.1, on Mac OS Catalina
Try using SwiftUI preview functionality for Pods/Development Pods/MyStaticPod/MyStaticPodSwiftUIView.swift , Pods/Development Pods/MyPod/MyDynamicPodSwiftUIView.swift, and MyPodTest/MyPodTest/MyMainAppSwiftUIView.swift

What did you expect to happen?

XCode previews should work for all 3 files.

What happened instead?

XCode previews always fail for MyStaticPodSwiftUIView.swift (which is set up with static_framework = true in its podspec) with:
noPreviewInfos(arch: "x86_64", sdkRoot: "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.1.sdk")

XCode previews fail most of the time for MyDynamicPodSwiftUIView.swift (unless a clean build is done, and that is the only dynamic pod in which previews are done, and previews are not done first for MyMainAppSwiftUIView.swift) with:
Xcode Previews rendering agent: Error Domain=com.apple.dt.UITestingAgent Code=-1 "failed to load library at path "~/DerivedData/MyPodTest-hcoikzfhpffncqcobtylgtykwvvb/Build/Intermediates.noindex/Previews/MyPodTest/Products/Debug-iphonesimulator/MyStaticPod/MyStaticPod.framework/MyStaticPod": Optional(dlopen(~/DerivedData/MyPodTest-hcoikzfhpffncqcobtylgtykwvvb/Build/Intermediates.noindex/Previews/MyPodTest/Products/Debug-iphonesimulator/MyStaticPod/MyStaticPod.framework/MyStaticPod, 0): no suitable image found

or sometimes:
MyPodTest.app: Error Domain=com.apple.dt.UITestingAgent Code=-1 "Preview provider "9MyPodTest32MyDynamicPodSwiftUIView_PreviewsV" does not exist" UserInfo={NSLocalizedDescription=Preview provider "9MyPodTest32MyDynamicPodSwiftUIView_PreviewsV" does not exist}

It looks like Xcode internally uses preview-thunk.dylib for previews. It appears that the preview functionality is not working at present within CocoaPods for either static or dynamic frameworks however.

CocoaPods Environment

   CocoaPods : 1.8.4
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
    RubyGems : 3.0.6
        Host : Mac OS X 10.15 (19A602)
       Xcode : 11.1 (11A1027)
         Git : git version 2.21.0 (Apple Git-122)
Ruby lib dir : /usr/local/var/rbenv/versions/2.6.3/lib
Repositories : cocoapods- - CDN - https://cdn.cocoapods.org/
               master - git - https://github.com/CocoaPods/Specs.git @ 7dd20d6b83719245167a244512860ef8b1ea5e99

Installation Source

Executable Path: ./bin/pod

Plugins

cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.4.1
cocoapods-try         : 1.1.0

Podfile

source 'https://cdn.cocoapods.org/'

platform :ios, 13.0

target 'MyPodTest' do
  use_frameworks!

  pod 'MyPod', path: 'lib/MyPod'
  pod 'MyStaticPod', path: 'lib/MyStaticPod'
end

Project that demonstrates the issue

https://github.com/jayayres/cocoapodsswiftuipreviewbugreport.git

help wanted

Most helpful comment

@dannypier Disabling code coverage works for me! Thanks!

All 52 comments

Have no idea here sorry.

I think Interface Builder doesn't work with static libs, does this work without setting static_framework = true?

It partially works with non-static libs. In the example at https://github.com/jayayres/cocoapodsswiftuipreviewbugreport , Pods/Development Pods/MyPod/MyDynamicPodSwiftUIView.swift is in a dynamic lib. If the first file previewed is in a dynamic lib, previews work in that one dynamic lib, but subsequently fail in the main app + other dynamic libs with the "failed to load library at path" error. If the first file previewed is in the main app, then subsequently previews fail in all dynamic libs.

So it entirely depends on which dynamic lib has the file which is previewed first.

So is this a cocoapods library issue?

I see. There's definitely some weirdness in this, unfortunately there isn't much documentation on how we are supposed to set things up here.

For example, I noticed that Bundle(for:) passing a class from a static lib does not return the main bundle when building for Xcode Previews - it returns a bundle pointing to an intermediate directory inside DerivedData. This can mess with resource loading if you rely on that bundle to manually load fonts.

It's possible there's something else we could do here but I'm not 100% sure at the moment what we would need to change to make this work more reliably

Edit: ~SwiftUI~ Xcode Previews

@dnkoutso it could be a CocoaPods issue but I'm not 100% sure. @jayresta if you link your dependencies natively in Xcode (without CocoaPods, and without the CocoaPods script phases) does it work as expected?

Xcode Previews now passes BUILT_PRODUCTS_DIR correctly as a DYLD_FRAMEWORK_PATH when rendering previews to allow you to reference and resolve built frameworks and other products. (53967108)

This is interesting, would love to see how this manifests. I haven't tried the 11.2 beta at all yet

I think I have a similar issue trying to use Xcode previews with UIKit. I got this error even on Xcode 11.2.1
failedToBuildDylib: ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/SharedFrameworks-iphonesimulator' Undefined symbols for architecture x86_64: "___llvm_profile_runtime", referenced from: ___llvm_profile_runtime_user in FirebaseABTesting(ABTConditionalUserPropertyController.o) ___llvm_profile_runtime_user in FirebaseABTesting(ExperimentPayload.pbobjc.o) ___llvm_profile_runtime_user in FirebaseABTesting(FIRExperimentController.o) ___llvm_profile_runtime_user in FirebaseABTesting(FirebaseABTesting-dummy.o) ___llvm_profile_runtime_user in FirebaseABTesting(FIRLifecycleEvents.o) ___llvm_profile_runtime_user in FirebaseCore(FIRAppAssociationRegistration.o) ___llvm_profile_runtime_user in FirebaseCore(FIRComponentType.o) ... (maybe you meant: ___llvm_profile_runtime_user) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I think this isn't a cocoapods issue, is from Xcode previews, looks like others are having similar problems with static frameworks that contains objective-c code see https://github.com/JetBrains/kotlin-native/issues/3059

Hi, I'm able to reproduce 100% of the times this problem, with any pod, statically or dynamically linked. I'm trying with Xcode 11.2, 11.2.1 and 11.3 beta, and if the iOS Framework has a SwiftUI and at least one Pod, the preview crashes even if the project is completely empty:
https://github.com/luizmb/SwiftUIPodsCrash

I just open a radar but maybe it could be some misconfiguration on the Pods project. It compiles correctly and runs correctly, only the SwiftUI Preview doesn't work.

Any ideas on how to debug this to understand better the problem?
Any help will be appreciated.

I would recommend attempting to embed the framework natively in Xcode to see if that fixes the issue. We can then try to narrow down what CocoaPods is doing differently

Thanks @amorde , I'm gonna try later today and share my findings. So far my workaround is creating the preview in any file that is in the Main App target, that works. But what's more interesting about this workaround is that, if I split the Xcode screen and open the View source code side-by-side to the preview running on main app, then it crashes again!

Hi @amorde,

I've added 2 branches to my repo:

  • Carthage (https://github.com/luizmb/SwiftUIPodsCrash/tree/Carthage) that uses Carthage to build externally the Frameworks and embedding using Xcode
  • Manual (https://github.com/luizmb/SwiftUIPodsCrash/tree/Manual) that adds RxSwift directly as a project in the same workspace and embed into my lib using Xcode framework.

Both work as expected, I even added some Rx logic to be sure the 3rd party is working.
With CocoaPods I still have the previews crash, unless the preview struct is in the main app.

Thank you! I'll try to look into this when I get the chance

Thanks for the support. From my side I'll try to understand better the issue when I have some time and will share here if I learn something.

@luizmb This is more of a workaround I guess but I had success by copying the required frameworks in a folder called Frameworks inside the Framework the SwiftUI View you want to preview is belonging to (e.g. LibWithUI in your case).
I looked at projects where the preview was working and by looking at the error messages.
Currently we run a script in the Build Phases to copy those Frameworks but I’m not sure if this is a setup step that’s missing from CocoaPods atm.
Screenshot 2019-11-21 at 10 24 33

Hi @nicerice

Thanks to your suggestion I managed to make preview work again. Very nice workaround.

I think I didn't follow exactly what you suggested, because my logs pointed me to a slightly different direction (in my real-world project, I mean). Probably because my DerivedData is located in a custom place (~/code/DerivedData) and the intermediates and builds are subfolders of it.

So in my case, logs pointed me to:
/Users/my.user/code/DerivedData/Build/Intermediates.noindex/Previews/MyProject/Products/Debug-iphonesimulator

Which is my custom Intermediates folder + "/Previews/MyProject/Products/Debug-iphonesimulator"

From there I open MyViewLib.framework/Frameworks and noticed that only some frameworks were there, basically only the ones I use Xcode to link.

Initially I tried to copy Pods_MyViewLib.framework into this folder, but that didn't help. So, instead, I copied all the dependencies that should be there, individually:

From:
/Users/my.user/code/DerivedData/Build/Intermediates.noindex/Previews/MyProject/Products/Debug-iphonesimulator/RxSwift/RxSwift.framework

To:
/Users/my.user/code/DerivedData/Build/Intermediates.noindex/Previews/MyProject/Products/Debug-iphonesimulator/MyViewLib.framework/Frameworks/

And the SwiftUI Preview started working immediately. As you suggested, I'm gonna try to automate this process in my build phases.

Thanks again for the help!

Same issue, can also confirm placing the framework in another Frameworks folder fixed the Previews for me as well.

Any luck in automating this?

Hi @cltnschlosser

For now I am using a Xcode Build Phase of type run script, and running this:

cp -R "$BUILT_PRODUCTS_DIR/SwiftRex/SwiftRex.framework" "$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH"
cp -R "$BUILT_PRODUCTS_DIR/CombineRex/CombineRex.framework" "$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH"
cp -R "$BUILT_PRODUCTS_DIR/RxSwift/RxSwift.framework" "$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH"
cp -R "$BUILT_PRODUCTS_DIR/RxBluetoothKit/RxBluetoothKit.framework" "$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH"

Not super elegant but it's what I could come up with in a few minutes.

One interesting thing that I found during writing this script, and it could be the root cause of this problem, is that "Build" and "Build for SwiftUI Preview" are two distinct things, and ALL environment variables are different, including the "/Previews" part between "Intermediates" and "PRODUCT_NAME".

My assumption is that the Embed Pods Framework phase has some hardcoded path that's not working for the Previews because it's assuming the path incorrectly. I'm not familiar with CocoaPods source code but I can try to find something.

${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH} It's being installed here, from "${BUILT_PRODUCTS_DIR}/Apollo/Apollo.framework". Looks like TARGET_BUILD_DIR needs to be replaced with BUILT_PRODUCTS_DIR when doing a preview build.

Because the env vars are different when building for preview, I believe there should be a way to write this script that works regardless if it's build or preview. I didn't have time to check the Ruby code you sent me, but I'm gonna try when I have some time.

Hmm, it looks like the embed frameworks script only runs for the app itself, and we need the frameworks copied to the correct folders for the frameworks.

Anyone know if there are any mechanisms in cocoapods now to add script phases to the framework targets?

You can add script phases both from Podfile and in podspecs. See podspec here https://guides.cocoapods.org/syntax/podspec.html#script_phases.

Right, I was thinking internally in the cocoapods tool itself, but I'll check out how that works, should be similar. I think we need a script like the Embed Frameworks script, but that runs for every pod framework. Script will look similar to the one here. I think we should be able to just simlink and not copy though.

What seems to work for Previews in frameworks is adding the pod built product paths ($(BUILT_PRODUCTS_DIR)/YourFramework) to LD_RUNPATH_SEARCH_PATHS, without needing scripts to copy frameworks over.

Here is a temporary workaround that seems working well — it overrides AggregateTargetSettings, adds more linker search paths for Previews to pick the pods up, and thus does not require manual framework copying.

// in Podfile

class Pod::Target::BuildSettings::AggregateTargetSettings
    BUILT_PRODUCTS_DIR_VARIABLE = "${BUILT_PRODUCTS_DIR}"

    alias_method :ld_runpath_search_paths_original, :ld_runpath_search_paths

    def ld_runpath_search_paths
        ld_runpath_search_paths_original + custom_ld_paths + [BUILT_PRODUCTS_DIR_VARIABLE]
    end

    def custom_ld_paths
        return [] unless configuration_name == "Debug"
        target.pod_targets.map do |pod|
            BUILT_PRODUCTS_DIR_VARIABLE + "/" + pod.product_basename
        end
    end
end

Hmm doesn't seem to be working for me. Looks like it's not picking up transitive dependencies.

So I have lib A, which depends on pod B. I have example app for lib A. When I'm in the example app previews don't work because it complains that pod B isn't loaded.

Library not loaded: @rpath/B.framework/B
| Referenced from: /.../DerivedData/A-hash/Build/Intermediates.noindex/Previews/A-Example/Products/Debug-iphonesimulator/A/A.framework/A

EDIT: If I open the example app for lib B, then previews work fine.

Okay got it working for transitive dependencies too. Extended what @andersio posted:

class Pod::Target::BuildSettings::AggregateTargetSettings
    BUILT_PRODUCTS_DIR_VARIABLE = "${BUILT_PRODUCTS_DIR}"

    alias_method :ld_runpath_search_paths_original, :ld_runpath_search_paths

    def ld_runpath_search_paths
        ld_runpath_search_paths_original + custom_ld_paths + [BUILT_PRODUCTS_DIR_VARIABLE]
    end

    def custom_ld_paths
        return [] unless configuration_name == "Debug"
        target.pod_targets.map do |pod|
            BUILT_PRODUCTS_DIR_VARIABLE + "/" + pod.product_basename
        end
    end
end

class Pod::Target::BuildSettings::PodTargetSettings
    BUILT_PRODUCTS_DIR_VARIABLE = "${BUILT_PRODUCTS_DIR}"

    alias_method :ld_runpath_search_paths_original, :ld_runpath_search_paths

    def ld_runpath_search_paths
        if ld_runpath_search_paths_original
            ld_runpath_search_paths_original + custom_ld_paths + [BUILT_PRODUCTS_DIR_VARIABLE]
        else
            # May just want to not return in this case
            custom_ld_paths + [BUILT_PRODUCTS_DIR_VARIABLE]
        end
    end

    def custom_ld_paths
        target.dependent_targets.map do |pod|
            BUILT_PRODUCTS_DIR_VARIABLE + "/../" + pod.product_basename
        end
    end
end

The new part is class Pod::Target::BuildSettings::PodTargetSettings. I removed the configuration check because there is no configuration_name here. There is @configuration, but it was nil in my case.
Also BUILT_PRODUCTS_DIR_VARIABLE + "/../" + pod.product_basename is kinda a big hack because of the directory traversal, but BUILT_PRODUCTS_DIR_VARIABLE for the pods is the pod folder themselves. Ex: /DerivedData/A-hash/Build/Intermediates.noindex/Previews/A-Example/Products/Debug-iphonesimulator/A, so by default it was looking for B in /DerivedData/A-hash/Build/Intermediates.noindex/Previews/A-Example/Products/Debug-iphonesimulator/A/B.framework/B, but it's actually in /DerivedData/A-hash/Build/Intermediates.noindex/Previews/A-Example/Products/Debug-iphonesimulator/B/B.framework/B

EDIT: It doesn’t seem to be perfect though, not sure why, but once you start previewing in one target, you need to do a clean to get previews in other targets to work. May be an xcode issue. So as long as you don’t constantly switch between targets you are previewing then it’s fine. (Example: Start looking at previews in pod A. It works, can switch between files in pod A, etc. If you want to preview files in pod B, then you need to clean build folder and click try again. Now you are soft-locked to pod B, until the next clean build where you can choose a different target.)

Posting this here since this was the only helpful post I came across in searching for a solution. I'm not using Cocoapods in my project, but the underlying issue appears to be the same.

My project is modularized into many separate static libraries. When I want to work with SwiftUI previews in a particular UI module I temporarily change that module from library.static to framework. (This is necessary because SwiftUI previews does not work from Views defined in static libraries.)

This strategy worked until recently, when I added Realm to my project (as a framework). I found that any UI module that depended on another framework (transitively or directly), was failing with “Library not loaded: @rpath/OtherFramework.framework/OtherFramework”.

Simply adding $(BUILT_PRODUCTS_DIR) to LD_RUNPATH_SEARCH_PATHS in my UI module did the trick. Thanks to @andersio for this comment: https://github.com/CocoaPods/CocoaPods/issues/9275#issuecomment-566281575

I've updated @cltnschlosser's/@andersio's fix to work with transitive dependencies (ie. pod A depends on pod B which depends on pod C) as the previous fix wasn't working in that scenario. This makes use of FRAMEWORK_SEARCH_PATHS which Xcode uses to look for frameworks and adds those to @rpath.

class Pod::Target::BuildSettings::AggregateTargetSettings
    alias_method :ld_runpath_search_paths_original, :ld_runpath_search_paths

    def ld_runpath_search_paths
        return ld_runpath_search_paths_original unless configuration_name == "Debug"
        return ld_runpath_search_paths_original + framework_search_paths
    end
end

class Pod::Target::BuildSettings::PodTargetSettings
    alias_method :ld_runpath_search_paths_original, :ld_runpath_search_paths

    def ld_runpath_search_paths
        return (ld_runpath_search_paths_original || []) + framework_search_paths
    end
end

On Xcode 11.3 I've been able to get SwiftUI Previews building by simply disabling Code Coverage gathering for my scheme. The above solutions weren't working as I was still getting "failedToBuildDylib" errors for Firebase. In fact, the above fixes don't seem to be necessary at all, at least on my case. Hope this helps someone.

Credits to: https://twitter.com/dannypier/status/1190312160557068293 🙏

Oh, hey! Was hoping that tweet would come in handy at some point. Thanks for the credit @p4checo.

I minimized the pain a bit by creating a duplicate target without code coverage that I use while doing UI development and keep the target with code coverage for my logic and CI tests. Not ideal, but it's not much of a day to day pain.

@p4checo @dannypier I'm afraid the error you mentioned is a different one. In the sample project reproducing this error here there's no code coverage at all.
Please check here:
https://github.com/luizmb/SwiftUIPodsCrash

Go to LibWithUI folder and try to preview SwiftUIView.swift.

You will notice that all schemes have "gather code coverage" disabled. The other solutions here seem to work for me.

For what you reported, I believe a Radar would be great because it really sounds a Xcode issue.

Oh, hey! Was hoping that tweet would come in handy at some point. Thanks for the credit @p4checo.

I'm the one that must be thanking you, @dannypier! 🙇 I had also spent a couple of hours ripping my hairs off trying to understand why it didn't work.

I minimized the pain a bit by creating a duplicate target without code coverage that I use while doing UI development and keep the target with code coverage for my logic and CI tests. Not ideal, but it's not much of a day to day pain.

Yeah, that sounds quite sensible. Happily for us we already had a bunch of targets just for running tests, so it was relatively straightforward to just disable code coverage on our main one.

@luizmb I'm really sorry that this "fix" didn't solve it for your case, however if the other solutions fixed your issue, that's great! I simply mentioned this alternative "fix" here so that others could find it on this thread, where more people are likely to land with similar problems.

Life's good on the cutting edge, right? 😆🔪

As for the Radar/FB, I can try to open one but Apple will most likely ask for a test project and unfortunately at this moment I can't afford the time to make one that replicates it.

@dannypier Disabling code coverage works for me! Thanks!

If, like me, you're not well versed in ruby and tried the workarounds above but on running pod install you got: NoMethodError - undefined method+' for nil:NilClass`

You should wrap the items you're adding in (${possibly_nil} || []), so for @cltnschlosser's answer, the line that is:

ld_runpath_search_paths_original + custom_ld_paths + [BUILT_PRODUCTS_DIR_VARIABLE]

would become:

(ld_runpath_search_paths_original || []) + (custom_ld_paths || []) + [BUILT_PRODUCTS_DIR_VARIABLE]

Once I did that, pod install stopped erroring and the previews appeared as expected.

I have a dev pod where I am using a framework and whenever I link the framework in the dev pod, my swiftUI previews break. If I remove the framework from the podspec, the previews work again.

In my podspec:

s.vendored_frameworks = 'SomeFramework.framework'

Is this the same issue?

Hello,
was this ever addressed in the cocoapods sources?

On Xcode 11.3 I've been able to get SwiftUI Previews building by simply disabling Code Coverage gathering for my scheme. The above solutions weren't working as I was still getting "failedToBuildDylib" errors for Firebase. In fact, the above fixes don't seem to be necessary at all, at least on my case. Hope this helps someone.

Credits to: https://twitter.com/dannypier/status/1190312160557068293 🙏

Xcode : Version 11.4.1 (11E503a)
This worked for me also.

Would appreciate someone open a PR here with the proposed fix and a test. This is a long issue thread and its hard to follow which answer is the right one.

I used Gemfile for cocoapods and Ruby 2.6.4p104. so I had this problem.
I changed to not use Gemfile and use Ruby 2.5.1p57.

then

$ pod install

I resolve this problem.

This is diff.

--- a/.ruby-version
+++ b/.ruby-version
@@ -1 +1 @@
-2.6.4
+2.5.1
diff --git a/Gemfile b/Gemfile
index 8b0c454..0cdb6dd 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,5 +5,5 @@ source "https://rubygems.org"
 git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

 gem "fastlane"
-gem "cocoapods"
+# gem "cocoapods"

diff --git a/Podfile.lock b/Podfile.lock
index a000b61..54110b9 100644
--- a/Podfile.lock
+++ b/Podfile.lock
@@ -114,4 +114,4 @@ SPEC CHECKSUMS:

 PODFILE CHECKSUM: 7c9dc03baafc5241ee84a5cc678cec1deda775a7

-COCOAPODS: 1.9.3
+COCOAPODS: 1.9.0

can someone verify with Xcode 12 Beta 5? https://twitter.com/NeoNacho/status/1295793181871599616

can someone verify with Xcode 12 Beta 5? https://twitter.com/NeoNacho/status/1295793181871599616

Unfortunately still happens for us (Firebase) using Xcode 12 beta 6, workaround of disabling code coverage still works. Repro steps for us: https://github.com/firebase/firebase-ios-sdk/issues/6219#issuecomment-683896871

Tried running a preview that depends on AsyncDisplaykit (Texture pod) with Xcode 12 beta 6 the following workaround 👍

class Pod::Target::BuildSettings::AggregateTargetSettings
    alias_method :ld_runpath_search_paths_original, :ld_runpath_search_paths

    def ld_runpath_search_paths
        return ld_runpath_search_paths_original unless configuration_name == "Debug"
        return ld_runpath_search_paths_original + framework_search_paths
    end
end

class Pod::Target::BuildSettings::PodTargetSettings
    alias_method :ld_runpath_search_paths_original, :ld_runpath_search_paths

    def ld_runpath_search_paths
        return (ld_runpath_search_paths_original || []) + framework_search_paths
    end
end

RemoteHumanReadableError: Failed to update preview.

The preview process appears to have crashed.

Error encountered when sending 'previewInstances' message to agent.

==================================

| RemoteHumanReadableError: The operation couldn’t be completed. (BSServiceConnectionErrorDomain error 3.)
|
| BSServiceConnectionErrorDomain (3):
| ==BSErrorCodeDescription: OperationFailed

I tried disabling code coverage and that didn't work as well.

also crashes in Xcode 11.6

I'm having this issue with Xcode 12 Beta 6. Didn't succeed with the workaround posted by @mycroftcanner / @jameshurst but it's possible that I'm doing something wrong here. Code coverage seems already disabled (maybe from earlier Podfile configuration) so workaround from @dannypier (hi!) can't work for me either.

Hello!

Based on @jameshurst and @kerrmarin, I fixed my issue with this code in my Podfile:

class Pod::Target::BuildSettings::AggregateTargetSettings
    alias_method :ld_runpath_search_paths_original, :ld_runpath_search_paths

    def ld_runpath_search_paths
        return ld_runpath_search_paths_original unless configuration_name == "Debug"
        return (ld_runpath_search_paths_original || []) + (framework_search_paths || [])
    end
end

class Pod::Target::BuildSettings::PodTargetSettings
    alias_method :ld_runpath_search_paths_original, :ld_runpath_search_paths

    def ld_runpath_search_paths
        return (ld_runpath_search_paths_original || []) + (framework_search_paths || [])
    end
end

It removes all errors about Error Domain=com.apple.dt.UITestingAgent Code=-1 "failed to load library at path…

Then, as I was using Firebase, I found in the crash logs that it also doesn't run the ApplicationDelegate methods and so I also missed the configuration of my FirebaseApp.

So I needed to add also a manual configuration in my preview code like this:

let options = FirebaseOptions(googleAppID: "my_id_from_ GoogleService-Info.plist file", gcmSenderID: "my_id_from_ GoogleService-Info.plist file")
FirebaseApp.configure(options: options)

BTW, I'm using Xcode 11.7

linker command failed with exit code 1 (use -v to see invocation)


LinkDylibError: Failed to build SignUpView.swift

Linking failed: linker command failed with exit code 1 (use -v to see invocation)

ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/SharedFrameworks-iphonesimulator'
Undefined symbols for architecture x86_64:
"___llvm_profile_runtime", referenced from:
___llvm_profile_runtime_user in Pods_MyProject(Pods-MyProject-dummy.o)
(maybe you meant: ___llvm_profile_runtime_user)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I dont know why or how but the first answer here fixed this issue

I dont know why or how but the first answer here fixed this issue

The problem is caused by Code Coverage being enabled. Above StackOverflow contains a fix. Thank you!

Was this page helpful?
0 / 5 - 0 ratings