how to fix the issue "Command /bin/sh failed with exit code 1" in iphone
Asked Answered
C

21

94

I used a cocoa static library in my application. When I compile my library I got the following error:

Shell Script invocation error:can't open input file:
/Users/sijuthomas/Library/Developer/Xcode/DerivedData/SCXML2-
    bbttehupryhijphhjdiemcytkvgy/Build/Products/Debug-iphonesimulator/
    libSCXMLParser.a (No such file or directory)
Command /bin/sh failed with exit code 1

Screenshot for error

How can I fix this?

Chlorophyll answered 22/10, 2012 at 7:7 Comment(0)
W
212

 Target -> Build-Phases -> update examples

Click On Run checkbox if not selected.

Wariness answered 23/3, 2015 at 13:10 Comment(7)
This checkbox might be under Build Phases → Bundle React Native code and images.Reformed
for me this works when building/installing app on phone but not when archivingOverscrupulous
This answer is correct.but when set mode Generc iOS Device for getting build fr all ... get the errr again @WarinessHampstead
@Hampstead make sure you have clear data as well as delete derived data. then try again.Wariness
@Wariness Works while building but not for archivingMuskogee
I don't even have update examples menu as in above image.Licentious
@Muskogee same issue with me worked while building but not while archiving. Have you found any solution to that?Translative
C
64

I had this issue because i denied keychain access and in order to solve it you need to open keychain, Then click on the lock on top right of the screen to lock it again, after that you can archive and it will work

Cota answered 28/12, 2017 at 13:28 Comment(3)
THANK YOU SO MUCH! Btw, at least for me the lock is in the left side. It was open and had to close it.Ortensia
I shared this solution from a source that i don't remember unfortunately.Cota
I got exit code 134 when try to archive the product , but I could install the app to device, I have open the keychain but could you find the lock any where, my Xcode version 9.2, really need helpImpressure
K
43

Deleting "Derived Data" worked for me.

In Xcode go to File > Workspace Settings > Click the arrow next to the Derived Data file path > move the "Derived Data" folder to the trash.

Kerrikerrie answered 25/8, 2015 at 20:17 Comment(4)
What Xcode version are you referring to ?... I don't have the menu/windows or options you are referring to in Xcode 6.2Peggy
its in windows->Organizer not Windows ProjectsPeggy
it works but needed to clean project and restart Xcode for meWillms
File->Workspace Settings...->Derived Data. Click arrow at the end of path. Right click on folder and move to trash. iOS 10.12.6Sharonsharona
P
30

Seems you are running a shell script and it can't find your specific file. Look at Target -> Build-Phases -> RunScript if you are running a script.

You can check if a script is running in your build output (in the navigator panel). If your script does something wrong, the build-phase will stop.

Phylloxera answered 22/10, 2012 at 7:22 Comment(1)
SKM i have edited my answer. Maybe its Xcode who has created this script in order to find your static library. By the way it's not compiling because it can't find the file at /Users/sijuthomas/Library/Developer/Xcode/DerivedData/SCXML2-bbttehupryhijphhjdiemcytkvgy/Build/Products/Debug-iphonesimulator/libSCXMLParser.a. So make sure to include it therePhylloxera
P
20

I had same issue got it fixed. Use below steps to resolve issue in Xcode 6.4.

  1. Click on Show project navigator in Navigator window
  2. Now Select project immediately below navigator window
  3. Select Targets
  4. Select Build Phases tab
  5. Open Run Script drop-down option
  6. Select Run script only when installing checkbox

Screenshot for steps

Now, clean your project (cmd+shift+k) and build your project.

Primacy answered 23/7, 2015 at 12:21 Comment(1)
This should be the accepted answer. To a problem bin/sh this is the solution.Felicitasfelicitate
S
9

Cleaning the build folder (Cmd + Shift + Alt + K) worked for me

Scandura answered 7/6, 2016 at 22:54 Comment(0)
G
3

1) Delete the pod folder and .xcworkspace file 2) Open the folder in terminal 3) Type "pod install"

Guddle answered 27/7, 2018 at 8:49 Comment(0)
C
1

Did you add the .a library to the xcode projet ? (project -> build phases -> Link binary with libraries -> click on the '+' -> click 'add other' -> choose your library)

And maybe the library is not compatible with the simulator, did you try to compile for iDevice (not simulator) ?

(I've already fight with the second problem, I got a library that was not working with the simulator but with a real device it compiles...)

Carefree answered 22/10, 2012 at 7:14 Comment(0)
S
1

In My case there was space in the path that was failing the script.If you are using variables like $PROJECT_DIR or $TARGET_BUILD_DIR then replace them "$PROJECT_DIR" or "$TARGET_BUILD_DIR" respectively.After adding quotes my script ran successfully.

Supra answered 28/6, 2016 at 9:24 Comment(1)
In my case, I have space and capitalize words in my folder name. I removed all space and capitalize words and now it's working. +1Backspace
I
1

For me, my certificate is expired. I have created a new certificate.

Irrefrangible answered 25/10, 2017 at 19:8 Comment(0)
H
1

I did all above and spent an hour on the issue.

Tried everything above as well as restarted Xcode.

Finally, restarted computer and everything working normally again!

Helbonna answered 4/1, 2018 at 17:55 Comment(2)
you have not added anything to this post with the answer. Restarting computer can be a comment as it does not help explain what was wrong.Fax
Some weird issue, deleted derived data and switched/unswitched new build system. But after a restart i was ok!Seasonseasonable
W
0

I tried restarting Xcode (7) and nothing (the have you tried switching it off and on again of iOS development for me :-)). I then tried by restarting my box and that worked.

In my case the script was failing when copying a file from a location to another one. I think it could have been related to Finder screwing with writing rights over certain folders.

Waldowaldon answered 10/11, 2015 at 10:21 Comment(0)
S
0

For me this error was occuring because I changed the version number from 1 to 1.0 and build number from 6 to 1.1 as I pulled the code from source tree. I just changed it back and changed the build number from 6 to 7and it worked fine.

Saintmihiel answered 20/4, 2016 at 7:22 Comment(0)
E
0

just put your script in a file and run that file with 2>/dev/null at the end of command line!

This way, if there is a problem with the command whatsoever, it will not halt your xcode build

in my case I was running just a command to uninstall my previous copy of the app from a connected iphone, so it could give an error if the iphone is not there. To solve it:

$mobiledevice uninstall_app com.my.app 2>/dev/null

Eiderdown answered 9/4, 2017 at 10:21 Comment(0)
I
0

The only thing worked for me:

1) Delete Derived Data with CleanMyMac: System Junk -> Xcode Junk -> Xcode Derived Data

Deleting Derived Data with CleanMyMac

2) Then in Xcode: Product -> Clean

Ibarra answered 9/12, 2017 at 15:55 Comment(0)
A
0

I'll list things I did that did not work for me and finally what did

First, the accepted answer of Run script only when installing did not work.

Deleting derived data did not work.

What did work:

  1. I added a new build phase in Build Phases

  2. New Copy Files Phase

  3. Drag & Drop the chosen framework into the drop target

  4. Set the 'Destination' to Frameworks

Credit due to Kevin Le's Medium post

Assorted answered 12/2, 2018 at 20:53 Comment(0)
A
0

For those who doesn't want to uncheck that option (using cocoapods for example), the problem might be with the certificate/key.

Xcode (or whatever tool you are using, like a command line tool) needs to be able to use the certificate/key from the keychain. For this open the Keychain, locate the certificate that you want to use (Usually on login keychain, My Certificates), right click on the key, select Get Info, click on Access Control tab and add the app to the list.

If this doesn't work, try unlocking the keychain.

Another option can be select Allow all applications to access this item instead of specific apps and/or move the certificate/key to System keychain which is shared between all the user accounts on that Mac.

Also check that the certificate is not expired.

Azilian answered 2/3, 2018 at 7:13 Comment(0)
A
0

1) option : Please check run the script only when installing......  it is right to answer of this question

2) option : pod update, clean derive data,

Archenteron answered 31/12, 2018 at 19:24 Comment(0)
Y
0

In my case, one of the script (related to SwiftGen) was failing during compilation.

I fixed the issue by removing the Pods and then updating them again.

  1. Remove the problematic pod under Pods directory or use pod deintegrate
  2. Install / Update the pods using pod install or pod update

P.S. It is possible your dependency is Global and is not in pods. In that case you can also try to reinstall that dependency.

Yale answered 24/6, 2020 at 14:17 Comment(0)
U
0

READ THIS IF YOU USE Crashlytics AND ARE HAVING THIS ISSUE...

I was having the same issue as above Command /bin/sh failed with exit code 1 more specifically [31merror: Could not fetch upload-symbols settings: An unknown error occurred fetching settings.[0m

The first solution (enabling the run script only when installing) allowed me to build my target in the simulator, but I could not archive my build.

I solved this Archive issue by enabling Crashlytics on firebase. I am still used to Fabric where Crashlytics is automatically enabled. Once I enabled Crashlytics in the firebase console for the corresponding GoogleService-Info.plist I was able to Archive without this error.

Undertook answered 22/7, 2020 at 15:54 Comment(0)
M
-1

Remove all pods and install again.

Steps:

  1. comment all pods and run pod install
  2. uncomment all pods and run pod install
Moonseed answered 13/12, 2017 at 11:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.