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

PathKit build fails through Carthage #5

Closed
Danappelxx opened this issue Oct 8, 2015 · 13 comments
Closed

PathKit build fails through Carthage #5

Danappelxx opened this issue Oct 8, 2015 · 13 comments

Comments

@Danappelxx
Copy link

Example:

$ cat Cartfile
github "kylef/PathKit"
$ carthage bootstrap
*** No Cartfile.resolved found, updating dependencies
*** Fetching PathKit
*** Checking out PathKit at "0.5.0"
*** xcodebuild output can be found in /var/folders/76/q9xfxg_s187bkp6gyxqqxw8r0000gn/T/carthage-xcodebuild.f9pQMQ.log
*** Building scheme "PathKit" in PathKit.xcworkspace

So carthage builds PathKit, which is great. However, the framework can't be used for whatever reason.

$ cat main.swift
import PathKit
print(Path.current)
$ ls Carthage/Build/Mac
PathKit.framework
$ swiftc main.swift -F Carthage/Build/Mac/
$ ./main
dyld: Library not loaded: @rpath/PathKit.framework/Versions/A/PathKit
  Referenced from: /Users/dan/Desktop/test/./main
  Reason: image not found
[1]    45284 trace trap  ./main

It works perfectly fine with other frameworks, for example Commander.

Thoughts?

@kylef
Copy link
Owner

kylef commented Oct 8, 2015

Does PathKit.framework get built into Carthage/Build/Mac/?

@Danappelxx
Copy link
Author

Yup - it's in the second code block (I edited my post right after I pressed submit).

@kylef
Copy link
Owner

kylef commented Oct 8, 2015

Just curious, can you try the following before running ./main:

$ install_name_tool -add_rpath "@executable_path/Carthage/Build/Mac/"  "main"

@Danappelxx
Copy link
Author

Huh... that worked. I've never heard of that command before. What does it do?

Output:

$ ./main
/Users/dan/Desktop/test

@kylef
Copy link
Owner

kylef commented Oct 8, 2015

I've written about it at https://github.com/kylef/Commander#installation

When you said it works perfectly for other frameworks, we're you doing this the exact same way? With swiftc?

@Danappelxx
Copy link
Author

Yup - take a look at the build script for MastCLI if you need an example.

@kylef
Copy link
Owner

kylef commented Oct 8, 2015

@Danappelxx I think MastCLI is only working because you haven't used any APIs from Commander only imported it.

Once you try using Commander, without the Commander framework available in the rpath it will not run too.

@Danappelxx
Copy link
Author

Src/main.swift uses Commander.

@kylef
Copy link
Owner

kylef commented Oct 8, 2015

Ah missed that file, was looking in src/Command.swift.

@Danappelxx
Copy link
Author

Hm... adding install_name_tool -add_rpath "@executable_path/Carthage/Build/Mac/" "bin/mast" to my setup script in MastCLI doesn't fix the PathKit issue I'm having. Would you happen to know why?

@kylef
Copy link
Owner

kylef commented Oct 8, 2015

@Danappelxx The rpath you've shown is relative to executable path, and Carthage isn't inside the bin directory.

Should become:

$ install_name_tool -add_rpath "@executable_path/../Carthage/Build/Mac/" "bin/mast"

@Danappelxx
Copy link
Author

Man, you really know your stuff - thanks!

@kylef
Copy link
Owner

kylef commented Oct 19, 2015

Going to close this since it looks like we've resolved the problem.

@kylef kylef closed this as completed Oct 19, 2015
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

2 participants