XCode performs custom behavior .sh script failed with The operation couldn’t be completed,Exec format error - xcode

As you can see near the screenshot Logs infos pic, the .sh Script can run normal inside terminal, but failed to run via Xcode custom behavior, Is there missing some configuration? I've Googled a lot of infos. still can't solve it. I really need someone's help. Thanks
XCode version: Version 8.3.2 (8E2002)

Add a New Run Script Phase in your projects Build Phases to run a Shell script. You do not need to open -a Terminal:
Update:
How I understand your comment, your actual question is how to get the Xcode project directory. Xcode provides a enviromental variable for this, ${PROJECT_DIR}:
prints:
You can find a list of Xcodes enviromental variables in this repo and helpful information in Apples documentation.

Related

Problem trying to run Flutter on any IDE on macOS

I recently got the idea to try out flutter and found particularly difficult to implement it on my macOS (intel).
I have well updated my path, I could run flutter doctor nicely.
Flutter doctor -v
The problem resides in setting up the IDE, I tried both VScode and IntelliJ IDEA.
And I got the same result both time.
env: bash issue
When trying to create a project, there is no issue recognizing the path as shown on this picture
, the problem is brought up right after, when I click Create. It says that env: bash no such file or directory. What I don't understand is that I have a Zsh Shell, and I changed the setting on my IDE to use the /bin/zsh
But I still get a bash (my old SHELL) problem ?
I get the same problem on VScode.
If anyone has any help or information to provide, I would gladly accept it !
Thanks a lot.

How to get a Run Script phase to run first during compile in xcode?

In xcode 10.2, there is a run-script build phase. I have a script to copy a framework to a specific pod in DerivedData/somename-someguid/products/etc...
However, it seems that the script is not running first based on the print statements and it fails to find the file. If I manually copy the file there first, I can see the output of my script in the build log and it succeeds.
I tried dragging it up in the build-phase panel. I also tried adding it to the copy-file section, but copy does not understand how to embed with the correct pod.
Is there a way to specify the order of running these scripts? Is there a pre-everything section I don't know about?
Of course, it turns out I had the run script phase on the main app project instead of the pod project targets not realizing it built the pods first. So adding it there fixes it. Saving other noobs from this mistake by leaving the question up....

Run react native app on Xcode 10

I get this error when i want to run my react native app hello world app on Xcode 10 (new beta version), can you help me?
The error :
error: Build input file cannot be found:
'/Users/nic/Documents/X-Project/xapp/node_modules/react-native/Libraries/WebSocket/libfishhook.a'
Screen shot from my Xcode
This helped me:
Remove and add again libfishhook.a from Xcode and the path issue will resolve.
This issue is caught by the stricter xcode 10 new build system.
A temporary fix while react-native really fix the issue is to switch back to using the old build system
In Xcode, Select File -> Project/Workspace Setting. You will see a Build System option to select the Legacy Build System as shown below
Clear your project and "Derived Data" Build and Run your project
BONUS Point: If you are using a CI/CD pipeline you can also add the xcodebuild argument -UseNewBuildSystem='NO' to the cli or via fastlane xcargs: "-UseNewBuildSystem='NO'"
Manually copypasting libfishhook.a into the correct folder, as suggested here, worked for me:
For a solution, I copied the file from my ios/build/Build/Products/Debug-iphonesimulator/libfishhook.a and pasted it into ../node_modules/react-native/Libraries/WebSocket/ and got the build. I hope it helps.
...
Daniel's answer helped me to solve problem. Just note that if it's tvOS, then the same action of removing and adding should be done of RCTWebSocket-tvOS.a

Jenkins Mac issue

I'm trying to set up Jenkins for continuous integration.
At the moment, I'm trying to do something very simple but am running into issues and I'm not sure if I'm doing something wrong or what I'm trying to do just isn't possible.
I currently have a file, which shows up on PC as a Windows batch file and on Mac as a Unix executable file. I run it from Mac and it uses xcodebuild and xcrun to make and share archives.
What I want to do for now is just have Jenkins do this for me (I'll add more stuff later) so I add added a build step and typed in the path to the batch file:
users/mcbuild/documents/work/fts/ArchiveFTS.bat
However, when I click build I get this:
Started by user anonymous
Building in workspace /Users/Shared/Jenkins/Home/jobs/FTS Build/workspace
[workspace] $ cmd /c call /var/folders/2n/gysykb914qlgtg2b0flhvh4r00007c/T/hudson6994878138376885970.bat
FATAL: command execution failed
java.io.IOException: Cannot run program "cmd" (in directory "/Users/Shared/Jenkins/Home/jobs/FTS Build/workspace"): error=2, No such file or directory
From searching around, I found a couple of possible solutions:
Had to specify the shell to C\windows\system32\cmd.exe
I'm not sure what this means or how to do this, can someone explain this please?
I'm not sure but doesn't it look like Hudson is trying to execute a .bat script on a Unix system?
Does that mean what I'm trying to do isn't possible and if not, what are my options please?
Some suggestions involve checking which user you're using Hudson as and maybe changing that
I'm not sure what user I am using it as or why it comes up as anonymous
Is there an issue with it being anonymous and if so, how do I change it please?
Thanks in advance for your help. If you need any more information please let me know.
It appears that you added a build step of type "Execute Windows batch command", but you are running this job on a Mac. What you need to do is run your xcode/xcrun file from an "Execute shell" build step. If you still have problems, make sure you can manually run the same file from a command prompt on the Mac (not by clicking on it). If you get an error about "Cannot run program sh", you may need to configure the path to sh. Type "which sh" at a command prompt to find out where sh is located. Click on Manage Jenkins, then Configure System, and enter the path under Shell Executable.

Build framework as build phase xcode

I am trying to build the facebook-ios-sdk as part of my project build phases.
In short, the script checks for the build folder, and if it does not exist runs scripts/build_framework.sh
When executing the build phase script I get the following error:
Check dependencies [BEROR]CodeSign error: code signing is required for
product type 'Static Library' in SDK 'Simulator - iOS 6.0'
The build works as expected when running from the terminal.
The closest SO answer I saw was this, but it appears to be for an older version, and the link to the tutorial provided is no longer valid.
XCode is setting a lot of environment variables, and these must be interfering with the script. If you knew which environment variables were the culprit, you could clear them before running your script, but there are dozens and I didn't want to spend the time figuring that out.
Instead, I decided to run the script without XCODE's environment variables. If you run the script this way, you will only get the PATH environment variable in your new shell. This seems to fix things for me:
env -i PATH=$PATH ./Submodules/facebook-ios-sdk/scripts/build_framework.sh

Resources