How to make xcodebuild print compile errors and warnings to stderr? - xcode

Seems like xcodebuild prints everything to stdout.
$ /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project test.xcodeproj build -target test -configuration Debug -jobs 3 2>err
# xcodebuild stdout with bunch of warnings and errors
$ cat err
** BUILD FAILED **
The following build commands failed:
CompileC _build/test.build/Objects-normal/x86_64/test.o /Users/me/test/test.cpp normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
That doesn't let my IDE(QtCreator) correctly parse the output.
And clang, actually, prints errors and warnings to stderr. But xcodebuild redirects everything to strdout for some reason. Is there a way to make xcodebuild print errors and warnings to stderr except 1>&2?

Can you try running the command with -quiet option as follows.
# Do not print any output except for warnings and errors
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project -quiet
So you can just pipe warnings and errors by using -quiet option and to filter only error you can use 2> ./errors.log
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project -quiet test.xcodeproj build -target test -configuration Debug -jobs 3 2> ./errors.log
There are other tools to check such as xcpretty and xcbeautify.
https://github.com/xcpretty/xcpretty (I prefer this)

Related

How can I stop prints of xcodebuild to consol in macOS

I want make xcodebuild in Terminal without those extra long long prints, for that goal I am using quiet code, but it seems not working! How can I stop prints?
xcodebuild archive \
-scheme Test \
-configuration Release \
//some other codes ...
-SKIP_INSTALL=NO \
-BUILD_LIBRARIES_FOR_DISTRIBUTION=YES \
-quiet=YES

OpenCOBOL Static Linking Multiple .cob Files

I am trying to statically link two COBOL files together using GnuCobol (Windows 10) following the example listed here: https://open-cobol.sourceforge.io/historical/open-cobol/Static-Linking.html but cannot seem to get it to work.
I am running the following:
cobc -free -c InterpFunc.cob
cobc -free -c -fmain Integrator.cob
cobc -x -o .\\dist\\integrator Integrator.o InterpFunc.o
The '.o' files compile correctly, but the binary never builds with the following errors:
H:\Programs\COBAL\cobc\bin\cobc.exe: unrecognized option '-fmain'
h:/programs/cobal/cobc/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain#16'
collect2.exe: error: ld returned 1 exit status
The terminal process terminated with exit code: 1
I have tried a few different things such as leaving out the '-fmain' or leaving out the '-x', but all seem to produce different errors.
Is this perhaps an issue with my compiler/system setup or am I misunderstanding how to statically link files?
I'm quite sure you do not use a compiler matching that old documentation (having "historical" in its URL). I'm quite sure it'll work the way the current manual says:
The easiest way of combining multiple files is to compile them into a single executable.
One way is to compile all the files in one command:
$ cobc -x -o prog main.cob subr1.cob subr2.cob
Another way is to compile each file with the option -c, and link them at the end. > The top-level program must be compiled with the option -x.
$ cobc -c subr1.cob
$ cobc -c subr2.cob
$ cobc -c -x main.cob
$ cobc -x -o prog main.o subr1.o subr2.o

How to Run Xcode Project From Terminal in iOS Device?

I want to Install Xcode Project in to iOS Device thru Terminal.I know how to Build Application using xcodebuild clean install this command.I want to launch app in device.Please can any body help me in this task?
I have tried some commands which executes successfully as well but now i am getting the following error when i tried to execute the following command.
xcodebuild -target "GoldenGate" -sdk "iOS 6.1" -configuration Release
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer/
PROJECT="GoldenGate"
SIGNING_IDENTITY="iPhone Developer: Deepak Shukla"
PROVISIONING_PROFILE="${WORKSPACE}/E6FD2816-7827-41AA-AC7E-2DC4833E637C.mobileprovision"
ARCHIVE="$(ls -dt ~/Library/Developer/Xcode/Archives//${PROJECT}.xcarchive|head -1)"
IPA_DIR="${WORKSPACE}"
DSYM="${ARCHIVE}/dSYMs/${PROJECT}.app.dSYM"
APP="${ARCHIVE}/Products/Applications/${PROJECT}.app"
/bin/rm -f "${IPA_DIR}/${PROJECT}.ipa"
/usr/bin/xcrun -sdk iphoneos PackageApplication \
-o "${IPA_DIR}/${PROJECT}.ipa" \
-verbose "${APP}" \
-sign "${SIGNING_IDENTITY}" \
--embed "${PROVISIONING_PROFILE}"
Embedding '/E6FD2816-7827-41AA-AC7E-2DC4833E637C.mobileprovision'
/bin/rm -rf /var/folders/wv/kv98qhfj6v36b2h0fkf_l66w0000gn/T/ouA93u702I/Payload/GoldenGate.app/embedded.mobileprovision
Program /bin/rm returned 0 : []
/bin/cp -rp /E6FD2816-7827-41AA-AC7E-2DC4833E637C.mobileprovision /var/folders/wv/kv98qhfj6v36b2h0fkf_l66w0000gn/T/ouA93u702I/Payload/GoldenGate.app/embedded.mobileprovision
Program /bin/cp returned 1 : [cp: /E6FD2816-7827-41AA-AC7E-2DC4833E637C.mobileprovision: No such file or directory
]
error: Unable to copy '/E6FD2816-7827-41AA-AC7E-2DC4833E637C.mobileprovision' to '/var/folders/wv/kv98qhfj6v36b2h0fkf_l66w0000gn/T/ouA93u702I/Payload/GoldenGate.app/embedded.mobileprovision'
Please help me in this task.
#!/bin/sh
# build.sh
#
# Created by iOSRider on 27/01/2014.
APPLICATION_NAME=MyApp
PROJDIR=/Users/iOSRider/Desktop/MyApp
PROJECT_NAME= MyApp
TARGET_SDK="iphoneos"
PROJECT_BUILDDIR="${PROJDIR}/build/Release-iphoneos"
TARGET_TEST_NAME="MyApp"
BUILD_HISTORY_DIR="/Users/iOSRider/Desktop/MyApp"
DEVELOPPER_NAME="iPhone Distribution: iOSRider India Limited (R8UAKS2M7L)"
PROVISONNING_PROFILE="/Users/iOSRider/Desktop/MyApp/iOS.mobileprovision"
# compile project echo Building Project cd "${PROJDIR}" xcodebuild -target "${PROJECT_NAME}" -sdk "${TARGET_SDK}" -configuration Release
#Check if build succeeded
if [ $? != 0 ] then exit 1 fi
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${PROJECT_BUILDDIR}/${APPLICATION_NAME}.app" -o "${BUILD_HISTORY_DIR}/${APPLICATION_NAME}.ipa" --sign "${DEVELOPPER_NAME}" --embed "${PROVISONNING_PROFILE}"

How do I get a build variable from xcodebuild?

I am using the following command:
xcodebuild -project eagle.xcodeproj -target eagle_test -showBuildSettings
But I need to extract the OBJROOT as part of an external makefile. How would I get this?
Her you go. Parsed all nicely.
xcodebuild -project eagle.xcodeproj -target eagle_test -showBuildSettings | grep "OBJROOT" | sed 's/[ ]*OBJROOT = //'
High level answer: As part of the makefile run the xcodebuild -project eagle.xcodeproj -target eagle_test -showBuildSettings command and parse the output for the value of OBJROOT.

How to reference current dir from a terminal command

How do I reference the current dir from a terminal command:
xcrun -sdk iphoneos PackageApplication -v "[current dir]/target/My App.app" -o "[current dir]/target/MyApp.ipa"
[current dir] = how do I get this value?
So basically I don't want to type the whole dir out in the command. I want it to look in the dir where it is currently running
xcrun -sdk iphoneos PackageApplication -v "$PWD/target/My App.app" -o "$PWD/target/MyApp.ipa"

Resources