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

"Library Not Found" error with just OCMock & Xcode 7.3 #291

Closed
Nomad00 opened this issue Mar 28, 2016 · 4 comments
Closed

"Library Not Found" error with just OCMock & Xcode 7.3 #291

Nomad00 opened this issue Mar 28, 2016 · 4 comments

Comments

@Nomad00
Copy link

Nomad00 commented Mar 28, 2016

Report

What did you do?

Upgraded to Xcode 7.3.
Created empty new empty project.
Ran pod init (Using CocoaPods 1.0.0-beta 5)
Added OCMock to podfile for LibraryNotFoundDemoTests target.
NOTE: KIF also exhibits the issue.
Executed pod install
Executed test target on device.

What did you expected to happen?

Test target execute on device.

What happened instead?

Test target failed to execute.

Failed to load test bundle from file:///private/var/containers/Bundle/Application/.../LibraryNotFoundDemo.app/PlugIns/LibraryNotFoundDemoTests.xctest: Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/var/containers/Bundle/Application/.../LibraryNotFoundDemo.app/PlugIns/LibraryNotFoundDemoTests.xctest/LibraryNotFoundDemoTests): Library not loaded: @rpath/OCMock.framework/OCMock

Podfile

# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!

target 'LibraryNotFoundDemo' do

end

target 'LibraryNotFoundDemoTests' do
# Issue occurs with either of these Pods.
#   pod 'KIF', '~> 3.3.0'
  pod 'OCMock','~> 3.2.2'
end

# Uncomment this if using `KIF`
# post_install do |installer|
#   installer.pods_project.targets.each do |target|
#     target.build_configurations.each do |config|
#       config.build_settings['ENABLE_BITCODE'] = 'NO'
#     end
#   end
# end

Sample Project

@erikdoe
Copy link
Owner

erikdoe commented Mar 28, 2016

Given that this problem occurs with other frameworks, too, wouldn't it be more likely be an issue with Cocoapods? I also note that you are using a beta version of Cocoapods.

In either case, I looked at the demo project. It seems like Cocoapods tries to use a dynamic framework for OCMock (and not an older-style static library). The binary that contains the tests is located in

Debug-iphoneos/LibraryNotFoundDemo.app/PlugIns/LibraryNotFoundDemoTests.xctest/LibraryNotFoundDemoTests

and the OCMock binary ends up in

Debug-iphoneos/OCMock/OCMock.framework/OCMock

To be honest, I don't know why Cocoapods puts the OCMock framework into this location, but given that OCMock is built as a a run-path dependent library (see https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html) it is definitely possible for this work. If Cocoapods sets up a runpath, e.g. @loader_path/../../../OCMock in this case, then it would be possible to find the binary. Obviosuly, this is not the case, but I'm not enough of a Cocoapods expert to debug it.

I'll leave this issue open for a while, in the hope that someone with more Cocoapods experience has a suggestions. It is definitely not a bug in OCMock, though.

@Nomad00
Copy link
Author

Nomad00 commented Mar 28, 2016

Upon some further experimentation, it does appear this issue is with CocoaPods. It is occurring whenever a Pod is within a Test target and not in the main target. Opened an issue there.

Thank you for your comment & leaving this open for a bit - may be helpful if other users are experiencing the same issue.

What is specifically interesting about this issue is if I include OCMock within the main target of the Podfile, then it works as it did before Xcode 7.3. Not a great workaround, but is something.

@Nomad00
Copy link
Author

Nomad00 commented Mar 29, 2016

Closing this as it is apparent it is either a CocoaPods issue or potentially Xcode.

@Nomad00 Nomad00 closed this as completed Mar 29, 2016
@vovkasm
Copy link

vovkasm commented Jun 28, 2016

I'am experienced this issue without CocoaPods, so it is unrelated. With OCMock.framework added to "UnitTests" target I got this errors:

2016-06-28 10:56:31.740 MyApp[84918:2895619] Failed to load test bundle from file:///Users/vovkasm/Library/Developer/Xcode/DerivedData/MyApp-amomkiuqjqonxyeytxdxigurvlbx/Build/Products/Debug-iphonesimulator/MyApp.app/PlugIns/UnitTests.xctest/../UnitTests.xctest/: Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/Users/vovkasm/Library/Developer/Xcode/DerivedData/MyApp-amomkiuqjqonxyeytxdxigurvlbx/Build/Products/Debug-iphonesimulator/MyApp.app/PlugIns/UnitTests.xctest/UnitTests): Library not loaded: @rpath/OCMock.framework/OCMock
  Referenced from: /Users/vovkasm/Library/Developer/Xcode/DerivedData/MyApp-amomkiuqjqonxyeytxdxigurvlbx/Build/Products/Debug-iphonesimulator/MyApp.app/PlugIns/UnitTests.xctest/UnitTests
  Reason: image not found" UserInfo={NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Users/vovkasm/Library/Developer/Xcode/DerivedData/MyApp-amomkiuqjqonxyeytxdxigurvlbx/Build/Products/Debug-iphonesimulator/MyApp.app/PlugIns/UnitTests.xctest/UnitTests, NSDebugDescription=dlopen_preflight(/Users/vovkasm/Library/Developer/Xcode/DerivedData/MyApp-amomkiuqjqonxyeytxdxigurvlbx/Build/Products/Debug-iphonesimulator/MyApp.app/PlugIns/UnitTests.xctest/UnitTests): Library not loaded: @rpath/OCMock.framework/OCMock

I'am resolve this by adding static library instead of "iOS Framework" from ocmock-3.3.dmg.

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

3 participants