Very helpful info Mike, thank you.

I'll fire up Xcode this weekend, give what you're saying a try, and report back.

Thanks!
'(Devin Walters)

> On Jun 12, 2014, at 8:14, Mike Fikes <mikefi...@me.com> wrote:
> 
> Hi Devin,
> 
> A great place to start is 
> http://web.cecs.pdx.edu/~cpinera/javascriptcore-integration-with-clojurescript-in-ios.html
>  (some slight modifications are required to get that blog post examples 
> working with the latest, but it's not that hard).
> 
> Another great resource is the WWDC 2013 video on JavaScriptCore.
> 
> Once you have a sample project up and running, then you are “cooking with 
> fire.” Roughly the workflow involves editing ClojureScript (I use Cursive in 
> IntelliJ, but any IDE would do) where the results of lein cljsbuild auto are 
> being consumed in a “sibling” Xcode workspace. Make a change to 
> ClojureScript, rebuild your Xcode app, observe the change in behavior, repeat.
> 
> Debugging is nearly impossible, so I rely heavily on logging, and on 
> producing lots of pure functions that can be independently verified in a 
> REPL. So the first thing you would want to do is set up things do that when 
> you call a logging function in your ClojureScript, it is routed to iOS and 
> logged in the console.
> 
> To avoid needing to add lots of new JSExport methods for new functionality, I 
> take the approach of writing some plumbing code that can work with the UI by 
> referencing UIComponents via their “tag” integer, which I manually set in IB 
> and then call a “bind!” function in ClojureScript to set up the needed 
> interactions.
> 
> For example, I might have a (def text-field (atom {})) and then in an init 
> method marked ^:export that takes a view argument, I do (bind! text-field 
> view 1), where the literal 1 is the tag for a text field in IB. I've written 
> bind to call into Objective C and register for notifications on that tag, 
> setting things so that, for example, whenever the text changes, it calls back 
> into ClojureScript executing a function that ends up calling (swap! text-view 
> assoc :text updated-text).
> 
> You can take a similar approach to have button tap events drop a message into 
> a core.async channel, and associated plumbing to bind a UI button to the 
> channel.
> 
> The end result is that you can essentially write what would normally be view 
> controller code in ClojureScript.
> 
> A lot of the above (especially the code fragments) are from memory—ask if 
> you'd like more elaboration. But in the end, it's simpler and less elaborate 
> than you might initially think.
> 
> - Mike
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to