NOTE: This project is no longer maintained. I recommend using the supported build workflow for Codename One as described on the Codename One website.
This repository contains an ANT task to build Codename One applications locally. This project is targetted specifically at iOS builds.
NOTE: If you are using Netbeans, then you might want to check out the Codename One Offline iOS Build Netbeans Module. It bundles this task into a Netbeans module so that you can build your Netbeans-based Codename One projects locally without having to fuss with any build scripts.
This ANT task is designed to be used for development builds only. It includes modifications to XMLVM to allow generated classes to be more self-contained, and thus optimized for faster compilation (when changes are made). These changes are experimental and may not work correctly in all cases. You are advised to use this module only as a tool to speed your development process.
PLEASE USE THE Codename One Build Server for all of your production builds, and for anything you wish to distribute for use by other users.
**ALSO NOTE:* This project is not affiliated with Codename One, the company. It is a community project maintained by Steve Hannah. Builds produced by this project are not supported by Codename One**.
Therefore, if you have questions or issues related to applications you have built using this tool, and you post questions to the Codename One mailing list, Stack Overflow, or any other forum, please state clearly that the build was produced using this project, and not with the build server. You will likely be asked to try building with the build server before asking for support.
If you find bugs, or have questions relating to this library, please post them to the issue tracker.
The easiest way to install this ANT task is by installing the Codename One Offline iOS Build Netbeans Module module.
If you would prefer to just download and install the ANT task on its own, the instructions are as follows:
<property name="libs.cn1-ios-all.classpath"
value="path/to/CN1LocalIOSBuild.jar:path/to/commons-io-2.4.jar:path/to/xmlvm.jar"
/>
<taskdef name="buildios"
classpath="${libs.cn1-ios-all.classpath}:${javac.classpath}"
classname="ca.weblite.codename1.ios.CodenameOneIOSBuildTask"
/>
buildios
task that was defined:
<buildios xmlvmclasspath="${libs.cn1-ios-all.classpath}"/>
Note: the xmlvmclasspath
paramter is required, and it needs to at least include the path to the xmlvm.jar
file.
Name | Description | Default | Required |
---|---|---|---|
xmlvmclasspath | A classpath containing at least xmlvm.jar | - | Yes |
iosport | Path to the iOSPort directory. If this is omitted, it will just use the bundled iOSPort, which will be extracted to $PROJECT_DIR/iOSPort | $PROJECT_DIR/iOSPort | No |
codenameonesrc | Path to the CodenameOne sources. If this is omitted, it will just use the bundled Codename One sources extracted to $PROJECT_DIR/CodenameOneSrc | - | No |
clean | Whether to build it clean or not | false | No |
In addition to the default task (ca.weblite.codename1.ios.CodenameOneIOSBuildTask
), there are two other tasks defined in this module:
ca.weblite.codename1.ios.SetupXcodeProject
- A wrapper task that only creates the Xcode project, and only if it doesn't exist or the "clean" parameter is passed. This takes the same parameters as ca.weblite.codename1.ios.CodenameOneIOSBuildTask
.ca.weblite.codename1.ios.OpenXcodeProject
- A task to open the previously generated Xcode project.
<taskdef name="openxcode"
classpath="${libs.cn1-ios-all.classpath}:${javac.classpath}"
classname="ca.weblite.codename1.ios.OpenXcodeProject"
/>
<openxcode/>
An easier way to use this task is to simply install the Codename One Offline iOS Build Netbeans Module. It provides you with menu items for each of the ANT tasks provided in this module. It also works with the Netbeans Update Center so that you can more easily stay up-to-date with the latest version of the module.
This task creates an Xcode project inside the build directory of your Netbeans project. (Actually it generates a sub-netbeans project at build/ios
, which itself generates an Xcode project at build/ios/dist/ProjectName.xcodeproj
). This Xcode project will include all of the generated C-sources produced by XMLVM in the conversion process. You should be able to build this Xcode project and run it either on the iOS simulator or on an actual device.
Initial builds are very slow since it requires converting all application files, codename one files, and much of Apache Harmony into C source files, then building these generated sources in Xcode. On my iMac with a 2.7GHz Intel Core i5, the full clean build of a moderately complex application takes about 15 minutes.
Subsequent builds should be much faster, depending on how many classes were changed. Generating C source files for changed Java files takes between 10 and 30 seconds usually. Then re-compiling in Xcode takes another 5 seconds or so.
This module will create a hidden .xmlvm directory inside your project directory to store cached files to help with dependency management and for speeding re-compilation.
On the initial build, quite often, the Xcode project will be set to use an unsupported compiler. If you try to build your project, it will fail. If this occurs, you should set the "Compiler for C++/Objective-C" in the "Build Settings" tab of your project properties (inside Xcode) to the "Default Compiler" as shown in the screenshot below:
It should then build properly.
Building from source is most easily done by cloning the repository, opening the project in Netbeans, and just building the project normally. The jars will be saved in the dist directory.
The github repo includes ZIP files of all of the Codename One sources that will be included by default.
build.xml
file in your local copy so that all of the paths in the bundle-iosport
target point to your local Codename One sources that you downloaded in step 1.bundle-iosport
target:$ ant bundle-iosport
Alpha. Currently the code is a mess and really needs a refactor. That said, it should work for simple apps.
This project bundles the entire Codename One codebase in it, which is licensed under the GPL with Classpath exception. See the Codename One website for more details on the license.
If you spot anything else that doesn't work, please post in the issue tracker.