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

v0.5.0 fails on CircleCI #35

Closed
jschmid opened this issue Oct 15, 2015 · 9 comments
Closed

v0.5.0 fails on CircleCI #35

jschmid opened this issue Oct 15, 2015 · 9 comments

Comments

@jschmid
Copy link

jschmid commented Oct 15, 2015

I use SwiftGen in CircleCI to make sure developers do not forget to run swiftgen on their own dev machine before committing. (I run swiftgen and check if the files have been modified)

v0.4.4 worked fine but since v0.5.0 I get an error. I of course updated the command to run. It works fine on my machine.

swiftgen images MyImages.xcassets > MyImages.swift
dyld: Library not loaded: @rpath/libswiftAppKit.dylib
  Referenced from: /usr/local/bin/swiftgen
  Reason: image not found

I don't know what the changes are in v0.5.0 so I don't understand where the issue comes from. Hopefully you do 😉

@AliSoftware
Copy link
Collaborator

Version 0.5.0 use some third-party frameworks (like Commander to parse the command-line, and in future versions I'll also use other frameworks like Stencil to add template support, etc).

That's probably why you have that "Library not loaded" error, because the dynamic linker (dyld) can't find them.

How did you install the app in your CircleCI server?

  • Using homebrew?
  • Using rake install?
    • If using rake install, did you specify a specific destination or did you let it use the default destinations (which are /usr/local/bin for the binary and /usr/local/Frameworks for the third-party frameworks)?
  • Or did you simply compile it on Xcode.app (which would then explain it as this doesn't work due to some Xcode subtleties & bugs, that's why the installation instructions in the README explains you must use rake or homebrew)?
  • Or did you install in on your Mac and then copy the binary file from your machine over to CircleCI… but forgot to copy the frameworks too? (which then need to be in the same relative-path to the app than it was on your Mac installation then)

@jschmid
Copy link
Author

jschmid commented Oct 15, 2015

Thank you for your reply.

I am using Homebrew.

Would you like me to try other methods?

@AliSoftware
Copy link
Collaborator

So you ran Homebrew directly on the CircleCI VM, right?

Does your CircleCI have Xcode 7, if so what's its path?

I'd be interested to see the output of otool -L /usr/local/bin/swiftgen
and otool -l /usr/local/bin/swiftgen | grep -A 2 LC_RPATH

Also useful would be the output of your homebrew install swiftgen --verbose --debug on the CircleCI VM.

@jschmid
Copy link
Author

jschmid commented Oct 15, 2015

@AliSoftware
Copy link
Collaborator

Hmmm so when SwiftGen was built by Homebrew, it built it with /Applications/Xcode.app (or at least it used this path as the @rpath to find the Swift core libraries), but when you try to run it, that path doesn't exist on the CircleCI VM.

That's probably because Homebrew built a bottle (pre-built binary that their CI build on its own and package in a tar.gz to avoid the need for you to build it yourself on the machine you're installing it to).
So the swiftgen version you have was build by Homebrew servers where their Xcode is at /Applications/Xcode.app… but on your CircleCI VM this path probably doesn't exist.

One quick way to solve it yourself is to add the path to Xcode (the one path on CircleCI I mean) to swiftgen's @rpath so SwiftGen can find the Swift binaries before invoking it.
Something probably similar to this:

rpath=$(dirname "$(dirname "$(xcrun -find swiftc)")")/lib/swift/macosx
install_name_tool -add_rpath "$rpath" "$(which swiftgen)"

I'll try to find a way to some this in the homebrew Formula so that the homebrew installation would automatically fix it after installing the bottle, if it can be done, but in the meantime that could allow you to workaround the issue.

@jschmid
Copy link
Author

jschmid commented Oct 15, 2015

Thanks for the thorough answer.
I have a few days off now. I'll let you know when I get back and try it.
Thanks!

On Thu, Oct 15, 2015, 21:43 AliSoftware notifications@github.com wrote:

Hmmm so when SwiftGen was built by Homebrew, it built it with
/Applications/Xcode.app (or at least it used this path as the @rpath to
find the Swift core libraries), but when you try to run it, that path
doesn't exist on the CircleCI VM.

That's probably because Homebrew built a bottle (pre-built binary that
their CI build on its own and package in a tar.gz to avoid the need for
you to build it yourself on the machine you're installing it to).
So the swiftgen version you have was build by Homebrew servers where
their Xcode is at /Applications/Xcode.app… but on your CircleCI VM this
path probably doesn't exist.

One quick way to solve it yourself is to add the path to Xcode (the one
path on CircleCI I mean) to swiftgen's @rpath so SwiftGen can find the
Swift binaries before invoking it.
Something probably similar to this:

rpath=$(dirname "$(dirname "$(xcrun -find swiftc)")")/lib/swift/macosx
install_name_tool -add_rpath "$rpath" "$(which swiftgen)"```�I'll try to find a way to some this in the homebrew Formula so that the homebrew installation would automatically fix it after installing the bottle, if it can be done, but in the meantime that could allow you to workaround the issue.


Reply to this email directly or view it on GitHub
#35 (comment)
.

@AliSoftware
Copy link
Collaborator

This should be fixed once Homebrew/legacy-homebrew#45008 is merged by the Homebrew team.

I'm gonna close this issue now that a fix is pending release — but feel free to reopen in case it still doesn't work on your CircleCI even after the fix is merged.

@jschmid
Copy link
Author

jschmid commented Oct 20, 2015

The build passes now. Thanks! 👍

@AliSoftware
Copy link
Collaborator

Thx for the feedback 👍

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

2 participants