Utilizing resources of separate apps on OS X - objective-c

Is it possible to write software on the mac that will launch other separate applications, tell them what to do, etc etc? What language would best suite doing this? (Assuming it's Mac specific).
I'm fairly new to Mac programming, though I have a strong background in iOS. I've seen multiple companies in the past write a script that will cross-compile source code, basically you run your app from the Terminal and it floats around your OS, grabbing what it needs to compile and spits out an Xcode, Eclipse and Unity-ready versions of your source code. I'm familiar with iOS, and how it crashes the second you try to use another apps resources. That is what leads me to the original question:
Is it possible to write software on the mac that will launch other separate applications, tell them what to do, etc etc? Specifically tasks like launch Safari, take a screenshot, launch disk utility, launch mail, email screenshot. I know that OS X allows you to play around a bit more than iOS, but the question is how much.

It's still rather up to what each app will let you do, rather than just being able to do anything, but take a look at OS X's scripting/automation abilities. Primarily this is accessed through AppleScript, but there's now a JavaScript frontend as well (new to Yosemite).
If you're looking at building a native application that takes advantage of other applications, the same scripting abilities can also be reached via the Scripting Bridge from Cocoa (Objective-C/Swift).

Related

How can I use a UWP Class Library for scripting?

I have a UWP Class Library project (written in C#) with some useful utility classes and functions. I want to create a script that uses these classes and functions and runs a few times a day automatically. What is the best way to achieve this?
Should I create an app? If so how can I make it run a few times a day?
Should I create a classic console exe program and run it using a script? If yes, can console apps use UWP class libraries?
Should I create a Windows Runtime Component with background task?
Or some other solution?
Assuming that you're definition of "scripting" can be stretched to mean "run an app" there's lots you can do. If you want something that will be seen as a more traditional script then the best you can do is compile the code in a standard .Net class library (not a UWP one) and then call it from a PowerShell script. If you can run apps then there are a few options and the most appropriate will probably depend on the device they're running on, how often you want them to run, and what they actually do.
As you're talking about a UWP app we should allow for it running on different "device families". The easiest way to run on different devices (desktop & phone, etc.) is to have a periodic background task. At time intervals defined by you it will try and run. Subject to connectivity, power, etc.
Because you said a console app was an option then you're probably really only interested in a desktop/PC environment. That's where there's the most options.
Firstly, if your code uses UWP/Win10 specific APIs then compiling into a console app probably isn't possible without changing the code. I do many things like you describe in the question and use console apps for this as I find them the simplest to work with.
If you're going to change code, consider moving to using Portable Class Libraries as you'll then be able to link to that code from many different types of app--including traditional desktop and UWP apps.
I'd avoid creating a runtime component unless you really need to as there are lots of potential gotchas.
You can run any app from the Task Scheduler but launching UWP apps is tricky.
You can launch a regular app or script by setting the action of the task to be the exe. (or the exe and passing the script file as a parameter.)
Apps from the store don't have an EXE you can just launch so you need to do a bit more. They can only be launched by the Windows Shell. But, fortunately, there's a way to do this. Have your task start explorer.exe (You'll find it in C:\Windows) and then add the argument shell:AppsFolder\[app-PFN]!App.
Where [app-PFN] is the Product Family Name of the app. You can find the values of all the installed apps on your machine by looking at "C:\Users[username]\AppData\Local\Packages\"
So, you can use this to launch the store app.
shell:AppsFolder\Microsoft.WindowsStore_8wekyb3d8bbwe!App

New to Ipad, familiar with SQL, how to get started

I have been a SQL writer using MS Access some years ago and have been given an IPad upon my retirement. I want to create simple database driven apps using SQL. I have downloaded SQL Lite editor from the Apps Store but it seems to have a big chunk of something missing.
Question. Do I need to have an Apple computer as a workstation and then copy to the iPad, or can I use my Windows 7 PC as the authoring tool.
Where do I find the tools for creating the graphics to enhance database search results?
Do I need to use C or C++ to create the application, as I never got around to learning it.
Odd questions I know, but google searches seem to leave me totally in the dark on this topic, yet I geel that most app's seem to revolve around some database manipulation. Would be helpful if I could find a series fo links somehwere.
best regards
Kaela
Hi
In order to develop native applications to ios devices you need the XCode environment and knowledge in objective c, its a bit odd and there are examples.
for that you will need a mac or run the mac os on a virtual box.
You can also create a non native app such as webapp using HTML5 and js and then import it to the XCode using Phonegap.
By using this method you will be able to create apps for many devices such as android and more and all you will have to do is to import your HTML5 and js into the supporting environment.
Just to warn you about these kind of apps, app store allows only native apps and its better to make native app because it will pass every inspection they make.
Thanks
yes, to develop on Apple's engine, you have to had an Apple computer. However, you can mount a virtual machine running OS X, but it's illegal and very complicated (but doable).
The "bible" for mac developers is here : http://developer.apple.com/.
It's recommanded to write your application in Objective C.

What challenges are there in making an iPhone IDE for Windows/Linux?

First of all, is this possible?
If so:
What challenges would I encounter in making an XCode imitation for iPhone/iPod development for Windows or Linux?
I was thinking about using gcc as the actual compiler for the objective-c and (VB).NET for the IDE. Will that work?
It doesn't need to compile to iPhone OS until it is to be tested on the device or submitted to the app store. Perhaps it will be easier to compile to the local OS format (Windows or Linux) until "prime-time".
Is this concept possible? Comments? Ideas of how to implement?
If you wanted to support all of UIKit and Cocoa Touch, the problems would be insurmountable. You'd spend 2 years trying to get off the ground and then give up, while everyone else had fun developing apps for the iPhone and iPad and other devices. You would regret even trying it.
But if you wanted to create your own framework for making iPhone apps, built immediately on top of OpenGL, it might be possible. You would create a simulator that renders to an OpenGL view, and the final app would also render everything in an OpenGL view, touching none of UIKit. You would use pure C, or some robust cross-platform language like Lua, compiled or even interpreted. Incidentally, that's more or less how the Corona framework does it: built on top of OpenGL, touches little of the iPhone SDK, uses compiled Lua. They developed their own simulator, which only runs on OSX, but could probably relatively easily be ported to Linux.
You could even use Objective-C as the language, and make available a carefully chosen subset of the Cocoa API's by using (the iPhone compatible parts of) GNUstep Base. Then users could use standard classes like NSString.
Still, all of this is mostly interesting as a thought experiment, unless you got a team together to work on this as an Open Source project. It's harder than you think. Your simulator wouldn't be able to emulate the way that memory warnings are generated on the iPhone, for example.
If someone wants to develop iPhone apps on Linux, it makes more sense to just write the whole app in C/C++ using OpenGL, and then basically just smack that code onto a vanilla iPhone OpenGL project. That's the fastest path. The next possibility would be to use another language, which is also not too hard. But an "iPhone IDE" on top of that would be little more than putting an iPhone-like frame around the OpenGL view in Linux.
Actually, Felixyz touched on something your should take a look at. See: http://www.gnustep.org/ . They have binaries for just about every variant of *nix, OS X, and windows. The site claims "GNUstep seeks to be source code compatible with Cocoa and OpenStep, it can thus be used to develop and build cross-platform applications between Macintosh (Cocoa), Unix and Windows." It would be a good jumping off point for such a project,
I doubt all OSX's functionality is covered by GNUStep, but it's a start.
I'd imagine to develop iPhone/iPod apps on an alternate platform, you'd need to get Apple's includes (Legality is likely to be an issue), and apply all their toolchain patches, plus a million other things I'm probably overlooking.
What would be a better project is implementing the missing functions in GNUStep to support OSX apps seamlessly under the host platform. Maybe then you could run xcode native on your desired OS.

OS X Mac and writing a twain scanning application

Can someone point me to the correct place to start development of a twain scanning appliation for the MAC osx. I have done some simple objective c development in the past, but nothing interfacing with a device.
If you're talking about Objective-C and TWAIN on the Mac, this page on the twain.org site has a DMG you can download which contains a sample project called TWAINClientCocoa.
It's from 2002 or something so it requires a little finagling to get it to load and build (rename the .pbproj folder to be a .xcode folder so it will open in Xcode and then do an "upgrade" when you're in Xcode) but it works (just tried it last week) and should give you a good starting point. It relies on the concept of the TWAIN source providing its on GUI but that's something you could modify.
If someone if still interested in this, I have just written a TWAIN client on macOS for my application. This documentation is quite helpful.
The main problem doing this today is that the PicHandle returned by native transfer mode requires some deprecated functions to operate on. On my system (10.13) I can workaround this by making up the headers for those functions but they might be removed totally some time in the future. It's probably worth trying to use memory transfer mode which is more complex.

cross platform development [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have questions on true cross platform development and if it is possible to use ONE platform to develop software.
I have a few applications that I write that work on OS X, Windows and Linux. They all use native platform toolkits with some shared source across platforms. I have to boot to each platform, checkout, compile, etc.
I have in the past tried GUI toolkits like QT (I bought a commercial license for Win, mac, Linus, but very expensive and paying it year after year became hard). I have tried WxWidgets, development moves slow.
So what I am thinking about is there a way to run a single platform and cross compile for other platforms so I can build my products from a single platform.
I favor OS X, is there a way to write apps for OS X, Windows, Linux from OS X where I just need to test on each platform respectively. I have found information on cross compilers, stub compiling, etc, etc.
Does anyone have any thoughts? Is this even possible? Would someone make a killing creating such a beast?
In my company, we use the Mozilla Framework to develop cross platform dictionary products. These applications are based on the Gecko/Necko Browser and most of the development is done via Javascript, HTML, CSS, XSL, XUL,... Of course, our homebrew Search engine had to be cross compiled to the three platforms (with some other code which was first done in JS and then ported to moz' C++ for speed reasons).
In the end, we have a reasonnably cross-platform solution: Our developers mostly work like power web-developers (think client and server side at the same time). Because the Gecko is the same on the three platform, we know it will predictably look and behave the same way (except when there are bugs, but the platform is now quite mature on this point of view).
Our R&D knows how to port slow javascript code to rather quick portable C++ code (you do Mozilla code using the NSPR library, a cross-platform lib). Testing has always to be done on the three platform however, although with time and experience, you get to know what will break where (Font support, Audio support, Flash Support)...
Today, you should probably have a look at XULRunner which is really the Mozilla without any real browser interface (in 2002, we had to dismantle the Mozilla Browser to repaint it in our first product colour). Of course, it works well for simple applications but if you wish to make OpenGL, 3D Audio and other nifty things, XULRunner will appear too limited.
I believe Blizzard has some cross-platform framework for that kind of thing... :)
Good luck!
Pierre.
Trying to develop applications on a single platform that will be used on many platforms isn't a good approach. At best you'll make applications which feel alien to users of the platforms that you didn't develop for.
More likely, you'll run into subtle compatibility problems in areas which you never forsaw. Java is probably the best way to go if you want to go down this route. Cross compiling will lead to autogenerated code that will be a nightmare to debug and maintain.
Certainly, you may be able to use tools for porting in some cases, but I don't think that this is a problem that you can just provide an automated solution for in general.
Well, to be honest, the only guaranteed way to build an app to be cross platform in one go is to use Java, but it requires a rather large runtime to be installed first.
However, if that's not an option, I would recommend keeping an eye on recent developments in Qt - it is now available (or should be soon) under the LGPL, which presumably means you don't need to pay for it anymore. Using GCC with Qt, I've found, works perfectly when cross-compiling on different platforms, as long as you only use Qt's classes/code/objects and make sure that any non-Qt code you create or use is capable of being compiled cross-platform.
You don't mention any specific programming language (but I'm guessing C or C++ because of the GUI toolkits), so it's kinda hard to give a good answer to what you are actually asking.
If you want "true" cross platform, I would first consider if it is possible to solve your problem using a language that is less platform bound. Python, Java and plenty of others allow you to write on one platform, and run on many.
If you still want to use C/C++, GCC gives you the option of cross-compiling, and if you combine that with QT (which will soon be available under the LGPL) you should be able to get something working.
Java has tried to do the write once, run anywhere. It works well in some situations, but there are too many "unique" things in an OS. GCC provided the ability to cross-compile applications, but you run into the same sort of problems. The code will just have better performance. The RIA approach seems to work, but it doesn't feel like a native application.
Even using a cross platform GUI toolkit will not remove all your cross platform problems. There's more to an app than GUI, after all. Cross compiling will never be able to catch all the issues that a native build will catch, either. If you're going to support multiple platforms, you're going to have to at least test on each platform. But hopefully you can perform native builds with all warnings turned on, in addition to testing.
In the past few months, I found a few great videos exploring this topic of cross platform development. I hope you find them useful as well.
QTCreator
http://www.youtube.com/watch?v=aYiPvM7ZRHA&feature=channel
FlexBuilder
http://www.youtube.com/watch?v=_O_xDXRsh3Y&feature=channel
Mono / MonoDevelop
http://www.youtube.com/watch?v=U6VG_Z0aRek
I've personally had success using Silverlight / MacOS X
http://screencast.com/t/if8xenkt
RealBasic
http://www.youtube.com/watch?v=GWipoBeKSRk
For Cross Platform Development you can use Phone Gap, Appcelerator (Titanium), Corona... This all provides a framework based on JavaScript and finally able to run on different platforms. What I am using is Titanium for Mobile Development which allows us to develop applications with Native Codes.... (which is very good advantage). Phone Gap is giving a web app which is not native in general... This softwares are used for development of cross platform supports... with support on Windows, Linux and Mac OS.
Based upon my personal experience, I believe you should adopt Java: you will avoid many headaches.
You develop in whatever platform you like and you deploy in all other platforms with no need of compiling for each target platform, as you mentioned.
For example, I develop under linux, I hit "compile" only once and the resulting file is ready to be run anywhere (windows, mac, solaris, z/OS, you name it). A double click will run it on any platform (Java runtime must me installed, but most users have it installed already and if not, it's a matter of downloading, installing, "Next>", "Next>", "OK").
If you choose the "Java Web Start" deployment method, it gets even easier: the user just clicks the launch button on a webpage and the application runs (if the proper JVM is installed according to what specified in the JNLP descriptor) or the user gets redirected to the Java download page (if no suitable JVM is found).
GUI development (with Swing toolkit) is easy and powerful, especially if you use the right tool (i.e. Netbeans IDE).