Offline Build HowTo

1,430 views
Skip to first unread message

jon....@gmail.com

unread,
Aug 22, 2012, 9:23:21 PM8/22/12
to codenameone...@googlegroups.com
I've searched google but I can't seem to find any info / howto on offline builds.
I'm specifically looking for iOS offline building tips.

Thanks!

Shai Almog

unread,
Aug 23, 2012, 3:59:00 AM8/23/12
to codenameone...@googlegroups.com, jon....@gmail.com
The process is very complex and not officially supported, the source code is out in our repository but we just don't want to support all the questions/problems people will run into.

jon....@gmail.com

unread,
Aug 23, 2012, 1:30:48 PM8/23/12
to codenameone...@googlegroups.com, jon....@gmail.com
Understood. I just read the FAQ and saw the line "Please note that we do not provide instructions or support for offline building however plenty of resources exist on the internet for doing that." -- I couldn't find anything.

I'll take a peek at the src to see if I can figure it out for myself but if you have a link to one of these resources you mentioned in the FAQ I would greatly appreciate the help.

Shai Almog

unread,
Aug 23, 2012, 3:05:40 PM8/23/12
to codenameone...@googlegroups.com, jon....@gmail.com
There are lots of instructions for building for devices only not for iOS. Check out Eric's posts/blog and I answered some questions on this here as well.
However, iOS is just much harder.

jon....@gmail.com

unread,
Aug 23, 2012, 5:58:40 PM8/23/12
to codenameone...@googlegroups.com, jon....@gmail.com
I've seen a few mention's of Eric's blog -- is this the one: http://gadgets.coolman.ca/
Thanks for responding to me n00b questions!

jon....@gmail.com

unread,
Sep 2, 2012, 12:29:19 AM9/2/12
to codenameone...@googlegroups.com, jon....@gmail.com
I've poked around the src and I think I'm getting closer.
I've built a skeleton project using xmlvm from the cn1 repo.
I grabbed the relevant source from a HelloWorld cn1 project and I'm able to get it to compile in xcode but when I run it in the native emulator I am just seeing a white screen which givez a null pointer exception if I click / touch it.
I could be wrong but I believe I'm just missing some bootstrap code to tell the IOSImpl / CodenameOne_GLAppDelegate which class to load (in this case I left everything default in the cn1 HelloWorld app so it would be something like "com_mycompany_myapp_MyApplication").

I've taken a few shots in the dark but I'm getting no where fast.
I've tried every method that looked remotely useful on "com_codename1_impl_ios_IOSImplementation" to feed it a reference to my "com_mycompany_myapp_MyApplication" class.
I also looked at the sample xmlvm demo projects and they don't actually use a MainWindow xib (they take care of initing the UIApplication separately) so it isn't much help for properly initing my cn1 app.

I understand and appreciate that you're not wanting to support the build process but I'd certainly appreciate any guidance.
Once I get this working I'll certainly share detailed instructions with the rest of the community here.

Shai Almog

unread,
Sep 2, 2012, 3:45:04 AM9/2/12
to codenameone...@googlegroups.com, jon....@gmail.com
In the main(String[]) you need to call Display.init() with a runnable instance. This method will block but your run code should just call the init()/start() methods.

That's the gist of it.

jon....@gmail.com

unread,
Sep 2, 2012, 6:36:41 PM9/2/12
to codenameone...@googlegroups.com, jon....@gmail.com
That did it! Thanks so much for your help!
With your permission I'll post detailed steps in a separate thread.

Raanan Nevet

unread,
Sep 12, 2012, 11:21:02 AM9/12/12
to codenameone...@googlegroups.com, jon....@gmail.com
Hi, did you make that post with the steps? I am very interested in the offline build process for IOS as well.

Regards,
Raanan

jon....@gmail.com

unread,
Sep 12, 2012, 11:24:52 AM9/12/12
to codenameone...@googlegroups.com, jon....@gmail.com
I didn't actually get the nod from the CN1 team yet. I'm happy to share my steps if Shai and team approve (I don't want to undercut their service offering / source of income).

@Shai - is it OK to post the steps here?

Shai Almog

unread,
Sep 12, 2012, 3:13:47 PM9/12/12
to codenameone...@googlegroups.com, jon....@gmail.com
Our concern isn't lost revenue, the amount of money we charge for subscription is negligible and doesn't come close to cover our costs.

The concern is about support and overflowing the forum with people trying to "figure this out". I helped you go through because you figured it out by yourself hence you don't need much support here (sort of trial by fire). Personally, I'm more in favor of that approach. Its not a process for the faint of heart.

What I don't want is:
1. This developing into many long threads about this that will drown out other discussions.
2. People turning to us expecting help on this from us or complaining on why we didn't support them here.

If you want to write down the steps that's fine, I suggest you define clear boundaries and expectations though.

jon....@gmail.com

unread,
Sep 12, 2012, 3:32:38 PM9/12/12
to codenameone...@googlegroups.com
Fair enough. Here it is for all to try then ...

=== Disclaimer ===

    1) I don't work for CN1 (in fact I'm very much a n00b)
    2) I've not tested these steps from start to finish -- it took many hours of trial and error to get this working and some of this is from memory
    3) The CN1 team has explicitly stated that they do NOT support this process so use at your own risk (or just use their build server)
    4) I'm not prepared to answer a lot of questions about this process but as a good OSS citizen I'll do my best to help you along if you get stuck
    5) You probably want to avoid this unless you've used tools like ant, Xcode, Netbeans and xmlvm before


=== Prerequisites ===

    1) OSX with Xcode 4.4 (don't forget to install the command line tools)
    2) JDK 7 with Netbeans 7.2 + the CN1 plugin
    3) subversion



=== Procedure ===

    1) Grab the latest CN1 trunk

        $> svn co https://codenameone.googlecode.com/svn/trunk/ cn1-trunk-read-only


    2) Install xmlvm

        $> cd cn1-trunk-read-only/Ports/iOSPort/xmlvm/
        $> ant
        $> echo "xmlvm.install=/opt/xmlvm" >> properties/local.properties
        $> ant install


    3) Create an iOS skeleton
        
        $> cd ../../../../
        $> /opt/xmlvm/bin/xmlvm --skeleton=iphone --out=tester --app-name=Tester

        - edit 'tester/xmlvm.properties' and change 'xmlvm.backend=objc' to 'xmlvm.backend=c'


    4) Copy CN1 java src files into iOS skeleton

        $> cp -a cn1-trunk-read-only/CodenameOne/src/* tester/src/java/
        $> cp -a cn1-trunk-read-only/Factory/src/* tester/src/java/
        $> cp -a cn1-trunk-read-only/Ports/iOSPort/src/* tester/src/java/


    5) Put CN1 native files in an xmlvm plugin

        $> mkdir tester/src/objc/ && cp -a cn1-trunk-read-only/Ports/iOSPort/nativeSources/* tester/src/objc/
        $> cd tester/src/ && jar cvf cn1_native.jar objc && mv cn1_native.jar ../ && cd -


    6) Add the cn1_native.jar to the runtime classpath of the iOS skeleton
        
        - Open the Netbeans project generated by xmlvm (you should be able to simply open the 'tester' folder)
        - Right-click on the Tester project and go to 'Properties > Libraries > Run' and add the cn1_native.jar
        

    7) Give ant extra memory to build the Xcode project in the iOS skeleton

        - edit tester/nbproject/build-Xcode.xml and change '<jvmarg value="-Xmx512m"/>' to something like '<jvmarg value="-Xmx2G"/>'


    8) Create a new HelloWorld CN1 project in Netbeans

        - This is the porject where you can write and test you CN1 project using the Java emulator
        - There will a few java src files automatically generated
        - You need to add one additional java src file with a main method as follows:

        package com.mycompany.myapp;

        import com.codename1.ui.Display;

        public class Main implements Runnable{
            
            private MyApplication ma;
            
            public static void main(String agrs[]){
                Display.init(new Main());
            }

            public void run() {
                ma = new MyApplication();
                ma.init(this);
                ma.start();
            }
            
        }


    9) Copy the java src from your CN1 project to the iOS skeleton

        $> cp -a ~/NetBeansProjects/HelloWorld/src/* tester/src/java/


    10) Build Xcode project

        $> cd tester
        $> ant

        - it will try to open the Xcode project automatically and sometimes fails (just open the 'tester/dist/Tester.xcodeproj' file)


    11) Remove duplicate symbols (if you figure out how to get rid of this please share)

        - edit org_xmlvm_iphone_NSString.m and change method signatures:

            'JAVA_OBJECT fromNSString(NSString* str)' to 'JAVA_OBJECT hide_fromNSString(NSString* str)'
            'NSString* toNSString(JAVA_OBJECT o)' to 'NSString* hide_toNSString(JAVA_OBJECT o)'


    12) That's it! Run your project in the native emulator like any normal Xcode project


If you have any constructive criticism or suggestion to improve this process please share.

Raanan Nevet

unread,
Sep 12, 2012, 4:35:38 PM9/12/12
to codenameone...@googlegroups.com, jon....@gmail.com
I'm actually going to do this process once to prove that I can do it, the reason being, I want to use CN1 commercially for projects and I want to be sure that I can fully support these projects, therefore I need to be able to compile them myself without a blackbox server. 
After this one attempt I'm going to continue using the server which is very convenient and elegant solution for this complicated process.

I'm going to try and achieve this without questions, I hope I can contribute more after. 

Thanks both of you.

balt...@gmail.com

unread,
Sep 22, 2012, 2:40:54 PM9/22/12
to codenameone...@googlegroups.com, jon....@gmail.com

Hi, there!


I've searched google but I can't seem to find any info / howto on offline builds.
I'm specifically looking for iOS offline building tips.

I've already read a lot about this issue, I understand that online building is great for iOS releases. However, I haven't found any info on Eric Coolman's blog. Also, I am more interested in Android releases than in iOS.

I know I can browse the free repository, but, before doing that, would it be simple/sane to build the android apk from a codenameone project?

Thanks !

jon....@gmail.com

unread,
Sep 24, 2012, 12:03:34 AM9/24/12
to codenameone...@googlegroups.com
Android isn't too bad at all (it is all Java).

Eric Coolman

unread,
Sep 24, 2012, 1:38:19 AM9/24/12
to codenameone...@googlegroups.com, jon....@gmail.com
It is relatively straightforward, but there's few other things, classes need to be converted to DEX, resource files go into the asset/ directory, jars zipaligned, and packaged to apk, all those tools included in the ADT under 'tools'.  Some, such as apkbuilder, has been deprecated since I last used them so I'm not sure what the current replacements are.

I haven't blogged about building the binaries yet, I use Maven for that, so it'd be too much to describe.  I will be releasing something that will help, but don't have a timeframe at the moment - partly due to a google code bug.

Eric

shannah

unread,
Dec 13, 2012, 7:05:12 PM12/13/12
to codenameone...@googlegroups.com, jon....@gmail.com
I have created an ANT target for building CodenameOne apps locally based on these instructions.  I have posted the target and build instructions in my blog.

Thanks for posting the instructions as I wouldn't have known where to begin without them.

-Steve

ST.RE

unread,
Jan 26, 2013, 10:26:38 AM1/26/13
to codenameone...@googlegroups.com, jon....@gmail.com
Hi Steve,

i followed your instruction for the offline build but the build in xcode failed.

d: warning: ignoring file /Users/xxx/NetBeansProjects/ProjectOne-Mobile/dist/app/resources/libzbar.a, missing required architecture i386 in file /Users/xxx/NetBeansProjects/ProjectOne-Mobile/dist/app/resources/libzbar.a (2 slices)


Undefined symbols for architecture i386:


  "_OBJC_CLASS_$_ZBarReaderViewController", referenced from:


      objc-class-ref in IOSNative.o


  "_ZBarReaderControllerResults", referenced from:


      -[ScanCodeImpl imagePickerController:didFinishPickingMediaWithInfo:] in ScanCodeImpl.o


ld: symbol(s) not found for architecture i386


collect2: ld returned 1 exit status


Do you know a solution for that problem?

Thanks

Steve Hannah

unread,
Jan 26, 2013, 10:38:51 AM1/26/13
to codenameone...@googlegroups.com, jon....@gmail.com

Building for the simulator doesn't work.  You need to build for device.

Unless you comment out all of the references to libzbar.

Steve

--
--
You received this message because you are subscribed to the Google
Groups "CodenameOne Discussions" group.
 
For more information about Codename One please visit http://www.codenameone.com/
 
To post to this group, send email to
codenameone...@googlegroups.com
To unsubscribe from this group, send email to
codenameone-discu...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/codenameone-discussions?hl=en?hl=en
 
 
 

ST.RE

unread,
Jan 26, 2013, 11:50:01 AM1/26/13
to codenameone...@googlegroups.com, jon....@gmail.com
Hi Steve,

you said it is only possible to build for device. I had never used xcode before, so please can you give me a hint how i can do that!?
I can't find a xcode menu option like "Build for device..."

Thanks!

Steve Hannah

unread,
Jan 26, 2013, 2:09:20 PM1/26/13
to codenameone...@googlegroups.com
Short answer: If you have your appropriate developer keys installed
in your keychain, and you have the provisioning profile set up on your
phone properly, then you can just plug in your phone, and Xode will
list your iPhone (or iPad or whatever) in the list of build targets.
Just select that.

The long answer is that I you should go through the documentation in
Apple's developer section (or any of the many tutorials on the net)
that describe how to set up your device for development in Xcode if
you run into problems. I spent almost en entire day fighting with
Xcode and provisioning profiles, etc... the first time I set up my
iPhone for development in Xcode. But I'm guessing you already have
the keys and provisioning profiles sorted out if you were already
building for your device on the build server... so it should be much
easier.

-Steve
>>> codenameone-discu...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/codenameone-discussions?hl=en?hl=en
>>>
>>>
>>>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "CodenameOne Discussions" group.
>
> For more information about Codename One please visit
> http://www.codenameone.com/
>
> To post to this group, send email to
> codenameone...@googlegroups.com
> To unsubscribe from this group, send email to
> codenameone-discu...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/codenameone-discussions?hl=en?hl=en
>
>
>



--
Steve Hannah
Web Lite Solutions Corp.
Screen Shot 2013-01-26 at 11.06.55 AM.png

ST.RE

unread,
Jan 27, 2013, 5:49:26 AM1/27/13
to codenameone...@googlegroups.com
Great, thanks!
>>> For more options, visit this group at
>>> http://groups.google.com/group/codenameone-discussions?hl=en?hl=en
>>>
>>>
>>>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "CodenameOne Discussions" group.
>
> For more information about Codename One please visit
> http://www.codenameone.com/
>
> To post to this group, send email to
> codenameone...@googlegroups.com
> To unsubscribe from this group, send email to

bouwme...@gmail.com

unread,
May 30, 2013, 4:04:09 AM5/30/13
to codenameone...@googlegroups.com, jon....@gmail.com
 
After building and opening the project in XCode I get the following result:

#include "org_xmlvm_iphone_NSString.h"

and the error is "Org_xmlvm_iphone_NSString.h: No such file or directory"

The full section is located in native_org_xmlvm_runtime_XMLXMUtil.m:

#ifdef __OBJC__
#ifndef XMLVM_NEW_IOS_API
#include "org_xmlvm_iphone_NSString.h"
#else
#include "org_xmlvm_ios_NSString.h"
#endif
#endif
Why is that library not included in my project?
(I followed the Steve Hannahs blog on offline building codenameone )
Reply all
Reply to author
Forward
0 new messages