xchammer icon indicating copy to clipboard operation
xchammer copied to clipboard

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

Open acecilia opened this issue 4 years ago • 11 comments

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 avatar Oct 03 '19 20:10 acecilia

I'm seeing the same error.

mpalczew avatar Oct 20 '19 22:10 mpalczew

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.

yuriy-yarosh avatar Oct 26 '19 06:10 yuriy-yarosh

@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 ;)

acecilia avatar Oct 28 '19 01:10 acecilia

@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 avatar Oct 28 '19 06:10 rahul-malik

@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

rahul-malik avatar Oct 28 '19 06:10 rahul-malik

@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.

acecilia avatar Oct 28 '19 14:10 acecilia

@rahul-malik thanks.

yuriy-yarosh avatar Oct 28 '19 14:10 yuriy-yarosh

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

mpalczew avatar Oct 31 '19 19:10 mpalczew

@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

acecilia avatar Oct 31 '19 20:10 acecilia

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

mpalczew avatar Nov 03 '19 18:11 mpalczew

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?

WilliamIzzo83 avatar Nov 03 '20 14:11 WilliamIzzo83