Emulate Run button in Xcode from command line - xcode

I'm looking for a way to build and run my app in the simulator from the command line. I need it to behave the same way as when you press Run in xcode.
I can build it with xcodebuild and I tried using simulator with -SimulateApplication option. My app launched but my tests didn't start executing (as they do when run from xcode).
I tried the script I found here and few other AppleScripts I found on the web. They didn't work for me. Commands like build and clean were ignored and others would throw errors. Maybe it's because I use xcode 4. Please help.

Related

programmatically xcode build(ios library) -is it possible?

I have mac descktop app(flutter, small obfuscator for objective-c code). after obfuscation of the source code, the user builds a ios library in XCode. is it possible to start the build process from my application?
These my options are:
Xcode Command Line Tools - it's very similar, but looks a bit complicated.
Also, I don't know yet how to use the terminal (terminal commands) in the desktop application - is it even possible?
fastlane -this tool is more for deployment. can i use this to build locally?
What do you recommend? maybe there are other options?
read below documentaion and set flutter path so it can be runable in terminal or you can get help from youtube to set flutter path
then simply open terminal and run below comands one by one
1.open -a simulator
this command open ios emulator
write cd and drag your project folder path
cd .../example
flutter run
✅your app launch in emulator
flutter path set details
https://docs.flutter.dev/get-started/install/macos

Is it possible using xcodebuild from the command line to build incrementally like the Xcode frontend?

I develop a macOS application and, for various reasons, I need a script to compile it from the command line. This works, but I have noticed that it compiles always like if the project had just been cleaned, that is, everything from scratch. Even if I don't make any modification to the project, it builds from the beginning and for this reason it takes a lot of time. My command is:
sudo -u $loggedInUser xcodebuild -project "${REPO_DIR}/MyProj.xcodeproj" -alltargets -configuration Release
Perhaps I can specify this requirement with an argument ? I hope somebody can bring me in the right direction. Thanks for your attention.

How can I see log of commands Xcode executed when I press `build` on Xcode?

I want to see the commands Xcode executed when I press "Build" on Xcode.
Those commands should be like xcodebuild and such.
I tried to find it at Xcode > View > Navigators > Show Report Navigator (related post), but I can not find the keyword xcodebuild inside. I want to see the parameters Xcode used for xcodebuild.
Am I able to do that?
Apparently, Xcode doesn't use xcodebuild in the build process. (If you think about it, the xcodebuild command is user-facing and part of the Xcode command-line tools, but those aren't required to be present to build and/or run something in it.) Here's the entirety of this very short answer:
You can't. Xcode itself doesn't invoke xcodebuild during the build process. This post has more information on executing xcodebuild to build for the simulator.

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

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.

Terminal Command or Apple Script to run XCode?

Is is possible to make XCode run by executing an AppleScript or some sort of terminal command?
Can you pass XCode startup arguments, like a project to open, or to build a project on startup?
Edit:
Please excuse my laziness, but Apple Script samples are appreciated.
It's fairly simple to run Xcode from the Terminal: open -a Xcode to simply open it, or open yourproject.xcodeproj to open your project in Xcode. As for getting it to build on startup, you'd probably have to turn to AppleScript for that:
tell application "Xcode"
build
launch
end tell

Resources