Terminal Command or Apple Script to run XCode? - 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

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

Generating a compiled application from an Apple Script

For an application uninstaller I use an Apple Script that I save in Apple Script Editor to a .app bundle. What I would like to do is to generate that .app bundle from the command line (so I can incorporate the step into an automated build script, and not have the bundle in a repo). Is this possible ? I have yet to find a command line interface to Apple Script Editor...
Edit: Just found osacompile... ;)
See the man page for the osacompile command.

Emulate Run button in Xcode from command line

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.

Xcode 4 Applescript to build and run the current target app

I'm looking for some applescript that would tell Xcode to run the current target.
I'd like to automate Xcode from textmate to provide "Run in simulator" and "Run on device".
This is as far as I got:
tell application "Xcode"
set myWorkspace to active workspace document
set myProject to the active project document of myWorkspace -- Can’t get active project document of workspace document "project.xcworkspace"
...
end tell
Creative use of the xcodebuild command line tool would very likely get you much further.

How to get the output of an OS X application on the console, or to a file?

I am writing a Cocoa application with Mono embedded. I want to run and see my debug output in Terminal. On the Cocoa side I am using NSLog(), and on the Mono side I am using Debug.Write(). I can see my debug output in Xcode's console, but not in Terminal. This is what I tried:
$: open /path/build/Debug/MyProgram.app
$: open /path/build/Debug/MyProgram.app > output
$: open /path/build/Debug/MyProgram.app 2> output
in a terminal but I do not my output on the console or in 'ouput'.
What's the correct command?
PS. My ultimate goal is to write a vim plugin to manage, build, run, debug the xcode project. You can save me this hassle if you can get this vi input manager to work with xcode.
Chris gave a good overview of how the Console works, but to specifically answer your question: If you want to see the results directly in your Terminal, you need to run the built product as a child of the Terminal, which means using something like
/path/debug/build/MyProgram.app/Contents/MacOS/MyProgram
to launch the app.
Terminal on Mac OS X is just another application. Opening a terminal window for text I/O is not an inherent capability of every application as it is on Windows.
Furthermore, open /path/to/MyApp.app does not execute MyApp.app as a subprocess of your shell, it sends a message to the operating system's launch infrastructure asking it to execute the application in a normal fashion, the same as if it were double-clicked in the Finder or clicked in the Dock. That's why you're not able to just redirect its output to see what your app is sending to stdout or stderr.
You can use Console.app to see the output of applications launched in the normal manner, because the launch infrastructure specifically sends their stdout and stderr there. You can also use the asl routines to query the log, or perform more sophisticated logging if you so desire.
Open Console.app in /Applications/Utilities. All NSLog output will be printed in the System log.
Or, if you run it from within Xcode, all of the output will be printed in the Debug console.
I'm not on my Mac right now and don't recall the command sequence or the menu the Debug Console is in, possibly the Build menu?
Overview
The idea is to simply run the app from command line using ios-deploy.
Instructions
Install ios-deploy
Run the app from xcode (make sure it runs successfully)
go to xcode menu > preferences > locations and click on arrow in derived data:
in the derived data directory, search for your .app file under Build/intermediates/Products
in the terminal type the following
ios-deploy --debug --bundle
then drag the .app file from step 4 unto the terminal.. you should have something like this
ios-deploy --debug --bundle path/to/your/applicationName.app
and that's it! The app should successfully run and all the logs will go to your terminal.

Resources