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

Getting "Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib" error #399

Closed
1 task done
nandin-borjigin opened this issue Feb 20, 2017 · 6 comments
Closed
1 task done

Comments

@nandin-borjigin
Copy link

nandin-borjigin commented Feb 20, 2017

  • I have read CONTRIBUTING and have done my best to follow them.

What did you do?

I created a new workspace & a project then added Nimble as git submodule and subproject for the workspace. Then added Nimble.framework(Nimble-iOS) to Build Phases of test target. Afterwards I added some really simple code to use Nimble (import Nimble on the top and expect(1 + 1) == 2 in the test method). Then I got error message when command + U to run test.

What did you expect to happen?

The test should run properly.

What actually happened instead?

Got error message below when trying to run test:

2017-02-20 23:41:29.482 xctest[52165:616190] The bundle “MainProjTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2017-02-20 23:41:29.483 xctest[52165:616190] (dlopen_preflight(/Users/nandiin/Library/Developer/Xcode/DerivedData/NimbleIssue-fkhppktoktwpjodtarmzrjobszwv/Build/Products/Debug-iphonesimulator/MainProjTests.xctest/MainProjTests): Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib
  Referenced from: /Users/nandiin/Library/Developer/Xcode/DerivedData/NimbleIssue-fkhppktoktwpjodtarmzrjobszwv/Build/Products/Debug-iphonesimulator/Nimble.framework/Nimble
  Reason: image not found)
Program ended with exit code: 82

Environment

List the software versions you're using:

  • Quick: not using
  • Nimble: git SHA 16a9a31
  • Xcode Version: 8.2.1 (8C1002)
  • Swift Version: Xcode Default

Please also mention which package manager you used and its version. Delete the
other package managers in this list:

I used git submodule.

Project that demonstrates the issue

https://github.com/nandiin/NimbleIssue

Notes

I have tried this kinda "creating new project and adding Nimble via git submodule" steps at least seven or eight times on different macs, and the problem occurred every time. Sometimes removing Nimble.framework from Build Phases and re-adding it will temporarily fix the problem ( One thing I noticed is under some circumstance re-adding Nimble.framwork will make workspace settings to refer Nimble from some absolute path under DerivedData instead of relative path ../Vendor/Nimble/build/Debug-iphoneos/Nimble.framework. But it happens somehow randomly and I failed to reproduce it again. And I consider that kind of absolute path referring as incorrect setting because it can't be shared via VCS).

@nandin-borjigin
Copy link
Author

I've also tried Embed Asset Packs In Product Bundle=YES and Always Embed Swift StandardLibrary=YES for both main target and test target. Still failed to wok.

@jeffh
Copy link
Member

jeffh commented Feb 21, 2017

Hey @Nandiin,

Thanks for filing an issue. I cloned your repo and saw the issue you were talking about. But I manually re-added the Nimble.framework under MainProjTests > Build Phases > Link Binary With Libraries by:

  • deleting the existing reference to Nimble.framework
  • clicking the + in that section
  • select Nimble-iOS and click Add
  • Re-run tests

I don't know how you've configured Xcode, but ../Vendor/Nimble/build/Debug-iphoneos/Nimble.framework sounds vaguely custom relative build directory for derived data, but I don't have that build folder showing. The project's currently path for Nimble.framework is incorrect and should be referencing inside derived data.

@nandin-borjigin
Copy link
Author

nandin-borjigin commented Feb 21, 2017

I may say the Xcode I'm using is almost under "default" configuration since I've just re-installed my OS X (with full disk erasing) and Xcode. I'd never changed the derived data location.

Give the project structure like:

NimbleIssue/
   |- MainProj/
        |- MainProj.xcodeproj  
   |- NimbleIssue.xcworkspace
   |- Vendor/
        |- Nimble/

manually adding Nimble-iOS to the build phases of test target would result in ../Vendor/Nimble/build/Debug-iphoneos/Nimble.framework. That build folder doesn't exist on my machine as well, but Xcode seems to have somehow managed to find the Nimble.framework according to the error message

Referenced from: /Users/nandiin/Library/Developer/Xcode/DerivedData/NimbleIssue-fkhppktoktwpjodtarmzrjobszwv/Build/Products/Debug-iphonesimulator/Nimble.framework/Nimble

My understanding: Xcode found Nimble.framework at this long and fancy derived data path(I didn't changed the location, again) and at some point it failed to find a library libswiftSwiftOnoneSupport which is referenced from Nimble.framework.

@jeffh
Copy link
Member

jeffh commented Feb 22, 2017

The path /Users/nandiin/Library/Developer/Xcode/DerivedData/NimbleIssue-fkhppktoktwpjodtarmzrjobszwv/Build/Products/Debug-iphonesimulator/Nimble.framework/Nimble is the final destination of the resulting framework. The basic process Xcode is going through is this:

  • Build Nimble.framework <-- either build or derived data dir (?)
  • Build MainProj <-- probably derived data dir
  • Build MainProjTests <-- derived data dir
  • Copy MainProj product to MainProjTests <-- derived data dir
  • Copy Nimble.framework product to MainProjTests location in derived data <-- derived data dir
  • Run MainProjTests

I'm not sure what you mean by manually adding, could you break down the steps you did? When I add it through the steps I previously describe I get a path that looks like this:

screen shot 2017-02-21 at 7 21 28 pm

Also, what is the path of the built Nimble.framework product? You can see them from the build output, near the end of the build process for the framework:

screen shot 2017-02-21 at 7 19 35 pm

It seems like only the final framework was added linked to the project, which doesn't tell Xcode that one project depends on the result of another.

@nandin-borjigin
Copy link
Author

By "manually adding", I mean the same steps you took.

It's really odd, on my mac, the path in red rounded rectangle is ../Vendor/Nimble/build/Debug-iphoneos/Nimble.framework. And another difference I noticed is the icon of the Nimble.framework in the Link Binary with Libraries panel is a white box on my mac instead of yellow briefcase like yours.

I noted the steps I took in the README.md of the repo.


I know that sometimes re-adding the Nimble.framework would change the reference directory and all things would work after then. But for me, it's somehow random. A project which is happy on my company's mac may fail after pulling it on my own mac at home, and re-adding Nimble.framework works sometimes. For now, I suppose there might be some asynchronous work happening at the build time and there is a chance that one may end up with ../Vendor/Nimble/build/Debug-iphoneos/Nimble.framework.

@ikesyo
Copy link
Member

ikesyo commented Jul 7, 2018

It's obvious that this is not a Nimble issue so closing.

@ikesyo ikesyo closed this as completed Jul 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants