I am launching xcodebuild through the lldb debugger so I can alter its execution like:
lldb
# set debugging target
target create /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
# launch process and stop at entry point
process launch -s -- -sdk iphonesimulator -destination 'name=iPhone SE' test
# set a breakpoint
breakpoint set -F "+[IDELaunchParametersSnapshot launchParametersWithSchemeIdentifier:launcherIdentifier:debuggerIdentifier:launchStyle:runnableLocation:debugProcessAsUID:workingDirectory:commandLineArgs:environmentVariables:architecture:platformIdentifier:buildConfiguration:buildableProduct:deviceAppDataPackage:allowLocationSimulation:locationScenarioReference:showNonLocalizedStrings:language:region:routingCoverageFileReference:enableGPUFrameCaptureMode:enableGPUValidationMode:debugXPCServices:debugAppExtensions:internalIOSLaunchStyle:internalIOSSubstitutionApp:launchAutomaticallySubstyle:]"
break command add
po $rcx = (unsigned long)IDEDefaultLauncherIdentifier
po $r8 = (unsigned long)IDEDefaultDebuggerIdentifier
continue
DONE
# resume execution
continue
What I want to achieve is to attach xcpretty to:
process launch -s -- -sdk iphonesimulator -destination 'name=iPhone SE' test
like
process launch -s -- -sdk iphonesimulator -destination 'name=iPhone SE' test || xcpretty
but I can see that obviously that is not the way.
xcodebuild: error: Unknown build action '||'.
Any ideas if that is even possible and if so how ?
Try this
process launch -s -- -sdk iphonesimulator -destination 'name=iPhone SE' test | xcpretty
instead of
process launch -s -- -sdk iphonesimulator -destination 'name=iPhone SE' test || xcpretty
or you can go this way
process launch -s -- -sdk iphonesimulator -destination 'name=iPhone SE' test > output.txt
xcpretty < output.txt
The run-args in lldb's "process launch" do not support piping or redirection operators. If the -c option is set, lldb will get the shell to do shell expansion on the arguments. But that's all the interaction with the shell that lldb supports.
If you need to debug something that is running in a chain of execution, you will have to launch the process chain manually, and attach to the process in the chain after the fact. The way to do this is to start the attach in lldb before launching your process and use the -w option to process attach to tell lldb to attach to the process once it starts up. Then start the process. Unless your system is heavily loaded lldb will generally catch the process early in its startup, so for most debugging tasks you don't miss code you actually care about.
Related
I have small problem with implementing xcodebuild command test at CI. I have tests related to specific device language, in xcode I can set "Arguments Passed On Launch" to -AppleLanguages (language). Can I pass that argument using xcodebuild?
My script looks like this
xcodebuild -workspace MyApp.xcworkspace -scheme "MyAppTests" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.0' test
Thanks!
xcodebuild is for build your app. You can use this command to run your app with specific language.
xcrun simctl launch <deviceid> <appid> -AppleLanguages "(pt-BR)"
Hera a sample with all steps to buil and run your app:
xcodebuild -sdk iphonesimulator8.4 -arch i386 install DSTROOT=YourAppFolder
xcrun instruments -w "iPhone 6 (8.4 Simulator)"
xcrun simctl install booted YourAppFolder/Applications/YourApp.app
xcrun simctl launch booted com.yourdomain.yourapp -AppleLanguages "(pt-BR)"
I'm having some trouble with my cocoapods running Travis CI. Everything seems to install correctly, but the xcodebuild script fails
$ set -o pipefail && xcodebuild test -workspace Example/UIKitPlus.xcworkspace -scheme UIKitPlus-Example -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO | xcpretty -c
xcodebuild: error: Failed to build workspace UIKitPlus with scheme UIKitPlus-Example.
Reason: The run destination iPad 2 is not valid for Testing the scheme 'UIKitPlus-Example'.
The command "set -o pipefail && xcodebuild test -workspace Example/UIKitPlus.xcworkspace -scheme UIKitPlus-Example -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO | xcpretty -c" exited with 70.
https://travis-ci.org/JamieREvans/UIKitPlus/builds/54649639
I'm not sure why this is failing, because I can run my tests on the iPad 2 simulator, using that scheme, without any issues.
Is this a Travis issue or is my Travis script wrong?
I've managed to get it build by adding a destination to the xcodebuild command line, e.g. -destination "platform=iOS Simulator,name=iPhone 6"
I normally run my xcode unit tests on command line using these commands:
clean:
xcodebuild -workspace appName.xcworkspace -scheme "Shared appName" -destination "platform=iOS Simulator,name=iPhone 5s,OS=8.1" clean
then build:
xcodebuild -workspace appName.xcworkspace -scheme "Shared appName" -destination "platform=iOS Simulator,name=iPhone 5s,OS=8.1" build
then test (with dry run):
xcodebuild -workspace appName.xcworkspace -scheme "Shared appName" -destination "platform=iOS Simulator,name=iPhone 5s,OS=8.1" test -dry-run
and I sometimes I get this error:
2015-02-27 11:01:50.417 Registering for testmanagerd availability notify post.
2015-02-27 11:01:50.417 testmanagerd availability notify_get_state check indicated manager not ready, waiting for notify post.
2015-02-27 11:02:50.371 60s elapsed since launch without testing starting, sending logs to stderr
any idea how to prevent this from happening? I'm assuming that the testmanagerd is a test daemon or something? Where can I find documentation about that?
This timeout usually means that your mac is too slow and it took more than expected to run the simulator. You should start thinking in getting a new machine.
I'm trying to launch an iOS app tests through command line, from a Jenkins Job.
If I launch the command in my user's console, works ok, the command is:
xcodebuild test -scheme demoIC -destination 'platform=iOS Simulator,id=E6954360-11D9-49E0-9008-A8EE6BA1ACFC'
It's supposed Jenkins uses 'jenkins' user for launching jobs, so I have done:
su - jenkins
And the when I launch the same command, I got an error:
2015-02-16 18:21:41.215 xcodebuild[3952:1303] iPhoneSimulator: Could not launch simulator: -10810
You can give a try to this, it worked for me:
xcrun xcodebuild -workspace $Project_Name.xcworkspace -scheme "$Build_Test_Scheme" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8,OS=13.2.2' -derivedDataPath './output' test
I'm using xcodebuild to build and install my app on the simulator (by copying the .app to ~/Library/Application Support/iPhone Simulator/6.1/Applications/UUID/) from the command line. I use:
xcodebuild -target MyApp
-configuration Debug
CPU_ARCHITECTURE=iphonesimulator6.1
install DSTROOT=Products
The .app is produced in /project_root/Products/Applications/MyApp.app However, every time I run the .app on my simulator, it crashes immediately.
I compared the .app that is created from Xcode's Run to xcodebuild's output from above. The two MyApp.apps are pretty much identical, but the MyApp binary inside of MyApp.app differ (the Xcode one is almost twice the memory footprint). I even tried copying the binary from Xcode's MyApp.app to xcodebuild's, and that worked too.
Any ideas why xcodebuild's .app is crashing?
Though there was no explicit "answer" to my question that I can mark as correct, here's my solution just in case anybody else has the same problem. Props to Richard for pointing me in the right direction. I played around with different settings for VALID_ARCHS and set it to "i386" (the simulator's architecture). Additionally, the syntax was wrong for CPU_ARCHITECTURE. xcodebuild uses the -sdk option instead. The following worked for me:
xcodebuild -target MyApp
-configuration Debug
-sdk iphonesimulator6.1
VALID_ARCHS="i386"
install DSTROOT=Products
This is my script that makes .app for simulator :
(Replace "MyApp" with your app name)
XCODE_WORKSPACE=/Users/MacBook/iOS/MyApp.xcworkspace
xcrun xcodebuild \
-scheme MyApp \
-workspace $XCODE_WORKSPACE \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 8,OS=11.2' \
-derivedDataPath \
build