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

test runtime error: Failed to load test bundle … Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib #8318

Closed
js opened this issue Nov 30, 2018 · 14 comments

Comments

@js
Copy link

js commented Nov 30, 2018

Report

Dynamic linker errors during runtime of XCTest bundle

What did you do?

  • Created a new Xcode 10.1 project from the "single view" template
  • pod init
  • Added a dependency to the test target & pod install
  • build and run normal build successfully
  • unittest bundle fails at runtime with
Failed to load test bundle from file:///Users/johan/Library/Developer/Xcode/DerivedData/Podtest3-gxhjknkxpvtkjfcnjwaactlgrgig/Build/Products/Debug-iphonesimulator/Podtest3.app/PlugIns/Podtest3Tests.xctest/: Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/Users/johan/Library/Developer/Xcode/DerivedData/Podtest3-gxhjknkxpvtkjfcnjwaactlgrgig/Build/Products/Debug-iphonesimulator/Podtest3.app/PlugIns/Podtest3Tests.xctest/Podtest3Tests): Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib
  Referenced from: /Users/johan/Library/Developer/Xcode/DerivedData/Podtest3-gxhjknkxpvtkjfcnjwaactlgrgig/Build/Products/Debug-iphonesimulator/Podtest3.app/PlugIns/Podtest3Tests.xctest/Frameworks/Nimble.framework/Nimble
  Reason: image not found" UserInfo={NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Users/johan/Library/Developer/Xcode/DerivedData/Podtest3-gxhjknkxpvtkjfcnjwaactlgrgig/Build/Products/Debug-iphonesimulator/Podtest3.app/PlugIns/Podtest3Tests.xctest/Podtest3Tests, NSDebugDescription=dlopen_preflight(/Users/johan/Library/Developer/Xcode/DerivedData/Podtest3-gxhjknkxpvtkjfcnjwaactlgrgig/Build/Products/Debug-iphonesimulator/Podtest3.app/PlugIns/Podtest3Tests.xctest/Podtest3Tests): Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib
  Referenced from: /Users/johan/Library/Developer/Xcode/DerivedData/Podtest3-gxhjknkxpvtkjfcnjwaactlgrgig/Build/Products/Debug-iphonesimulator/Podtest3.app/PlugIns/Podtest3Tests.xctest/Frameworks/Nimble.framework/Nimble
  Reason: image not found, NSBundlePath=/Users/johan/Library/Developer/Xcode/DerivedData/Podtest3-gxhjknkxpvtkjfcnjwaactlgrgig/Build/Products/Debug-iphonesimulator/Podtest3.app/PlugIns/Podtest3Tests.xctest, NSLocalizedDescription=The bundle “Podtest3Tests” couldn’t be loaded because it is damaged or missing necessary resources.}

What did you expect to happen?

unit tests continues to run successfully even after adding a test target dependency with cocoapods

What happened instead?

dynamic linker errors at runtime with no other changes than adding the pod

CocoaPods Environment

Please note that this is reproducible on both 1.5.3, and master@8d244a7c

Stack

   CocoaPods : 1.6.0.beta.2
        Ruby : ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
    RubyGems : 2.6.14
        Host : Mac OS X 10.14.1 (18B75)
       Xcode : 10.1 (10B61)
         Git : git version 2.17.2 (Apple Git-113)
Ruby lib dir : /Users/johan/.rvm/rubies/ruby-2.4.1/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 9d8fcd946e320c680b4d5c71903fb5510099abc8

Installation Source

Executable Path: /Users/johan/temp/CocoaPods/bin/pod

Plugins

claide-plugins         : 0.9.2
cocoapods-deintegrate  : 1.0.2
cocoapods-dependencies : 1.0.0.beta.1
cocoapods-plugins      : 1.0.0
cocoapods-search       : 1.0.0
cocoapods-stats        : 1.0.0
cocoapods-trunk        : 1.3.1
cocoapods-try          : 1.1.0
cocoapods_debug        : 0.1.0

Podfile

platform :ios, '10.0'

target 'Podtest3' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
  # Pods for Podtest3

  target 'Podtest3Tests' do
    inherit! :search_paths
    pod 'SnapshotTesting', :git => 'https://github.com/pointfreeco/swift-snapshot-testing.git', :commit => "c3ba842f"
  end

end

Project that demonstrates the issue

https://github.com/js/cocoapods-sample-dynamic-linker-xctest

@dnkoutso
Copy link
Contributor

Can you add a swift file ot your tests target?

@js
Copy link
Author

js commented Nov 30, 2018

@stephencelis
Copy link

stephencelis commented Dec 23, 2018

I've had another user file this issue directly with our repo:

pointfreeco/swift-snapshot-testing#151

Given a brand new iOS Single View app with a unit test target I've had fine luck with the following Podfile:

target 'MyAppTests' do
  pod 'SnapshotTesting', '~> 1.1'
end

But this Podfile breaks in the same manner described here:

target 'MyApp' do
  use_frameworks!
  target 'MyAppTests' do
    inherit! :search_paths
    pod 'SnapshotTesting', '~> 1.1'
  end
end

Something with the nesting, use_frameworks!, and inherit! :search_paths maybe?

Are we missing something in our Podspec? https://github.com/pointfreeco/swift-snapshot-testing/blob/21567920d976099106e5a8eb7ccedf8edea398f6/SnapshotTesting.podspec

stephencelis added a commit to pointfreeco/swift-snapshot-testing that referenced this issue Dec 23, 2018
This reverts commit 7c350f6.

SnapshotTesting appears to not be compatible with this style of Podfile:

CocoaPods/CocoaPods#8318

Let's go back to the old description for now.
szotyi pushed a commit to szotyi/swift-snapshot-testing that referenced this issue Jan 3, 2019
This reverts commit 7c350f6.

SnapshotTesting appears to not be compatible with this style of Podfile:

CocoaPods/CocoaPods#8318

Let's go back to the old description for now.
@drmarkpowell
Copy link

I find with a similar project that if I un-nest the project target and test target and only apply "use_frameworks!" to the project and not the tests, the tests will build and run.

For example (a new project built with pod lib create, modified thus):

platform :ios, '10.0'

def shared
  pod 'Foo', :path => '../'
end

target 'Foo_Example' do
  use_frameworks!
  shared
end

target 'Foo_Tests' do
  shared
  pod 'Quick', '~> 1'
  pod 'Nimble', '~> 7'
end

@dnkoutso
Copy link
Contributor

Thats normal because it builds dependencies as static libraries instead of dynamic frameworks.

I was able to reproduce the issue but I am unable to understand why swiftSwiftOnoneSupport is not copied over to the produced test bundle.

Right now I am leaning this is not a CocoaPods issue as CocoaPods only deals with lswiftSwiftOnoneSupport for test specs and not test targets like yours.

I do not want to close as I do not know 100% yet.

@dnkoutso
Copy link
Contributor

See this old issue http://www.openradar.appspot.com/34254691

@dnkoutso
Copy link
Contributor

Came up to this https://openradar.appspot.com/43701006

@dnkoutso
Copy link
Contributor

dnkoutso commented Jan 18, 2019

@js the only time I got it to compile is by setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to YES on both the test bundle and SnapshotTesting targets.

@dnkoutso
Copy link
Contributor

@js I think this is as far as I can go. Setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to NO doesnt make it work for both targets.

I honestly think this is an Xcode bug.

@dnkoutso dnkoutso added the s1:awaiting input Waiting for input from the original author label Jan 18, 2019
@amorde
Copy link
Member

amorde commented Jan 18, 2019

See also: #8172

Yes it appears to be an Xcode bug, and there was a PR to add this workaround to CocoaPods but I was hesitant to merge it since it may be fixed in a future release of Xcode

@stale stale bot removed the s1:awaiting input Waiting for input from the original author label Jan 18, 2019
@dnkoutso
Copy link
Contributor

Cool nice!

@dnkoutso
Copy link
Contributor

dnkoutso commented Feb 3, 2019

Alright good news this appears fixed in Xcode 10.2 Beta!

Probably an Xcode bug exacerbated by CocoaPods integration.

@js can you give it a try?

@stale
Copy link

stale bot commented Feb 10, 2019

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍

@stale stale bot closed this as completed Feb 10, 2019
@dnkoutso dnkoutso removed the s1:awaiting input Waiting for input from the original author label Mar 1, 2019
phantomdev99 pushed a commit to phantomdev99/swift-snapshot-testing that referenced this issue Dec 14, 2022
This reverts commit 7c350f6680cff5180a78a04ab30ac1c5cb565f1b.

SnapshotTesting appears to not be compatible with this style of Podfile:

CocoaPods/CocoaPods#8318

Let's go back to the old description for now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants