A CodeFlow blog

about live coding and more…

CodeFlow 0.9.9: the power of structs

0.9.9 is a great version number for a software. And this is precisely the version number of the new CodeFlow beta, available since yesterday in the downloads section of celedev website.

What is new in this version?

  • Major improvements in the use of C structs from the Lua code: CodeFlow now supports an object-oriented syntax for structs, that makes the code more concise and readable, and enables you to very easily define your own struct methods. This new feature is described in more details below in this post.

  • A better bindings libraries management adapted to the various iOS SDK versions available on the host computer. In particular, CodeFlow can now automatically select the default SDK corresponding to the version of Xcode installed on your development machine. And if you select a specific SDK for your CodeFlow project, CodeFlow will open the associated Xcode project with the right Xcode version for this SDK (on OS X Yosemite only). Really convenient for testing projects that use a beta iOS SDK version!

  • The fix of several problems that could make CodeFlow crash under OS X 10.10 Yosemite.

  • And of course many smaller improvements and bug fixes.

CodeFlow Bindings libraries adopt a new format with this version and need to be updated. In addition, CodeFlow Bindings for iOS 8.2 SDK have been upgraded to match the beta 2 SDK version released by Apple a few days ago.

A new version 0.9.9 of the CodeFlow Sample Applications Package is available too. It includes a new application WatchApp1 that shows how to use CodeFlow to develop an Apple Watch app, and updates of existing applications to illustrate the use of structs with the new object syntax.

[Edit 18 Dec. 2014 22:45 CET] As Apple has just released Xcode 6.2 beta 3, CodeFlow Bindings for iOS 8.2 SDK have been updated to match the iOS 8.2 beta 3 SDK. So has the WatchApp1 CodeFlow sample application, which is now compatible with API changes in WatchKit in iOS 8.2 beta 3.

Using structs in Codeflow

Structs are used heavily in C / Objective-C APIs and the iOS SDK is no exception. Data of struct types, like NSRange or CGRect, are used as parameter or return value in many functions and methods of the SDK. To make the use of these functions/methods possible and practical from the Lua code, CodeFlow supports, since many versions, the transparent conversion from a Lua table to a struct parameter, as well as the reading or writing of struct data fields from Lua.

For example:

local myView = self.view -- self.view is a UIView

-- set a struct value with a Lua table
myView.center = { x = 100, y = 256 }

-- use a struct value in Lua
local center = myView.center -- center is a reference to a C struct
center.x = 50 -- set a struct field
print ("The center is (" .. center.x .. ", " .. center.y .. ")") -- get struct fields

In addition to this basic support, CodeFlow 0.9.9 adds two new tools: struct constructors and struct methods: constructors allow the creation in Lua of a struct with a given type, without necessarily creating it from a Lua table; struct methods provide an easy way to manipulate structs or to get information from them, using a unified syntax with objects, and as a result, improving the code consistency and readability.

All struct types known by the program are stores in a global Lua table struct, that provides a specific namespace for struct types and avoids collision with other Lua global variables. The list of types in the struct table can vary from program to program, as it depends of the frameworks used by the CodeFlow project. For example, in the WatchApp1 application, that uses MapKit, Foundation and CoreGraphics, struct contains the following types:

Struct types in the WatchApp1 app

Struct constructors are used like this:

local CGRect = struct.CGRect -- using a local variable makes the use of CGRect more concise and improves performance in the rest of the code

-- create a CGPoint value with the list of its fields
local point1 = struct.CGPoint (0, 150)

-- create a  CGSize value with a Lua table
local size1 = struct.CGSize {width = 200, height = 100 }

-- create a CGRect value with the list of its fields
local rect1 = CGRect (point1, size1)

-- create a CGRect value with the list of its sub-fields
local rect2 = CGRect (50, 65, size1.width, 500)

-- create an empty CGRect (with all fields set to zero)
local rect3 = CGRect()
rect3.origin.x = 10
rect3.origin.y = 15
rect3.size = rect2.Size

Struct methods can be defined by Bindings Libraries or by your Lua code. Two standard methods are defined for every struct type:

  • copy() that duplicates a struct value
  • hasType(someStructType) that tests if a struct value really has the expected type

And as everything in CodeFlow is compatible with live-coding, adding or replacing a struct method can be done at any time, including in live mode while the app is running.

Here are a few examples of using and defining method structs in Lua:

-- this uses local variables from the previous code sample...

-- duplicate a struct value
local point2 = point1:copy()
point2.x = 10 -- this does not modify point1

-- add a method to CGRect
function CGRect:centeredRectWithSize (width, height)
    -- if the method is called with a single parameter, return a square
    height = height or width
    -- create the centered rectangle (note the use of predefined CGRect methods getMidX and getMidY)
    return CGRect (self:getMidX() - width / 2, self:getMidY() - height / 2, width, height)

if rect1:hasType(CGRect) then
    local rect4 = rect1:CGRect:centeredRectWithSize(50)
    -- use rect4...

You can visualize existing struct methods in CodeFlow Variable Inspector while the app is running, by unfolding a type in the struct global variable:

CGRect methods in CodeFlow Variable Inspector

We can notice here the presence of the centeredRectWithSize method defined in the Lua code (with icon Lua function icon) ; other methods are C functions (with icon C function icon) defined in Bindings Libraries.

Et voilà! This is about all you need to know to use structs in CodeFlow. Quite simple, right?

In any case, as a reminder, CodeFlow beta can be downloaded for free. So do not hesitate to give it a try and to send us your feedback or suggestions, either in the comments of this post, or by sending an email to support@celedev.com.

Read More

CodeFlow 0.9.8-b brings WatchKit support

Only two days after Apple made WatchKit available to developers, you can now live code apps for the Apple Watch by upgrading to the just released CodeFlow version 0.9.8-b, a minor update of CodeFlow public beta. Being that fast to integrate a new technology proves the high flexibility and quality of CodeFlow's underlying live update technology.

CodeFlow 0.9.8-b includes the following new features:

  1. It extends the set of Xcode targets types that can be associated with a CodeFlow project. In particular, app-extensions and watchkit-extensions can now be associated with a CodeFlow project.

  2. It brings more flexible resource handlers for dynamic resource update. A resource handler can now be defined as a pseudo-setter method that can capture variables from the context in which getResource is called (don't panic, this is explained later in this post...).

  3. It includes the bindings library for iOS 8.1 SDK, which is now the default for new projects.

A number of companion downloads are available too:

  • updated versions of the sample applications, using the for iOS 8.1 SDK bindings library and providing example of the new resource handle syntax;

  • Codeflow Bindings for iOS 8.2 beta SDK: a must-have if you want to develop WatchKit apps or use new APIs in iOS 8.2 (needs Xcode 6.2 to be installed) .

  • Codeflow Bindings for iOS 8.0 SDK to be downloaded if you are still using Xcode 6.0 for developing your apps. This bindings library was included in the previous version of CodeFlow, so you don't need to download it if you are upgrading from the previous 0.9.8 version.

WatchKit support

More details about how to live-code a WatchKit app with CodeFlow will be the topic of a dedicated post very soon on this blog. Stay tuned for this.

Extended dynamic resource handlers

The new way of declaring dynamic resource handlers deserve some explanation:

In previous versions, a dynamic resource was associated with an object field like this:

getResource("path.to.resource", "public.image", self, "fieldName")

which has the effect of setting self.fieldName to the current value of the resource after every update of this resource. By declaring a setter for fieldName you can execute a method when the resource was updated and do more sophisticated processing.

CodeFlow 0.9.8-b extends this by allowing the use of a handler function directly in the getResource call. This gives you the opportunity to write more concise code for resource handlers, but most importantly to capture variables from the current scope in your handler. For example, you can now manage a collection of dynamic resources like this:

for i = 1, #resourceNames do
        getResource(resourceNames[i], "public.image", 
                    self, function (self, resourceObject)
                              -- capture the loop index `i` for future updates
                              self.rowImages[i] = resourceObject

Using this version

In case you missed it, CodeFlow is now in public beta, and you can download it and use it freely until the end of the betatest phase.

And you can help us to make CodeFlow even better, by sending general feedback, suggestions for improvements, or bugs reports to support@celedev.com and by accepting to send crash reports when CodeFlow proposes it. Thanks in advance for this.

So, download this version, and start developing your iOS or AppleWatch app in live-coding mode today!

Celedev wins national innovative startups contest

Celedev wins an award for its innovative live-coding technology in the 2014 national contest for innovative technology start-ups…

I'm happy to announce that Celedev has won an award for its innovative live-coding technology in the 2014 national contest for innovative technology start-ups organized by the French Ministry for Research.

This contest rewards each year a small number of start-ups projects or recently created start-ups characterized by an innovative technology as well as a convincing business plan, in various technology areas.

Photo: the award ceremony at French Ministry for Research, on 1st July.

Recent posts

Blog Post
Aug 1, 2016

CodeFlow 1.0.2

CodeFlow 1.0.2 is a minor release that focuses on improving the Live Application Developer's Experience.

Aug 1, 2016
Blog Post
Jun 16, 2016

CodeFlow 1.0.1 and WWDC 2016

The just-released CodeFlow 1.0.1 brings support for the new iOS 10, tvOS 10 and macOS 10.12 announced at WWDC 2016 this week.

Jun 16, 2016
Blog Post
Jun 9, 2016

CodeFlow turns 1.0

It has been some time since the last beta of CodeFlow, version 0.9.20 was released in January this year. And all this time, we have worked very hard to improve CodeFlow, and to turn it into an effective Application Development System that we love to…

Jun 9, 2016

Last tweets

Jun 8, 2018
✅ Wow, @celedev CodeFlow looks really good in dark mode on macOS 10.14 Mojave! 😃
Still a work in progress, but it took me only a few hours to reach this point, while keeping it compatible with macOS 10.11+ 😎
CodeFlow = live-code native iOS apps in Lua celedev.com
Jun 8, 2018
May 17, 2018
🎉🥂Time-Flow, an iOS app created with @celedev CodeFlow by @alf147 is on the AppStore!
The approval process took less than 24 hours. 😎
#LuaLang #livecoding #iOS
May 17, 2018
Apr 2, 2018
Minor CodeFlow update today: v1.2.3 fixes an issue with Xcode 9.3. Check for update or download it directly from celedev.com/en/download/
Apr 2, 2018
Feb 12, 2018
New CodeFlow version 1.2.2 today: it solves an error that could occur when calling certain kinds of Swift closures or ObjC blocks from Lua.
Thanks @alf147 for reporting the issue! 😀
Check for update in CodeFlow, or download version 1.2.2 from celedev.com/en/download/.
Feb 12, 2018
Feb 8, 2018
The LuaPanda 🐼sample application has also been updated for CodeFlow 1.2.1.
To get it from GitHub: github.com/celedev/LuaPan…
Feb 8, 2018
Feb 8, 2018
CodeFlow 1.2.1 is now available for upgrade. This is a bugfix release recommended to all users. 😎
Check for update in the appplication,
or download it from celedev.com/en/download/,
or simply read about the changes here: celedev.com/en/download/co…
Feb 8, 2018
Feb 2, 2018
Live iOS app development strikes back!
Version 1.2 of CodeFlow is out, with lots of improved features, for a unique interactive native app development experience. 😀
- download celedev.com/en/download/
- changelog celedev.com/en/download/co…
(by @celedev)
Feb 2, 2018
Dec 7, 2017
🛠New CodeFlow SDK Bindings are available for all supported Xcode versions: 9.2, 8.3, and 7.3. 😊
Dec 7, 2017
Aug 9, 2017
🛠CodeFlow SDK Bindings for Xcode 9 beta 5 are available for download. Enjoy! 😊
Aug 9, 2017
Jul 11, 2017
New APIs in Xcode 9 / iOS 11 beta 3? CodeFlow supports them from day 1. 😀
🛠 Download updated OS SDK bindings from celedev.com/en/download/
Jul 11, 2017
Jul 2, 2017
CodeFlow 1.1.1 is out, and supports real-time native app development for iOS 11 and macOS 10.13.
Check for update or celedev.com/en/download/
Jul 2, 2017
Dec 5, 2016
"Programming iOS in Lua - A bridge story"
Slides of my talk at Lua Workshop 2016 are here: slideshare.net/jljumpertz/pro…
#lualang #iosdev
Dec 5, 2016
Oct 11, 2016
Little Lua red Panda is now on GitHub! github.com/celedev/LuaPan…
A SceneKit 3D game in #LuaLang with dynamic update of all 3D assets and code
Oct 11, 2016
Oct 3, 2016
CodeFlow 1.0.3 is out!
⚡️ Live SceneKit assets, Sierra support, and more…
#lualang #iosdev
Oct 3, 2016
Oct 1, 2016
@Javi @nicklockwood same and also sad they didn't mention Redux realm.io/news/benji-enc… nor @celedev for Live Reloading & Faster iterations
Oct 1, 2016