How to launch console app from terminal with parameters? - objective-c

I've got console app in Xcode which uses Core Data and should get one parameter from console. Problem is it builds without packaging into .app file. So I can't even launch it from terminal, not even pass it a parameter. Maybe I missed some project settings, allowing me to do this?

you should run the actual program within the app e.g. ./MyProgram.app/Contents/MacOS/MyProgram if you are in the directory that contains the .app.

open -a "./MyProgram.app/Contents/MacOS/MyProgram" --args myarg

Related

SenchaSDKTools-2.0.0-beta3-windows Command not working

I have installed SenchaSDKTools-2.0.0-beta3-windows on my windows Xp 32-bit.
following is the command I am running on command prompt.
C:\Program Files\SenchaSDKTools-2.0.0-beta3>sencha app create MyApp c:\xampp\htdocs\sencha\myapp\
Giving following error
[ERROR] the current workind directory (C:\Program
Files\SenchaSDKTools-2.0.0-beta3>) is not valid SDK directory. Please
'cd' in to a SDK directory before executing this command.
environment variable has been set following way.
Variable name : Path
Value : C:\Program Files\SenchaSDKTools-2.0.0-beta3
can anyone figure out what exactly wrong in this process ?
*****Sencha Touch setup Guide steps(in Window)******
Download Sencha Touch SDK Tool. (http://www.sencha.com/products/touch/download/ -->SDK Tools Beta for Developers). Run .exe file. It will install tool to default path. (i.e. C:\Program Files\SenchaSDKTools-2.0.0-beta3)
Download Sencha Touch SDK. (Download openSource version file licensed under GPL.).
Extract SDK you just download in step 2.
Open Command line terminal (start->Run->type cmd). Change directory path to SDK path as you just extracted in step3.
Verify that Sencha Command is working properly on your machine. So Type Sencha.
E.g. sdkPath>sencha
you will see "Sencha Command v2.0.2" message with other sencha command detail.
Create app in your web directory by typing following.
E.g. sdkpath> sencha app create firstSenchaApp "path/ to/ www"
(If you have tomcat 7 installed in your computer, give path to \apache-tomcat-7.0.30-windows-x86\apache-tomcat-7.0.30\webapps)
Note: There must not be space in directory path name. _(underscore),- (desk) are allowed.
If app is not generated in step 6. There might be an error. There are as follow:
If error message appear is "sencha' is not recognized as an internal or external command, operable program or batch file.”, follow these steps to troubleshoot:
The path to SDK Tools directory is prepended to your system's PATH environment variable.
From the terminal, run
echo $PATH or echo %PATH% .
The SDK Tools directory should be displayed in part of the output. If this is not the case, add it to your PATH manually.
The environment variable SENCHA_SDK_TOOLS_{version} is set, with the value being the absolute path to the installation directory mentioned above.
For example: If the installed version is '2.0.0-beta2', a SENCHA_SDK_TOOLS_2_0_0_BETA2 must be set.
From the terminal, run
echo $SENCHA_SDK_TOOLS_2_0_0_BETA2 or echo %SENCHA_SDK_TOOLS_2_0_0_BETA2% on Windows.
If the output is empty, set the environment variable manually.
Wrong Current Working Directory
A common mistake is not running Sencha Command within either a valid SDK directory or an application directory. If the current directory is not a SDK or application directory, "sencha" command will fallback to backwards-compatible mode. As of SDK Tools release "2.0.0-beta2", you should see a clear warning in such case:
"The current working directory (...) is not a recognized Sencha SDK or application folder. Running in backwards compatible mode." So in this case follow proper step as mentioned above.
Reference:
http://www.sencha.com/forum/showthread.php?192169-Important-SDK-Tools-Sencha-Command-Update
There is an invisible file that you need to copy, called .senchasdk. Make sure it is in the folder.
I think you're having the same problem I had; I had attempted to run 'sencha app create...' from the folder containing sencha.bat. Instead, you need to run 'sencha app create...' from the sencha-touch-2.0.1.1 folder (which contains the .senchasdk file).
See this previous SO question!
Save my days.
By the way, if you can't extract the sencha-cmd to sdk tools, try to extract on other location and copy the folder [3.0.0.250] to your sdk tools > [bin] folder.
hope this helps.

How do I Include a Powershell script when publishing my VB app?

I am writing an application in VB.NET. In the app, I have a function which calls a Powershell script and places the resulting information in a text box.
I have two issues:
How to I ensure that when my app is published, the powershell script is included?
How do I reference the script in my code?
Currently, I simply give my function the full path to the script, which is in a folder on my Desktop. Obviously, this will not work once I deploy the app to other computers.
You will need to create a Setup project to get your script in place on your target system.
A first step is to change the Build Action to Content and Copy to Output Directory to Copy always.
Your Setup project can pick up the script from the VB app build result and put it in place when installing your app.
As for your question concerning the user configurable install path: The easiest way to handle this would be to add registry entry containing the selected program file path and have your app read the path from there.

Running an Mac OS command line application, how to

Suppose you create a new Mac OS Command Line Application using Xcode, which prints something. How do you actually find and run it using your command line or Finder?
Application was "built", but project directory structure does not seem to contain an executable file. For what matter in what format will this file be?
Please advise
This should help out:
Choose to build your project for archiving (Product->Build
For->Archiving).
The executable will be created and placed in the project build
folder. This will typically be something like
/Users//Library/Developer/XCode/DerivedData//Build/Products/Release.
If you wish, copy the executable to a more convenient location.
To run it, open up a shell window, browse to the executable
directory, and type in your command name.
EDIT
I see you mentioned iOS in your question and tagged it as such. This answer is NOT relevant to iOS, infact I see no option to build a command line application for that system and it doesn't really make much sense to have one.

Build and Debug application outside the default package

If I try to build an application with the application class outside the default package, so the application file path is /app/AppClass.mxml instead of /AppClass.mxml (as would normally be the case), Flash builder cannot launch the application for debugging because it is looking for the SWF in debug/app/AppClass.swf and the SWF is being output to debug/AppClass.swf instead. Changing the output folder to debug/app makes it put the swf in debug/app, but then it puts the application configuration file "AppClass-app.xml" in /debug/app/app and then that can't be found.
Is there a way to change only the SWF output folder, or the location of the xml configuration file in the run-configuration?
You may use symbolic link to created swf file - http://en.wikipedia.org/wiki/Symbolic_link
for example for Windows :
cd project/path/bin-debug/package/path/
MKLINK ClassName.swf project/path/bin-debug/ClassName.swf
and it's work
or you can use symbolic link for folder:
cd project/path/bin-debug/package/
MKLINK path project/path/bin-debug/ /D
I think I remember this worked for me. But it was long time ago. And, yes, it is a known problem, I also recall Adobe people mentioning it as a limitation of FB.
In my Ant script, you'll need to do the adjustments to reflect your actual file names and directory structure. Also note that it will make it more cumbersome to debug it from FB. You'll need to use the debugging target in Ant, and then connect the debugger to the running application (so that some info, especially on the startup) will be lost. The only way you would be able to debug it, though I've never tried it, is with the commandline tools (I'm not sure of adl syntax for breakpoints / printing / stack frames, so idk how to do it.
Also, for the released application you will probably want to change the signing mechanism.

How to debug a Screensaver in OS X

I was wondering if there was any decent way, other than NSLog-ing just about everything - to properly debug a Screensaver app bundle in OS X?
The "Screensaver" is a project type in Xcode, but there's obviously no Build and Go debugging. Further, I've found that in fact my bundle is getting loaded in to the
/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app
application as some sort of plugin.
So is there a decent way to debug your code? Looking at crash reports and NSLog-ing to the console helps, but it's far from perfect.
There is an old MacTech article that describes the Screen Saver development cycle. There is also a Part 2 to the article. Look in the "Debugging Tips" section.
I find this method a pain so I wrote an application, the basic application was one window and a controller that initialized a ScreenSaverView with my new screensaver bundle. Once that was working all I had to do to test a change was hit Command-R in Xcode.
Because of OS X 10.11 El Capitan's System Integrity Protection feature, the debugger can't attach to anything running from /System/. Also, the other info here applies to old versions of Xcode.
Here's how I got it working on El Capitan with Xcode 7.2:
Copy /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app/ to /tmp/. (Since the .xcscheme references the fully-qualified path, copying it to someplace common is best for collaboration, instead of to somewhere in a particular user's home directory.)
Edit the project's .xcscheme:
Set the Executable for its Run action to the copied app, and add the arguments: -debug -background -module "<product-name>" (where <product-name> is the bundle name without the .saver extension).
Add a Pre-action script (source below), with its shell set to /bin/bash and its build settings to come from the scheme. It creates a symbolic link to the built .saver bundle in ~/Library/Screen Savers/
Source:
SCREEN_SAVER_PATH="${HOME}/Library/Screen Savers/${FULL_PRODUCT_NAME}"
if [[ -d "${SCREEN_SAVER_PATH}" || -f "${SCREEN_SAVER_PATH}" || -L "${SCREEN_SAVER_PATH}" ]]; then
rm -Rf "${SCREEN_SAVER_PATH}"
fi
ln -s "${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}" "${SCREEN_SAVER_PATH}"
Now, when you hit Xcode's Run button, the screen saver will run in wallpaper mode on your Desktop, and you can use the debugger.
You can debug plugins by executing the application that will load the plugin.
So to debug a screensaver, open your plugin project, choose New Custom Executable from the Project menu and set the application to be the screensaver engine.
For debugging a screensaver, you might also want to use a second Mac and use remote debugging so your user interface actions don't interfere with the screensaver.
There's a few Mac OS X apps that will run screen savers: SaverLab, Screenalicious, etc.
Just find one of them on the web and download it and then set it as the target executable (as Peter N Lewis said).
To avoid copying the build product to '~/Library/Screen Savers/' after each build you can add a custom build script (note: I'm using '/bin/tcsh -x' for the shell):
#remove the old screen saver or link
rm -Rf "${SCRIPT_OUTPUT_FILE_0}"
#if this is a debug build…
if ("${CONFIGURATION}" == "Debug" ) then
# create a symbolic link from our screen saver to this users screen saver directory
ln -sfv "${SCRIPT_INPUT_FILE_0}" "${SCRIPT_OUTPUT_FILE_0}"
#if this is a release build…
else if ("${CONFIGURATION}" == "Release" ) then
# copy our screen saver to this users CMM directory
cp -Rfv "${SCRIPT_INPUT_FILE_0}" "${SCRIPT_OUTPUT_FILE_0}"
endif
Then set its input file to "${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}" and its output file to "${HOME}/Library/Screen Savers/${FULL_PRODUCT_NAME}".
Now when you build / run your project it will auto-magicly link to your debug build or copy your release build.
You could also make the screensaver engine ('/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app') the target executable and pass it the -background flag (so it runs behind everything instead of in front of everything).
As Peter says, you can debug the plugin by executing an application that will load the plugin.
However, rather than using the screensaver engine you could also use system preferences. When the preferences appear navigate to your screensaver under "Desktop & Screen Saver" to load your plugin.
It's not perfect as your view won't be full size, but it can be easier than setting up remote debugging.
not necessarily the best way, but you could ssh in from another machine and launch ScreenSaverEngine from gdb (untested)
edit:
also, you could try adding a new application target and add your ScreenSaverView to a window in IB, you may have to manually configure stuff like settings, but it could help some and should probably work OK as ScreenSaverView is a subclass of NSView
If you make a copy of the ScreenSaverEngine app, and sign it with your Developer ID, it will fix the situation where System Integrity Protection prevents attaching the debugger. Just make sure to set the executable to your own-signed copy.
I would like to note that #Karl's solution worked the best for me.
However, if you are like me and you reboot your computer every night you may want to think about putting:
cp -Rn /System/Library/CoreServices/ScreenSaverEngine.app /tmp
at the beginning of the pre-Build shell script mentioned in his answer. This will automatically do the copying step for you.
(though I believe this really belongs in a comment, my xp is not yet high enough)