Xcode 4 Applescript to build and run the current target app - applescript

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.

Related

How to run Script from "Build Phases" section in archived (deployed) app?

so I'm trying to build a macOS menu bar app that executes a binary (a small server) and closes it when the app is closed. I added "path/to/server >/dev/null 2>&1 &" to the "Run Script"-section in "Build Phases" and it works perfectly when executing the app from Xcode. Now I wanted to store it locally in my Applications-Folder ("Archive" -> "Distribute App" -> "Copy App"). But when I start the app from there, the server does not start. I only found solutions for executing the script before archiving, but it needs to run every time I open the application. (macOS Ventura, Xcode 14)
What do I need to do?
Thanks a lot,
Nicolas

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

Copy iOS App bundle to another folder during Xcode build

I would like to copy the contents of my iOS App Bundle to a particular directory during the Xcode build stage. Can anyone tell me how to do that?
A solution using a script in "Build Phases" does not work properly since Xcode is not finished building the app when running the script. Here is a solution with a script that runs after all build tasks are finished:
Go to "Edit Scheme"
Click on the triangle next to "Build"
Select "Post-action"
Press the + button and select "New Run Script Option"
Select your app name in "Provide build settings from"
Add the following shell script:
Script:
PRODUCT="${BUILT_PRODUCTS_DIR}/${TARGET_NAME}.app"
cp -R "${PRODUCT}" ~/Desktop

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

Using Clang Static Analyzer from within Xcode

Since there is no Xcode script variable for "current project directory," how can you create a script menu item to run the Clang Static Analyzer on your current project from Xcode?
From the XCode script menu item, "Edit User Scripts" enter the following script:
#!/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/clangchecker/scan-build -k -V xcodebuild -configuration Debug -sdk iphonesimulator3.0
Obviously, you will need to adjust the path to your install of Clang, and adjust to the version of the SDK you are using.
Remember to do a "Clean All" immediately before using scan-build, or the results may be incomplete.
FYI, Xcode 3.2 (Snow Leopard only I believe) includes the Clang Static Analyzer in the "Build and Analyze" menu option.
http://iosdevelopertips.com/xcode/static-code-analysis-clang-and-xcode-3-2.html
One downside of Xcode 3.2 (aside from it only working on Snow Leopard) is that the v2.x Simulators don't seem to work - in fact, I've seen posts indicating that v2.x builds are not supported at all.
I believe the ${PROJECT_DIR} environment variable is what you want for the directory of the project running a build-phase script.
Either use the version bundled in XCode 3.2+, or download a newer version at https://clang-analyzer.llvm.org/ then see some additional instructions at https://clang-analyzer.llvm.org/xcode.html to switch XCode to that downloaded version.

Resources