Where does Xcode download and install its simulators?

I need to fire off a quick tip before I go to bed tonight. I was stuck on a bad build of an XCode Simulator and I wanted to reinstall it. (Sometimes the downloaded sim is corrupted. This is common in the beta/pre-release builds of XCode.) I had downloaded and installed both 8.4 and 8.1 simulators. Hi, I’m Cliff. You’re here reading this because you suck at uninstalling Simulators in Xcode.

I had the worst luck trying to remove what I’d downloaded and installed. First I tried drilling into the Xcode.app folder to find and remove the downloaded simulator here:
However, after restarting XCode it still “thought” the simulators were downloaded. I even tried deleting the cache folder here:
But I had the same results after restarting. The actual path to the downloaded and installed Simulators (since version 6.x) is:

Talking Web Views

You got this one web view with Javascript and you want to talk to Javascript running in another web view, for reasons that I’m totally unsure of. Maybe you want to impress the girl in the coffee shop with your hard core coding expertise. Maybe you wanna go for a promotion and your manager is all like, “I need to see you innovate!” Maybe you think it’s just cool to load two web views that know one another. Hi, I’m Cliff, you’re here because you want to tote two web views. I’m here to show you how it’s done.

I haven’t posted anything in a month of Sundays. I never understood why people use dumb phrases like “a month of Sundays”. If there were only Sunday “days” in the month then it would be kind of short because you only get four of them… and that doesn’t seem like it makes much sense. I say that because people use that phrase to indicate long elapsed periods of time and a month of Sundays is only four days. People should just get over themselves and say I haven’t seen you in four days without all of the, “I need you to do the Maths and figure out what I’m talking about”. People are dumb. I digress.

I was beginning to tell you about this thing I’m doing with web views. I did it because I’ve been asked how to do it like two times. I got tired of pretending to know what I’m talking about so I prototyped it and I’m going to post my stuff here and just point to this page from now on. Plus, like I said earlier it’s been a month of Sundays (or four days if you don’t like Maths). So here goes. For those three of you who visit regularly I’m sorta back but not quite. Testing the waters a bit.

Back to these talking web views… the idea is simple. a mobile app with Javascript in one web view makes something happen in a second web view in the same app. To make it work you need to know two things, how to call from Javascript into native code and how to call from native code into Javascript. Tonight’s example will demonstrate how we will demonstrate how this is done on Android but I can show the same example on iOS.

Let’s start with main layout saved in a file call main.xml

<?xml version="1.0" encoding="utf-8"?>





We have a linear layout set to vertical orientation. There are two nested WebViews defined, “myWebView” and “secondWebView”. Each will appear one above the other. Next we define a main activity.

package com.example.JavascriptBridge;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class MainActivity extends Activity {
     * Called when the activity is first created.
    public void onCreate(Bundle savedInstanceState) {
        WebView myWebView = (WebView) this.findViewById(R.id.myWebView);
        //Magic Javascript handling class to be defined later
        final JavaScriptHandler scriptHandler = new JavaScriptHandler(this);
        myWebView.addJavascriptInterface(scriptHandler, "MyHandler");
        WebView otherWebView = (WebView) this.findViewById(R.id.secondWebView);
        otherWebView.addJavascriptInterface(scriptHandler, "MyHandler");

We set Javascript enabled on both views. We have a magic Javascript handler class which we will define next. This is a custom class which we stuff inside the first WebView using the addJavascriptInterface() method on the WebView class. This method makes ordinary Java objects appear as Javascript objects to code running inside a WebView. (We will soon add Javascript code that makes calls on the magic class.) Next we load an HTML file, “view1.html” into our first view. We grab our second WebView and give it to our JavascriptHandler which will relay information from the first WebView. We setJavascript enabled on the second WebView and put our magic JavascriptHandler object in it as well, just for good measure. We load view2.html as the content for the second view.

Let’s see our first HTML file, view1.html:

<!DOCTYPE html>
    <title>Javascript Bridge</title>

        Java/Javascript Bridge example
        <form id="inputform">
            Value to pass: <input type="text" name="user_input">
            <input type="button" name="pass" value="relay!" onclick="window.MyHandler.setValue(inputform.user_input.value)">

Not much here. There’s a typical HTML form with an input text field and a button. The onClick() action of the button has Javascript that talks to a special object called “MyHandler”. This object was defined in the Activity above, if you recall these lines:

        final JavaScriptHandler scriptHandler = new JavaScriptHandler(this);
        myWebView.addJavascriptInterface(scriptHandler, "MyHandler");

The handler, which we’ll define next, exposes a setValue method. We call this method and supply the value from the earlier input text field. Let’s see the magic inside the custom JavaScriptHandler class definition.

package com.example.JavascriptBridge;

import android.webkit.WebView;

public class JavaScriptHandler {
    MainActivity parentActivity;
    private String value = "unset";
    private WebView relayWebView;

    public JavaScriptHandler(MainActivity activity) {
        parentActivity = activity;

    public void setValue(String val){
        this.value = val;
        relayWebView.loadUrl("javascript:second_inputform.second_user_input.value='" + value + "'");

    public String getValue() {
        return value;

    public void setRelayWebView(WebView relayWebView) {
        this.relayWebView = relayWebView;

Inside the JavaScriptHandler custom class we have a WebView property, relayWebView which we saw used in the MainActivity. There is also a value property but inside the property set method we have additional logic to relay the value to the relayWebView property. We do this by calling the loadUrl() method on the relayWebView and passing in javascript code using the “javascript:” protocol. (When you ask a WebView or web browser to load a Url prefixed with the “javascript:” protocol is will execute any javascript included after the protocol prefix.) The Javascript assumes there is a “second_inputform” with a “second_user_input” text field and attempts to set the value of this text input. Let’s look at the view2.html which we load into the relayWebView from the MainActivity.

<!DOCTYPE html>
    <title>Javascript 2nd Page</title>
        Passed value shows here!
        <form id="second_inputform">
            Value Received: <input type="text" name="second_user_input">
            <input type="button" name="button" value="reset" onclick="second_inputform.second_user_input.value='enter text above'">

Here you see the “second_inputform” with the “second_user_input” text input. So when the earlier Javascript is injected and executed you will see the text from the first WebView relayed to the second WebView. That’s the entirety of it! Since I haven’t posted source in what we used to describe as a “month of Sundays” but now understand should be much more than a four day-long month, it’s going to take me a while to figure out how to glue my example project to this blog post.

I used to be so much better at gluing code to blog posts but these days I don’t even remember how to log in to my site as the administrator. With any luck, the code will be found as an attachment or maybe something with a little paper clip icon hanging on the side bar. I’m not really sure but I’ll figure that out now. There! I just remembered the Box widget on the right hand side. You can find my Jvascriptbridge.zip project there. Until next time… which might not take an entire month of Sundays if I get my act together…

Getting one’s act together is another one of those things people say. I’ve never acted nor do I belong to a drama club, so I would have a hard time getting my act together. For example, if I had an “act” how did it become disassembled in the first place? I would imagine various pieces of what would have been “my act” scattered randomly on the floor. I would probably hire somebody to piece it back together because I suck at act assembly. That would take a while because last time I looked in the Yellow Pages there was no section for “Act Assemblers”. I could find “Plumber”, and “Doctor” just fine. “Mechanic” was there, as well as “Actor” but not “Assembler”. It’s late, and I probably should go now. If you’re into programming stuff, check back. I promise I won’t ramble senselessly on my next post… unless you like my rambling. And if you do like it maybe I’ll put up one of those PayPal links so people can pay me for rambling. Yes it’s late. I should do other stuff like sleep. Thanks for reading! :)

How to get images in your cod for Blackberry

Such a painful problem it is to create Blackberry software from anything other than their proprietary JDE. There are options, however. There’s some blackberry Ant tools (an independent project and also there’s a few things in the Antenna project). Then there’s RIM’s rapc docs, which aren’t too informative. Finally there’s the post I made a while ago detailing some of the inner workings of rapc. In the post and also in the comments I hint at ways to get images and other resources into the final cod file. To save you the pain of reading there I’ll write about it here. Once you figure out how to compile with RAPC and at least get a working cod file, you need to compile again. The trick is to pickup the jar file that RAPC creates next to your cod and stick images and resources in there. Finally, remove some rapc generated .csi and .cso files before you pass the jar back to rapc. (If you forget to remove these files rapc will complain and list them in the error output, though you might not understand what it’s trying to tell you. Just know if you get an error recompiling jar and you see mention of a file ending in .cs-whatever that you’ll need to remove the file(s) in question.) Here’s some pseudo-code since I’m too lazy/busy/uncertain/tired/vitamin-B-deficient/loaded-with-excuses to post the real solution:

call rapc net_rim_api.jar -midlet -codename MyApp MyApp.jad @myJavafilesList.txt
updateJar MyApp.jar (use images/resources)
removeRapcFilesFromJar MyApp.jar
call rapc net_rim_api.jar -midlet -codename MyApp MyApp.jad MyApp.jar

GMaven for Blackberry development on a Mac?

Ok, it’s been a while but I finally posted the code for GMaven-Blackberry in another blog post.

I’ve gone clear outta my mind. I’m thinking let’s build a blackberry native app on the Mac. Sure! Why not? I mean there’s only the long-standing platform incompatibilities between J2ME and OS X, the windows-oriented nature of Blackberry tools, the mismatch of typical J2ME project structure and Maven project structure and looming deadlines to worry about. And while I’m at it, throw Groovy into the mix, because everybody knows that Groovy has everything to do with writing embedded apps right?

This week I’ve bounced between a Gant build, a legacy Ant build, our multi-module maven JEE project, and brand new GMaven plugin projects. Let’s just say I’m becoming very familiar with the build process in general. Project structure is important. The build system is critical. It is at the root of every successful and failed project in history. Many problems, and resolutions to problems stem from the build/deployment system in place on a given project. It makes sense that as a developer you pay close attention to what’s involved in the building and deployment of your software. Yet soooo many people fail to understand the variables involved in the build tool chain. Many a problem can be tracked to system incompatibilities resulting from version mis-match and/or conflicts. Something as simple as a micro point release difference in your web container or JDK can cause an app to behave wildly different. (Today I tracked a bug down to Tomcat 5.0.28 on a dev box where version 5.5.25 is running in production.) The version numbers of your build tool chain is often the last place developers look when researching a problem. It is the first thing I look for when trying to isolate an issue. I digress.

With all the build tools ranging from Ant to GAnt to Maven to Gradle… (BuildR anybody?) it’s easy to get overwhelmed. I had a buddy remind me how important it is to refrain from going overboard in leading edge-multi-faceted-combined technologies. Stick with proven products yet always look for the next thing. That’s how I feel about Maven. There are alternatives some have better features. However Maven is mature and ubiquitous. I don’t have to pull in yet another runtime to build my project. I don’t need to learn yet another platform. It does its job and does it well. So well that I try to use it for all of my Java work, bringing me to my point. J2ME Blackberry development can be done with Maven. It can be done on a Mac. And at the end of my ordeal it should be painless to do on a Mac.

So why Maven? Why not Ant? The app I’m working on includes several JEE complimentary pieces and I’m sorry but I would rather not touch Ant on a web app project. No way, no how. Furthermore with JEE making up over half of the codebase Maven is the perfect solution for managing the project. We currently have it in use and we have a wrappering pom around the Ant build we use for our J2ME client. That wrapper has been a source of utter pain. So I’ve been looking to figure this out for the longest.

What does Groovy have to do with it? Well I have the Pyx4ME J2ME plugin for Maven working pretty well but there are some obvious holes. First off is a decent deployment mechanism. I need to tie deployment into the modified Antenna OTA servlet we have. Secondly there is no support for Blackberry in the plugin so somebody needs to add it. I started to write a plugin and I just knew I wouldn’t want to be bothered writing it in Java. A couple of minutes after I finished bouncing between 20 different reference articles, APIs, and PDFs and I had the beginnings of the RIM plugin for Maven complete with OS X compatibility. It’s not totally finished yet. I still have issues running the jar signing tool on the Mac. (It should run fine on Windows, and possibly Linux.) But it runs the compiler. I’ve generated a .cod file in the target folder of a prototype project. Interesting stuff indeed.

If that’s not enough, I’ve also managed to launch GAnt from within Maven! Why would anybody want to do this? Maven is become widespread like Ant. If you or your team already use Maven but you want to toy with Something else like Gant you would have immediate access. You don’t need to open your browser, don’t launch Safari, just run Gant:

mvn gant:run

That’s it! And that’s perfect for my current situation where I’m trying to spread Gant across my team. The same applies for Groovy. Don’t go to the codehaus site, just run it!

mvn groovy:console

There’s something to be said about the convenience of a one stop shop. That’s my thing for now. Stop back because I’m gonna continue to post updates on not only Groovy, but Blackberry, GAnt, Maven, maybe even Gradle if I get that far. Holla!

Debug mode on Blackberry

Shamelessly I copy something I found in the Blackberry forums. I don’t know what it means but I DO know it’s one of those things that you have to search far and wide for. Some guy wanted to get into some debug mode that I’d never heard of so he posted his question then later his own answer to the forum thread. Read the solution below:

You must:

1. Have a login/password to https://www.blackberry.com/EngineeringScreens/ (updated 5/30/2008)
2. On the BlackBerry pres ALT+CAP+H and leave it on this screen.
3. Once logged in to the link on #1, you will be asked to enter your PIN#, Uptime and Zip code of where your device is.
4. You will then receive a unlock code that is specific to this information (if you exit out of this help screen on the blackberry, the uptime number will be different thus your code will be different.)
5. Then enter the unlock code on the BlackBerry, holding the ALT key for numbers, capitals are not necissary.
6. This will give you access to the Trace Mode Engineering App
7. Select “Radio Engineering” screen
8. Select “CDMA Engineering” screen
9. Select “Operational Info” (2nd line ec/io, 3rd line rss)
10. Scroll down to “Neighbor Set Details” and get 1st line Active Pilot, 2nd through 20th will give Neighbor sites with ec/io for each.

*This code will only work for 30 days, then you will need to get a new code in the same way.

I got it!

I just ran the Blackberry compiler from Maven… on my Mac. Two cans of Pabst Ice and one Mike’s hard cranberry lemonade into my dev cycle and I finally see a “.cod” file show from a pyx4Me project! It’s in the wrong folder, project root vs. projectroot/target but I can live with that for now. Anyone know a groovy way to set the working directory from a command string run by the overloaded String.execute() method? I don’t wanna call out to Runtime.exec and I don’t wanna write a bunch of platform checks in my plugin. Right now I’m one too many drinks swallowed to know whether or not String.execute() implies platform. In other words I don’t know if I need to code a prefixing “cmd /c ” on my string and check for Windows before calling String.execute(). I’m not happy with the impl because there were a few things I wanted to do better. Right now I’m spawning a java process because the GMaven plugin doesn’t set the rootLoader, which means I can’t dynamically append to my classpath. I’ll either have to set the rapc.jar as a dependency or figure something else out. I’m just glad I got this far! More updates later…

Build Native Blackberry apps natively on a Mac… using Maven!

Click here for the Maven Blackberry code behind this post.

Aight, I can’t help it! I’ve been itching to get this done for sooo long. If you’re into Blackberry development then you’ll understand just how absurd the above title sounds. Let me just throw intelliJ Idea into the mix as well then you’ll begin to see the big picture. Starting to do J2ME development, an experienced Java guy like myself has naturally gravitated towards a certain set of tools. Maven2 is hands down the only acceptable build system for a Java project, while Idea beats the pants off of Eclipse, and Windows boxes…? Forget it! Java runs practically double speed on a *Nix OS plus with the flash of OS X there’s no question as to what boots on a typical knowledgeable hard working Java developer’s box. All of these tools work well, and most of them work well together. BUT… BUT!!! Doing J2ME implies Windows and Ant all around so there’s gonna be either a divorcing of the toolchain or a boatload of integration issues. This weekend I fought through the biggest of the integration issues. And this morning I finally managed to build a Blackberry .cod deployable program… completely without Windows… using a Maven2 pom… natively on my Mac! I’ve been updating my blog incrementally with all of the individual pieces so I won’t go into too much detail here. At a high level I’ll explain the tools involved.

  • One Apple Macintosh (iBook, MacPro, MacbookPro, MacAir, whatever…)
  • One Blackberry (Preferably not Verizon because I don’t think they support J2ME)
  • One Windows install (I know, but this is only to extract the Blackberry tools! You can throw the whole thing away once you got the goods out of the JDE downloads. If you have a buddy that already has the JDE just steal it from him and skip this piece all together.)
  • One install of the Blackberry Java Development Environment (JDE).
  • One bottle of scotch (or wine) for to celebrate with.
  • One install of Maven2
  • Two tablets of asprin (to handle the hangover after you’ve spent the entire rest of the day celebrating with scotch or wine.)

I think that’s everything in the ingredients list. I’ll post back later with the recipe as time allows.