How to run an Xcode built app from the command line (bash) - iphone

Following on from my question How to run an xcode project from bash?
I've found the built *.app in the build directory, but I'm trying to figure out how to get xcode to open it as it can't just be run as a Mac OS X program.
Any ideas?
thanks to chuan at this post: XCode Test Automation For IPhone

I'm stuck with the same problem trying to launch my debug output from building my xcode project. I just experimented with the following
open ./prog.app&
seems to do the trick.

I've solved my problem using a bash file that uses rsync to sync working directories and then AppleScript which builds and runs the project.
sync.sh:
#!/bin/bash
# script for moving development files into xcode for building
developmentDirectory="/"
xcodeDirectory="/"
echo 'Synchronising...'
rsync -r $developmentDirectory $xcodeDirectory \
--exclude='.DS_Store' --exclude='.*' --exclude='utils/' --exclude='photos'
echo 'Synchronising Done at:'
echo $(date)
buildandrun:
set projectName to "projectName"
# AppleScript uses : for / in directory paths
set projectDir to "Users:username:Documents:" & projectName & ":" & projectName & ".xcodeproj"
tell application "Xcode"
open projectDir
tell project projectName
clean
build
(* for some reasons, debug will hang even the debug process has completed.
The try block is created to suppress the AppleEvent timeout error
*)
try
debug
end try
end tell
quit
end tell
Then, finally, I'm using a shell script called run.sh aliased in my .bash_profile:
run.sh:
#!/bin/bash
bash utils/sync.sh
osascript utils/buildandrun

Related

Xcode 14.0 command PhaseScriptExecution failed with a nonzero exit code

After updating my Xcode to the latest version 14.0. I am facing this issue if anyone know how to resolve it please let me know
Click properties on the project, go to build phases and check the option "For install builds only"
Maybe the problem is with "Run script"
Ex: I did change firebase crashlytics from "pod" to "Packeges".
But I not change script.
I have tried all the solutions in
"https://stackoverflow.com/questions/53289524/xcode-10-2-1-command-phasescriptexecution-failed-with-a-nonzero-exit-code"
My solutions is change TARGETS -> Build Phases. In the script field
form
"${PODS_ROOT}/FirebaseCrashlytics/run"
to
"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"
In short the problem is your script, do it right
If Scrip is install builds only. U need
Targets -> Build Phases -> Run Scrip -> check "For install builds only"
Ex:
APP_PATH=“${TARGET_BUILD_DIR}/${WRAPPER_NAME}”
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find “$APP_PATH” -name ‘*.framework’ -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read “$FRAMEWORK/Info.plist” CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH=“$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME”
echo “Executable is $FRAMEWORK_EXECUTABLE_PATH”
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo “Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME”
lipo -extract “$ARCH” “$FRAMEWORK_EXECUTABLE_PATH” -o “$FRAMEWORK_EXECUTABLE_PATH-$ARCH”
EXTRACTED_ARCHS+=(“$FRAMEWORK_EXECUTABLE_PATH-$ARCH”)
done
echo “Merging extracted architectures: ${ARCHS}”
lipo -o “$FRAMEWORK_EXECUTABLE_PATH-merged” -create “${EXTRACTED_ARCHS[#]}”
rm “${EXTRACTED_ARCHS[#]}”
echo “Replacing original executable with thinned version”
rm “$FRAMEWORK_EXECUTABLE_PATH”
mv “$FRAMEWORK_EXECUTABLE_PATH-merged” “$FRAMEWORK_EXECUTABLE_PATH”
done
On my side this issue appeared when i change my computer and issue was caused by Apple Silicon processor. When i start to use m1 pro, i did not check the installation page i directly intalled flutter via Fvm. When i check the installation page i saw there are a few steps to install flutter on Apple Slicon. And these steps fixed the issue;
sudo softwareupdate --install-rosetta --agree-to-license
ref: https://docs.flutter.dev/get-started/install/macos

Eclipse (atollic) Pre-Build command format

I'm using Eclipe-Atollic to build for a STM32 micro. Running Windows 10 and TortoiseSvn. Im trying to get the Svn version into my code using the Tortoise "svnversion" command.
I'm trying to add the following command to the Pre-build steps in Eclipse-atollic under "Project Properties >> C/C++ Build >> Settings >> Build Steps >> Pre-build steps" .
svnversion > Src\svnvers.inc
This works fine from the Command prompt, but when I use the Eclipse builder - I get the following error message:
Info: Internal Builder is used for build
svnversion > Src\svnvers.inc
svnversion: E020024: Error resolving case of '>'
After the initial error, I've tried a variety of combinations of " and \ escapes, but without success.
Looking for any guidance on how to configure Eclipse to execute this command.
Thanks,
OK, If anyone else needs to know, I used "cmd -c" to execute the command, so what worked was:
cmd -c svnversion > Src\svnvers.inc

send an email using monkey talk automation tool

Is it possible to send an html email report through a monkey talk automation tool. If it is possible please provide any code or url.
Thanks,
Ramakrishna.
Use a CI (continuous Integration tool) with monkeytalk.
like jenkins+monkeytalk it is bit hard to configure it. but it can be done. use jenkins to automate the process of checkout code from repository and write a shell script to build the project and runtest cases with monkeytalk. after finish tests jenkins will email the reports to the given recipients.
jenkins: http://jenkins-ci.org/
More details...
first of all you need to download and deploy Jenkins. Downloadlink
to deploy in terminal
$ java -jar jenkins.war
open a browser http://localhost:8080 will take you to Jenkins dash board.
There is link for Jenkins settings on left side menu: from that page you can set an email account , password for Jenkins. and then provide recipient email addresses. so if a build faild Jenkins will email all console errors to the recipents. (try reading Jenkins documentation if it hard to install)
Then create a new job giving a name and details . add your repository URL and type add user credientials to it. and configure the rest in the end of the page you can give a build command as a shell script or ant file or there are many options.
then save the job and edit configurations start a build if it not checkout your code from repo and build correctly copy the errors from error console and search in google.
here is a sample code for build a Xcode project to a simulator
echo "Build Start"
/usr/bin/xcodebuild -target FuncTest CODE_SIGN_IDENTITY="iPhone Distribution: Leapset Inc." PROVISIONING_PROFILE="xxxxxxxx-1216-4E86-97D5-xxxxxxxxxxxx" OTHER_LDFLAGS="-lxml2 -all_load -lstdc++" DSTROOT="build" VALID_ARCHS="armv7 armv7s i386" -arch i386 -sdk iphonesimulator6.0 -configuration Release clean build install;
echo "Build End"
if you need to open iPhone simulator with the app use
# open app in simulator
echo "Start run app in simulator"
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication release-1.081/Leapset/build/Release-iphonesimulator/LeapsetFuncTest.app/FuncTest & disown;
echo "DONE run app in simulator"
run tests
echo "start run Test jobs"
######### Job 1 #########
echo
echo "TEST: SignInOut.mts"
echo "DISCRIPTION: sign in and out with user credintials"
#java -jar $$ROOTPATH/monkeytalk/LeapsetTest/libs/monkeytalk-runner-1.0.43.jar -agent IOS $ROOTPATH/monkeytalk/LeapsetTest/signinUser.mt
java -jar monkeytalk/LeapsetTest/libs/monkeytalk-runner-1.0.43.jar -agent IOS monkeytalk/LeapsetTest/SignInOut.mts
and monkey talk will generate reports. only thing you need to find is some way to attach those html reports to the Jenkins There are so many plugging available for Jenkins.
above commodes are working fine but you need to give the corrects paths to work it. like for above build command
Note: this command should run in terminal inside the project root directory(where the Xcode project file is)
Good luck
:)
xocdebuild command help
xcodebuild
[-project <projectname>]
[[-target <targetname>]...|-alltargets]
[-configuration <configurationname>]
[-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]]
[-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...
xcodebuild
[-project <projectname>] -scheme <schemeName>
[-configuration <configurationname>]
[-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]]
[-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...
xcodebuild
-workspace <workspacename> -scheme <schemeName>
[-configuration <configurationname>]
[-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]]
[-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...
xcodebuild -version [-sdk [<sdkfullpath>|<sdkname>] [<infoitem>] ]
xcodebuild -list [[-project <projectname>]|[-workspace <workspacename>]]
xcodebuild -showsdks

Clang Static Analyzer can't start. Why?

Getting this error:
2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler 'com.apple.compilers.llvm.clang.1_0.analyzer'
This happens when I execute this script from within xcode:
#!/bin/bash
result=$( osascript << END
tell application "Xcode"
tell active project document
set projectPath to path as string
end tell
end tell
return projectPath
END
)
cd "$result"
/Developer/clang/scan-build -k -V xcodebuild -configuration Debug -sdk iphonesimulator2.2.1
It worked all fine, but abruptly stopped working after restarting xcode. Clang is still installed and still at that specified path. Any idea what that message means?
If you have SnowLeopard and Xcode 3.2, you can run Clang via the menu command: Build and Analyze.

Build and Run an xcode project via AppleScript

I'm trying to build an xcode project and run it through the iPhone Simulator via applescript. I'm aware of xcodebuild but it doesn't let you run the app in the simulator. I've gotten pretty close with the script below...
tell application "Xcode"
set targetProject to project of active project document
tell targetProject
set active build configuration type to build configuration type "Debug"
set active SDK to "iphonesimulator3.0"
end tell
if (build targetProject) is equal to "Build succeeded" then
launch targetProject
end if
end tell
... but the build command doesn't seem to obey the active SDK property, it always defaults to the project's base SDK setting (such as the iPhoneOS3.0 instead of iPhonesimulator3.0)
Is there a way to tell the build command to use a specific SDK? I'm using xcode 3.2 on snow leopard.
Here is the trick... you have to set the SDKROOT build setting. Here is a zsh script I use to find the xcode project within the current hierarchy, build it, and run it via xcode.
#!/bin/zsh
BUILD_PATH=$(dirname $0)
while [[ -z $BUILD_FILE && $BUILD_PATH != "/" ]]; do
BUILD_FILE=$(find $BUILD_PATH -name '*.xcodeproj' -maxdepth 1)
BUILD_PATH=$(dirname $BUILD_PATH)
done
if [[ -z $BUILD_FILE ]]; then
echo "Couldn't find an xcode project file in directory"
exit 1
fi
# Applescript likes's : instead of / (because it's insane)
BUILD_FILE=${BUILD_FILE//\//:}
# Find the latest Simulator SDK
SIMULATOR_SDKS=( /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/*.sdk )
SIMULATOR_SDK=${SIMULATOR_SDKS[-1]}
SIMULATOR_SDK_STRING=$(basename ${(L)SIMULATOR_SDK%.[a-z]*})
if [[ -z $SIMULATOR_SDK ]]; then
echo "Couldn't find a simulator SDK"
exit 1
fi
osascript <<SCRIPT
application "iPhone Simulator" quit
application "iPhone Simulator" activate
tell application "Xcode"
open "$BUILD_FILE"
set targetProject to project of active project document
tell targetProject
set active build configuration type to build configuration type "Debug"
set active SDK to "$SIMULATOR_SDK_STRING"
set value of build setting "SDKROOT" of build configuration "Debug" of active target to "$SIMULATOR_SDK"
if (build targetProject) is equal to "Build succeeded" then
launch targetProject
else
application "iPhone Simulator" quit
end if
end tell
end tell
SCRIPT
Another option to consider is to use Applescript to launch a shell script that executes the xcodebuild program. xcodebuild allows you to specify things like a specific target, configuration, sdk, etc. I use this all the time when I have to SSH into a build server and rebuild a project.
The iphonesim project gives you a command-line launcher for the iPhone simulator.
If the set active SDK command does not work as expected, a workaround would be to create another build configuration named "Debug-Simulator" (in Xcode in the project settings), and to set the base SDK in the new configuration to iphonesimulator3.0. This would allow you to select the SDK by selecting the build configuration (if that works in AppleScript).