Carthage: copy-frameworks build phase fails with Carthage 0.12

Created on 1 Feb 2016  Â·  16Comments  Â·  Source: Carthage/Carthage

Installing from pkg attached to release.

Build fails in the Run Script Phase /usr/local/bin/carthage copy-frameworks with Unrecognized arguments, presumably since Commandant introduced error handling for unused/unrecognized args.

If I reinstall 0.11 the build passes. I'll try and debug this more when I have some free time but in the meantime is there any additional information I can provide to help figure this out?

question

Most helpful comment

@dcaunt @askielboe You both are incorrectly setting up the “Run Script” phase. Please do as the following screenshot:

2016-02-02 22 25 26

All 16 comments

I can't reproduce it. Did you previously install carthage by homebrew? If so, running brew uninstall carthage would help?

I have been installing from the pkg for the last few versions and brew says it's not installed. I even tried removing Carthage by deleting /Library/Frameworks/CarthageKit.framework and /usr/local/bin/carthage before re-installing 0.12.

Is there a way to see the invocation of copy-frameworks without doing a custom build of Carthage?

I can verify this error as well with 0.12.

I do install carthage via homebrew and running brew uninstall carthage before upgrading did not seem to help.

Reverted to 0.11 and build passes as stated by dcaunt.

Still haven't figured this out yet, but my colleague tried with the same project and 0.12 works on their machine.

I think this has to do with how carthage 0.12 parses command line arguments.

Seems like the problem is that shell scripts in xcode are called with a shebang #!, which passes the path of the script as an argument to carthage.

Not knowing what to do with the path, carthage fails with Unrecognized arguments.

Seems like the problem is that shell scripts in xcode are called with a shebang #!, which passes the path of the script as an argument to carthage.

I'm not sure what you are saying about. What is the contents of your script of the Run Script phase and the entire error message carthage outputs?

The contents of the temporary script Script.sh is:

#!/usr/local/bin/carthage copy-frameworks

The error I get when I run it using sh -c ./Script.sh is:

Unrecognized arguments: "./Script.sh"

Prior to v0.12 I would instead get as output (if run outside Xcode):

Environment variable not set: SCRIPT_INPUT_FILE_COUNT

My point is that #! in Script.sh passes the path of the script as an argument to carthage. You can verify this by putting the following line in a Script.sh file:

#!/bin/echo the-first-argument

Running this with sh -c ./Script.sh prints:

the-first-argument ./Script.sh

Hope that makes sense.

To avoid any confusion, here's my build phase and the error output:

copy-frameworks build phase

Output:

Unrecognized arguments: "/Users/dc/Library/Developer/Xcode/DerivedData/YYY-dcnkpwkqfacmtmadeqpkpqmijqhn/Build/Intermediates/YYY.build/Debug-iphoneos/YYY.build/Script-BFB6FF9C1C5F6F1D00053132.sh"
Command /bin/sh failed with exit code 1

Yes, I too have put in the build script in the same way as @dcaunt (and as suggested in https://github.com/Carthage/Carthage/blob/master/README.md).

The shebang is added by Xcode automatically when it generates the temporary build script (Script-SOME-RANDOM-HASH.sh).

I guess it's related to this change in Commandant: https://github.com/Carthage/Commandant/pull/40

@dcaunt @askielboe You both are incorrectly setting up the “Run Script” phase. Please do as the following screenshot:

2016-02-02 22 25 26

Ah! Interesting. Thanks @ikesyo, and sorry for the confusion.

I see! Thanks for looking at this, @ikesyo. Given that at least three of us had the same problem, perhaps the README could be more explicit. I'll open a PR if you like.

Can we pass the argument as command line .... Example: /usr/local/bin/carthage copy-frameworks $(SRCROOT)/QUICK.framework

We want to decide at the build time how many frameworks should be added to the ipa.

This is very problematic.

I tried the suggestion from @ikesyo

It worked OK.

When I went to archive my app for the app store, the build fails. Presumably because the "run script only when installing" doesn't apply.

It's a serious enough blocker.

I notice that I get an error when I run:

/bin/sh -c /Users/eamorr/Library/Developer/Xcode/DerivedData/MyApp-awsbthrqbootgybbroycqgdqmajw/Build/Intermediates/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/Script-66CCC4C31AA43B72002794F7.sh

But don't get an error when I run without the -c switch:

/bin/sh /Users/eamorr/Library/Developer/Xcode/DerivedData/MyApp-awsbthrqbootgybbroycqgdqmajw/Build/Intermediates/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/Script-66CCC4C31AA43B72002794F7.sh

Restarting the mac helped me,not the xcode.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

itinance picture itinance  Â·  3Comments

3lvis picture 3lvis  Â·  3Comments

faustperic picture faustperic  Â·  3Comments

JustinJiaDev picture JustinJiaDev  Â·  3Comments

chrislconover picture chrislconover  Â·  3Comments