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

Using xchammer after make install fails with the error 'Fatal error: Missing XCHammerAssets: file Sources/XCHammer/Generator.swift' #182

Open
acecilia opened this issue Oct 3, 2019 · 11 comments

Comments

@acecilia
Copy link
Contributor

acecilia commented Oct 3, 2019

Hello:

Using xchammer from /usr/local/bin after make install does not work. It fails with the following error:

'Fatal error: Missing XCHammerAssets: file Sources/XCHammer/Generator.swift, line 776'

I am running macOS Mojave 10.14.6 (18G103), and I have tried this with Xcode 10.3 and 11. I have tried commit f5fe4657eb751ababfa4ad5986afaa691910080f from xchammer (last one at master at the time of writing).

You can reproduce the issue by running the following script:

set -eou pipefail

# Clone XCHammer repository
tmp_dir=$(mktemp -d -t xchammer-XXXXXXXXXX)
git clone "https://github.com/pinterest/xchammer" "$tmp_dir"
cd "$tmp_dir"
git checkout f5fe4657eb751ababfa4ad5986afaa691910080f

# Clean previous installation if needed
rm -rf /usr/local/bin/xchammer
rm -rf /usr/local/bin/xchammer.app

# Install XCHammer
make install

# Patch the makefile, so instead of using the binary from the actual directory, use it from /usr/local/bin
sed -i '' 's/$(ROOT_DIR)\/$(PRODUCT)\/Contents\/MacOS\/XCHammer/xchammer/g' "Makefile"

# Run
make run # This fails with the error 'Fatal error: Missing XCHammerAssets: file Sources/XCHammer/Generator.swift, line 776'

If this is not working, how are you usually using xchammer in Pinterest?

Thanks!

@acecilia acecilia changed the title Using xchammer after make install fails with the error Fatal error: Missing XCHammerAssets: file Sources/XCHammer/Generator.swift Using xchammer after make install fails with the error 'Fatal error: Missing XCHammerAssets: file Sources/XCHammer/Generator.swift' Oct 3, 2019
@mpalczew
Copy link

I'm seeing the same error.

@yuriy-yarosh
Copy link

I've tried last year 0.2 release and it did work...
For some reason it seams that XCHammer is an old unsupported internal pinterest project.

@acecilia
Copy link
Contributor Author

@rahul-malik your feedback would be very much appreciated :)

PD: Also, did you manage to publish the part 2 of https://medium.com/pinterest-engineering/developing-fast-reliable-ios-builds-at-pinterest-part-one-cb1810407b92? I would like to know more about how you are using Bazel in Pinterest ;)

@rahul-malik
Copy link
Collaborator

rahul-malik commented Oct 28, 2019

@yuriy-yarosh - XCHammer is currently used by all developers at Pinterest. The docs should be updated ideally to how we've set it up internally. We also use HEAD so feel free to track upstream closely

@acecilia - Can you try the bazel instructions in https://github.com/pinterest/xchammer/blob/master/Docs/XCHammerFAQ.md ?

@rahul-malik
Copy link
Collaborator

@acecilia @yuriy-yarosh - I just tagged a new release for you to try. Please let me know if this works for you https://github.com/pinterest/xchammer/releases/tag/0.3

@acecilia
Copy link
Contributor Author

@rahul-malik thanks for your answer :) I had a look at the FAQ, but I can not make it work (I do not see any installation or setup instructions in the FAQ).

I run the script I attacked in the first comment of the issue, and I am still getting the same error: Fatal error: Missing XCHammerAssets: file Sources/XCHammer/Generator.swift, line 788:

set -eou pipefail

# Clone XCHammer repository
tmp_dir=$(mktemp -d -t xchammer-XXXXXXXXXX)
git clone "https://github.com/pinterest/xchammer" "$tmp_dir"
cd "$tmp_dir"
git checkout tags/0.3

# Clean previous installation if needed
rm -rf /usr/local/bin/xchammer
rm -rf /usr/local/bin/xchammer.app

# Install XCHammer
make install

# Patch the makefile, so instead of using the binary from the actual directory, use it from /usr/local/bin
sed -i '' 's/$(ROOT_DIR)\/$(PRODUCT)\/Contents\/MacOS\/XCHammer/xchammer/g' "Makefile"

# Run
make run # This fails with the error 'Fatal error: Missing XCHammerAssets: file Sources/XCHammer/Generator.swift, line 776'

I can not find information about how to install xchammer, only the indication on the readme about using make install, which is not working for me.

@yuriy-yarosh
Copy link

@rahul-malik thanks.

@mpalczew
Copy link

So I figured out the issue and a work around.
xchammer generate xchammer.yml fails
because it gets installed a symlink to /usr/local/bin
Which then looks for resources in /usr/local/bin

Workaround is
to call it directly
e.g.
/usr/local/bin/xchammer.app/Contents/MacOS/xchammer generate xchammer.yml

@acecilia
Copy link
Contributor Author

@mpalczew Yayyy that made it, thanks for the trick! Finally the following script works:

set -eou pipefail

# Clone XCHammer repository
tmp_dir=$(mktemp -d -t xchammer-XXXXXXXXXX)
git clone "https://github.com/pinterest/xchammer" "$tmp_dir"
cd "$tmp_dir"
git checkout tags/0.3

# Clean previous installation if needed
rm -rf /usr/local/bin/xchammer
rm -rf /usr/local/bin/xchammer.app

# Install XCHammer
make install

# Patch the makefile, so instead of using the binary from the actual directory, use it from /usr/local/bin
sed -i '' 's/$(ROOT_DIR)\/$(PRODUCT)\/Contents\/MacOS\/XCHammer/\/usr\/local\/bin\/xchammer.app\/Contents\/MacOS\/xchammer/g' "Makefile"

# Run
make run

@mpalczew
Copy link

mpalczew commented Nov 3, 2019

I don't have permission to push a new branch, otherwise I would have a PR.
Here's a patch.

diff --git a/Makefile b/Makefile
index bf78e98..de15594 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,8 @@ archive: build-release
 install: archive
        mkdir -p $(PREFIX)/bin
        ditto $(PRODUCT) $(PREFIX)/bin/$(PRODUCT)
-       ln -s $(PREFIX)/bin/$(PRODUCT)/Contents/MacOS/xchammer $(PREFIX)/bin/xchammer
+       echo '#!/bin/sh\n$(PREFIX)/bin/$(PRODUCT)/Contents/MacOS/xchammer $$@\n' > $(PREFIX)/bin/xchammer
+       chmod +x /usr/local/bin/xchammer

 uninstall:
        unlink $(PREFIX)/bin/xchammer

mokagio added a commit to mokagio/playground-bazel that referenced this issue Sep 17, 2020
@WilliamIzzo83
Copy link

As for #267 the problem is still there when generation is done with xcode_project rule. Does someone have a pointer to understand what is going on here?

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

5 participants