I've been using Swift-Keylogger as a command-line program.
I thought of making a UI for it as I have started mac development recently.
As it is a command-line program, the author used RunLoop.current.run() in-order to run the keylogger continuously.
Now the problem is I can't use RunLoop.current.run() because it blocks the UI.
I have looked into GCD and it only runs a piece of code. But I want to run it continuously. I saw some additional articles about running continuously but I found running code continuously after every 'n' specified time by using Timer.
So, how can I replace the RunLoop.current.run() which has same behaviour without blocking UI?
UPDATE: 05/07/2018
To start and stop the keylogger from the UI, check this issue from GitHub
UPDATE: 18/01/2018
Some guy approached me with same requirement as yours. After some discussion and trial and error method, he found a solution.
1) Just comment out the RunLoop.main.run() line in the keylogger code.
2) Now disable the app sandbox. If you want to enable the app sandbox, then add this entitlement com.apple.security.device.usb = YES.
Original: 18/03/2017
I also searched for it a lot in the beginning when I'm writing my keylogger. After a day I gave up.
I use Process in swift to run the keylogger from my UI.
The way I do is:
Do the necessary modifications in keylogger source like the path of files/folders.
Compile the keylogger source.
Drag the keylogger to your project in your Xcode and check copy if needed.
The executable is in resources folder inside your .app.
Run the executable using Process class and launch() to start the executable/ your keylogger.
You should terminate the created process, otherwise the keylogger will be running in the background. To stop the keylogger, use terminate() on Process variable.
Code:
let pathToKeylogger = Bundle.main.resourcePath! + "/Keylogger" // path to keylogger executable
keylogger = Process() // You need to declare this variable at class-level because you need to have the variable later to terminate it.
keylogger.launchPath = pathToKeylogger
keylogger.launch()
To Terminate:
keylogger.terminate()
Edit: 18/03/2017
Try to quit your app normally i.e., either clicking quit in menu bar or in the dock instead of pressing stop button in Xcode. I think you are pressing stop in Xcode.
Related
I currently want to debug my application using the LLDB debugger. I am successfully able to run code in my application if I set a breakpoint on my iPhone app and when I click build and run. The problem is if I start my application without Xcode and attach the debugger to my iOS application. Doing it this way means I cannot debug my application.
When I do build and run from Xcode along with a breakpoint and run the LLDB command list. I can see that it is debugging the GameViewController.swift file, however when I attach the debugger to my app after running it normally, the LLDB debugger is now in the AppDelegate file.
How would I get the LLDB debugger to debug the file GameViewController.swift instead of AppDelegate,swift file?
Bear in mind that the debugger is attached to your entire application, not to a particular file.
When you attach to the program, it stops wherever the program happens to be; and if the program is idling, that will be in the AppDelegate more times than not.
To get it to list code in another file, you can use the list command, e.g. by using:
list GameViewController.swift:10
It lists the file GameViewController.swift, from line 10, for 10 lines.
You can add in a breakpoint for a method in GameViewController, e.g. for a method called onClick by doing:
breakpoint set --file GameViewController.swift -n onClick
or a line using:
breakpoint set --file GameViewController.swift -l 998
and then continuing, until it stops in the relevant piece of code.
I'm newbie to ruby and rhomobile.
I'm debuggind succesffuly using the simulator, I can set breakpoints, etc... All works fine except I can't debug inside the framework code.
How can I debug through the framework code in a rhomobile app? How can I configure rho studio so I can debug inside the framework?
I'm a newbie with ruby and eclipse.
More detailed:
My problem happens when I try to debug functions inside the framework. For example: I put a breakpoint in a model.find(:all). The debugger stops here, but when I want to debug then find method it doesn't enters it, it simply executes and continues in the next instruction. In keys terms, I want to make a step into, but it makes a step over. If it helps you, in edit mode, when I press control+left mouse button over a "Rho::RhoController" in a line like this: "class TestController < Rho::RhoController", it doesn't open /rhodes-3.2.1/lib/framework/rho/rhocontroller.rb, where the source code of this class is.
First you need to install rhostudio, once ure done with that. You need to run your application through Rhosimulator which is a really fast simulator than native blackberry, android & ios simulators.
Please follow these steps :
Select Run » Debug Configurations… from top menu
Find ‘Rhodes Application’ section on the left and add new (or modify existing) configuration
On ‘Common setting’ tab select a project by clicking ‘Browse…’ button next to ‘Project name:’
Select ‘Rho simulator’ as the platform
Click ‘Apply’ and then ‘Debug’
Its good that you have already added breakpoints in your .rb files which you can now view in log in Console window.
I am trying to debug a small prototype for an iPhone App (iOS Simulator 4.1), compiled as Debug, with all the configuration apparently ok.
The application makes use of Cocos2d graphic engine and GDataXMLNode library (for XML reading). There isn’t much stuff going on. But on certain method, if I set a breakpoint, gdb simply “stops”.
Here’s the status line of the debugger after it hits he breakpoint:
And here’s the code that has the breakpoint(sshot):
note: the breakpoint could be anywhere in that function and it’s the same.
And this is the calling code (from another object)
self.map = [SimulationLoader loadMap];
None of the Editor buttons work when a breakpoint is set inside the “loadMap" (step into, step out, next, continue execution, etc.). I can stop and/or restart the debugging and it works (but goes back to the beginning). The gdb prompt, will let me write, but nothing happens. I cannot view object values or anything debugging related. I cannot resume execution, it won’t do anything.
The strange thing is that, if I put a breakpoint before or after that line (the loadMap), it all works, and I can step out or in, debug it and do all I want to do.
What am I missing?
A couple of seconds after the “failing” breakpoint is hit (and it “hangs”) the stack window clears. I believe all this happens because the gdb has stopped, but the question is, why does it stop there? What are the restrictions for this?
I’m compiling with LLVM GCC 4.2 for what is worth (but could probably change to other if that’s the problem, haven’t tried that because I don’t know much about the differences).
Is there something (maybe in your Map class?) that requires timing? For instance, a double-tap that's being interrupted by the breakpoint's being triggered at that spot?
(i.e., no breakpoint => double-tap registered, Breakpoint => second tap comes after breakpoint hits, so only a single-tap is registered.)
I don't see anything like this in your code specifically, but that's the kind of thing that could show mysteriously different behavior between breakpoints on/off.
Is there any way to restart a program in Eclipse? (preferably 1-click)
I really wish the console view had something like a restart button that would kill the app and restart it with the latest changes.
This always takes me at least three clicks. I click the down arrow next to the green circle with white triangle (play button) to open the dropdown menu, then I click to choose the Java main that I want to run, and then to stop I click the red square terminate button in the console view. Is there any easier way to do this that requires fewer clicks?
In Eclipse 4.1
open:
windows->Preferences->keys
in the filter text type: terminate and relaunch
In the binding add your binding (i use shift-F5)
For "when" select "In Windows"
This will do it in single shorcut for you.
Or install relaunch plugin:
https://bitbucket.org/mantis78/relaunch-plugin/wiki/Home
which will enable you to restart anywhere
If you use "build automatically", there is a good chance that your changes are applied on the running program, on the fly. As such, most changes will be effective directly without a need to restart.
If there is a structural difference and Eclipse can't inject the new code (for example if you change anonymous classes, or inheritance patterns), then you will be prompted with a dialog inviting you to restart the application in one click:
Exceptions are when you change the value of a static variable (or of the initialization of a class that won't be executed again until you restart the application). In this case indeed, you will need to restart explicitly with another method.
the console view has a terminate button (a red square) which stops the execution. then another click on the Run button (the green circle with triangle) begins execution again.
thats what i do - 2 clicks :)
If you're using Eclipse with Spring you could download the "Spring Tools X" plugin.
This will automatically add a start and relaunch button to the top bar menu.
It should be available on any perspective.
I haven't found an elegant solution for this problem, but if your program is short running and you can live with a few instances here and there, you can just use the run command. Its default shortcut is Ctrl+F11. Every time you press this, your application will restart. BUT! If you press this while your application is still running, another instance will be run because the "old" instance won't be automatically terminated.
There are ways to really terminate your application using shortcut keys, but that requires setting breakpoints and then using the "terminate" command, and that isn't very elegant.
When developing my own network application, I have added a code to check if the older instance is running, and if so, then send an agreed command over network socket for graceful shutdown. While this approach may not be the best as universal solution, it allows clean shutdown of the previous instance, rather than just killing it.
Easy way without plugin, every Eclipse !
Click the project from of this icon at this time hold the shift Button, Project will restart (Terminate and relaunch) with server port also.
I have unit tests set up for my iPhone project built using the Google Toolkit for Mac framework on top of OCUnit. I have a dependent project called "Unit Tests" that builds and runs the tests as needed.
But then it all stopped working, for no reason that I can fathom. Suddenly, my "Unit Tests" executable launches and just sits there, waiting, forever. It never gets as far as the Application Delegate's -applicationDidFinishLaunching: method, which is what calls the actual unit tests. Inserting an NSLog into the delegate's -init method tells me that that method gets called, but the application never "finishes" launching.
If I modify the shell script that runs the "Unit Tests" executable and take out the -RegisterForSystemEvents argument, the executable exists immediately (it runs no tests) and gives me the following message:
Terminating since there is no system event server.
(Run the EventPump or pass the argument "-RegisterForSystemEvents" if you want to run without SpringBoard.
Since it terminates when I remove that argument, I'm curious what exactly that argument does and how, since it would seem to be causing the hang. But since no tests run without it, I need to determine how I can get it working again. However, Google doesn't provide links to anything relevant to the current situation, and nothing in the dev docs is helpful.
Any ideas?
If Xcode hangs during the build (the build results window shows 'Running custom shell script' but stalls there), select the unit test target and click 'Get Info'. Then select the Properties tab and clear the text field for 'Main Nib File' and clean the target.
Clicking 'Build and Go' should now successfully run the tests.
We fixed this issue as of this morning. Top of tree GTM should not hang anymore. It has to do with the delegate being switched before it had a chance to get the applicationDidFinishLaunching event. More details in this thread:
http://groups.google.com/group/google-toolbox-for-mac/browse_thread/thread/513a3252d655e1e3
In case someone else comes across this, here's what I finally got working.
I made a local copy of the code, then reverted the entire codebase back to a previous commit in my Git repository. That clean checkout could still run tests just fine. I then reintroduced my changes in file by file, checking that unit tests worked after each incremental merge.
I expected to hit some point when the unit tests stated failing, but it never came. I merged all the changes in and the unit tests were still running fine.
Obviously, this isn't going to be of help to anyone who doesn't have a SCM system with a working copy to revert to. In that case, making a clean project and pulling your code over would be the best option.
I had this same problem - looks like I had messed up my AppDelegate in IB.
Make sure:
You have your AppDelegate class
instanced in the NIB.
That its window outlet points at
the UIWindow in that NIB.
That any other outlets point where
they should (in my case,
tabBarController to my instanced
UITabBarController).
And finally that your File's Owner
delegate outlet points to your
AppDelegate
Whew.