SolvedCocoaPods Bug with Unit Tests on Mojave: "The bundle couldn’t be loaded because it is damaged or missing necessary resources"


Since I upgraded to macOS Mojave, I can't run unit test of modules including cocoapods. Please check the sample app to understand/reproduce.

What did you do?

  • Download sample project at
  • Unzip
  • In CLI, go to the project directory and run pod install
  • Open the UnitTestIssue.xcworkspace file with Xcode 10 on macOS Mojave
  • Run unit tests on App scheme

The sample project is a workspace composed by an iOS application target (App) and a framework (AppModule) imported by the app. Both target includes RxSwift (as example) through CocoaPods.

What did you expect to happen?

AppTests is executed and all its tests correctly pass
AppModuleTests is executed and all its tests correctly pass

What happened instead?

AppTests is executed and all its tests correctly pass
AppModuleTests is not executed and the console displays the following error:

2018-09-27 16:49:34.580550+0200 xctest[3033:761430] The bundle AppModuleTests couldnt be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2018-09-27 16:49:34.580849+0200 xctest[3033:761430] (dlopen_preflight(/Users/jeromealves/Library/Developer/Xcode/DerivedData/UnitTestIssue-akzscdcjjahzpmdxkzgmyhdxntrl/Build/Products/Debug-iphonesimulator/AppModuleTests.xctest/AppModuleTests): Library not loaded: @rpath/RxSwift.framework/RxSwift
  Referenced from: /Users/jeromealves/Library/Developer/Xcode/DerivedData/UnitTestIssue-akzscdcjjahzpmdxkzgmyhdxntrl/Build/Products/Debug-iphonesimulator/AppModuleTests.xctest/AppModuleTests
  Reason: image not found)
Program ended with exit code: 82

CocoaPods Environment


   CocoaPods : 1.6.0.beta.1
        Ruby : ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
    RubyGems :
        Host : Mac OS X 10.14 (18A391)
       Xcode : 10.0 (10A254a)
         Git : git version 2.15.1
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib
Repositories : master - @ 69dd9cd4156aa6343da3ad63c150897bc30fa7da

Installation Source

Executable Path: /usr/local/bin/pod


cocoapods-deintegrate : 1.0.2
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


source ''
platform :ios, '11.0'


workspace 'UnitTestIssue.xcworkspace'

def podsRx
    pod 'RxSwift', '~> 4.0'

target :AppModule do
    project 'AppModule/AppModule.xcodeproj'
    target :AppModuleTests do
        inherit! :search_paths

target :App do
    project 'App/App.xcodeproj'
    target :AppTests do
        inherit! :search_paths

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ENABLE_BITCODE'] = 'NO'

Project that demonstrates the issue


  • In sample project podfile, comment line podsRx under target :AppModule do
  • run pod install again
  • run unit tests again
    → Now everything works fine and all tests are executed. This makes me thank that the issue is somewhat related to CocoaPods.
36 Answers

✔️Accepted Answer

i was able to workaround this by reverting to the legacy build system for now, to get the UI tests running again. This might not be desirable if you need some feature from the new build system.

You can switch it by going to File > Workspace Settings... and under Shared Workspace Settings set Build System to Legacy Build System. There are per-user settings there but I haven't messed with those yet.

Other Answers:

Change to:

target :AppModule do
    project 'AppModule/AppModule.xcodeproj'
    target :AppModuleTests

Worked for me.

The problem is that target :AppModuleTests do do not have an app host and you are using inherit! :search_paths. This means that this target would find the dependencies to load them from the host but in this case there is none.

@mgrebenets we set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to YES only in Debug mode, and that helps the app size not get bloated. Our workaround is

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            # This works around a unit test issue introduced in Xcode 10.
            # We only apply it to the Debug configuration to avoid bloating the app size
            if == "Debug" && defined?(target.product_type) && target.product_type == ""
                config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = "YES"

I also submitted the PR referenced above to have CocoaPods do this for us

I've been seeing very similar issues (XCode 10.0 & 10.1; macOS 10.13.6; CocoaPods 1.6.0.beta.2).

Above given post-install hook did not solve the issue. In fact, I'm seeing


in Pods/Targets Support Files/Pods-TestTarget/Pods-TestTarget.debug.xcconfig so I'm not sure what it does effect.

What did work was removing nested blocks from Podfile. Bug?

Related Issues:

CocoaPods [error report] pod install /w m1 macbook
do you have a MacBook Pro with a M1 processor? this fixed my issue: Report What did you do? Run pod ...
CocoaPods NoMethodError - undefined method `size' for nil:NilClass
Also faced with this issue Fixed by updating flutter and cocoa pods to the latest version and then ...
CocoaPods pod install has bug
Did you try: sudo arch -x86_64 gem install ffi And run: arch -x86_64 pod install instead of pod inst...
CocoaPods CocoaPods was not able to update the master repo
Looks like your specs repo was edited at some point and now git can't update it ...
CocoaPods CocoaPods compatibility with Apple DTK (Apple Silicon)
For anyone else struggling with this issue I just found a way to solve it In addition to running ter...
CocoaPods Build issue with Xcode 12.3 - file not found #include "ruby/config.h"
I just updated to Xcode 12.3 and I am hitting this issue Seems like Xcode 12.3 broke the system ruby...
CocoaPods Unzip fail when zip contains chinese char on macOS 10.13
Maybe replace unzip with ditto: I have a SDK and there is a folder named FaceDistortion_20171205雪天的雪...
CocoaPods None of your spec sources contain a spec satisfying the dependencies
Did you note this part of the error message: Note: as of CocoaPods 1.0 pod repo update does not happ...
CocoaPods pod install fails with json error on Mac OS X 10.15
I did rm -rf ~/.cocoapods/repos/trunk/ After that it worked again. I've read and understood the CONT...
CocoaPods No such file or directory @ rb_sysopen -- AppCenter -- ReactNative
So I updated my appcenter dependencies from v2.4.0 to v2.5.0 and I'm having this issue again 🙄 Edit...
CocoaPods App Icons not included in build from Xcode 9
I have the same problem Report What did you do? Run project on device from Xcode 9 Beta 6 What did y...
CocoaPods Intermittent CDN issues
The workaround to get working locally during this outage or CDN issue - guessing a DNS change or som...
CocoaPods new Macbook M1 crash
As a temporary fix I've installed cocoapods using sudo arch -arch x86_64 gem install cocoapods then ...
CocoaPods Support multiple Swift versions on a per pod basis
this works: It's not pretty but will do until they update your pods to Swift 4. ...
CocoaPods pod update error with CDN
And? How to fix? gem install concurrent-ruby or gem update concurrent-ruby. I've read and understood...
CocoaPods Failed to build gem native extension. Header file missing,
I had the same problem on macOS Mojave 10.14.16 A few threads eventually lead me here which solved i...
CocoaPods I can not install pod files.
Nope Just do: Install ffi sudo arch -x86_64 gem install ffi Re-install dependencies arch -x86_64 pod...
CocoaPods CocoaPods1.9.0 cannot install on Mojave10.14.6
This should be re-opened I can repro on a clean Mojave The workaround is to run sudo gem install coc...
CocoaPods [Xcode 8 beta 2]: CopySwiftLibs for Pods framework fails with Mach-O header error
I've found a workaround Add the following lines to your Podfile: 🌈 I've read and understood the *CO...
CocoaPods FBSDKLoginKit can not find headers under 1.0.0
This appears to be some issue between CocoaPods and XCode I tried to reproduce the problem I was see...
CocoaPods Podfile without use_frameworks! triggers "deployment target" warnings in Xcode 10
For those wanting a quick fix: edit: updated snippet now supports the new generate_multiple_pod_proj...
CocoaPods Resources installed using cocoapods not loaded for xctest bundle
For me I fixed it by setting Host Application to main target (In Test Target -> `General) ...
CocoaPods CDN: trunk Repo update failed - 2 error(s):
pod repo list 查看源列表 pod repo remove trunk 移除trunk源 只有移除掉问题才解决!!! 2019.11.07更 怕有人不懂,特意写了一篇文章 具体操作看下这篇...
CocoaPods [1.9.2] Error during pod install JSON::ParserError - 767: unexpected token
Running only sudo rm -rf ~/.cocoapods/repos and then pod install was enough for my case. ...
CocoaPods pod lib create fails: uninitialized constant Nanaimo::Reader::StringScanner (NameError)
gem uninstall nanaimo It will prompt you for which version to uninstall 👍 Before you start ...
CocoaPods pod install triggers pods to use Swift 4.2 in XCode 10
I was also facing the same problem and able to fix by adding swift_version in pre_install block Is t...
CocoaPods pod spec lint fails (Xcode 8 GM & Cocoapods 1.1.0.rc.1)
Got it working using the .swift-version file mentioned in #5841 For those who need help make a .swif...
CocoaPods undefined method `map' for nil:NilClass (NoMethodError) Did you mean? tap
ah gem update xcodeproj fixes the problem for me I've read and understood the CONTRIBUTING guideline...
CocoaPods error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
This seems like an issue with cloning the master repo Could be an issue with your connection or the ...
CocoaPods Malformed version number string
if your rubyGems version is 2.7.7 or higher you just can do like this gem update --system 2.7.6 my p...
CocoaPods Pod with swift 4.2 fails at linting
The podspec contains s.source_files = Constrictor/Constrictor/**/* which includes all files includin...
CocoaPods LoadError - cannot load such file -- macho
TBH I'm not familiar with ruby so this may be a terrible solution I tried with versions 1.5.0 and 1....
CocoaPods Modules not found in test targets
Thanks for the great ticket! So pods would be passed to a target by inheritance here but you're not ...
CocoaPods Duplicate symbols when framework target has a static dependency
I have a new version of the workaround It works when some static libraries are only used in the Appl...
CocoaPods UITests missing 📦 Embed Pods Frameworks build phase in 1.0.0.rc.1
Moving the UITests target outside of the main target in the Podfile seems to have helped So now inst...
CocoaPods Fails to install cocoapods on Ruby 2.4
Luckily cocoapods v1.0.1 still works Reproduction Detail CocoaPods has dependency in activesupport g...
CocoaPods Unit tests do not run on iOS 11 devices on Xcode 11 when using dynamically linked libraries
@dvataksi16 I got a response from Apple with a non-hacky solution: After reviewing your feedback we ...
CocoaPods 🐛 : Unable to install pods using custom build configurations
Just to leave a clear solution here Thankfully the solution is already merged to RN 0.63.3 ...
CocoaPods pod install: [!] Oh no, an error occurred.
This was what worked for me - arch -x86_64 pod install Report [!] Oh no an error occurred ...
CocoaPods Raise default macOS/iOS deployment target
The same is happening with iOS btw I've read and understood the CONTRIBUTING guidelines and have don...
CocoaPods Bug with Unit Tests on Mojave: "The bundle couldn’t be loaded because it is damaged or missing necessary resources"
i was able to workaround this by reverting to the legacy build system for now to get the UI tests ru...
CocoaPods pod search AFNetWorking
Can you try removing search_index.json and run search command again? I'd be happy if you send the ou...
CocoaPods Signing for requires a development team. Select a development team in the Target Editor. in Xcode 8 and Swift 3. 🌈
I know it's a bit self explanatory but to make the project actually build again select a Development...
CocoaPods Playgrounds regression between CocoaPods 1.4.0 and CocoaPods 1.5.0
@dnkoutso The workaround suggested above (@litmanenPL) does resolve the issue 🌈 I've read and under...
CocoaPods 'Pod Spec Lint' failed validation
Confirmed this is the same as #8116 This worked and I was able to lint successfully Please remove In...
CocoaPods Current CocoaPods should be installable on Mojave without dependency upgrades
Here's an annotated transcript of my console session reproducing the problem I've also discovered th...
CocoaPods Pushing spec fails with Xcode 10 GM
Run gem install cocoapods --pre to install beta version 1.6.0.beta.1 fixes the issue for me ...
CocoaPods RuntimeError - [Xcodeproj] Unknown object version.
you are on a very old version of cocoapods please update to latest version and also gem update xcode...