iOS building issues trying to develop a cn1lib

55 views
Skip to first unread message

Ivan Stoiev

unread,
Jun 24, 2014, 12:30:51 AM6/24/14
to codenameone...@googlegroups.com, Fabrício Cabeça
Hi Guys

I was trying to develop a cn1lib inspired on TelephonyManager API from Android, at least for Android and iOS.
For Android everything worked just fine, but for iOS I'm facing building problems.

My knowledge on Objective C and Apple build stuff was basically nothing, so I created a xcode project using the generated *Impl.h and *Impl.m from "Generate Native Access" on NetBeans as recommended on video tutorial, and created a native interface only to test the "native component".
To let things more clear, I've added an extra header file basically with a lot of #define directives (loosely based on the results of j2obc conversion tool, running on a Constants.java already existent on my cn1lib - the result file is attached).

On xcode project, I've got everything working fine (on a simulator), but trying to build remotely, seems like that my extra header file is indigest.
Seems like the remote building is trying to compile a com_codename1_telephony_Constants.m that does not exists:

CompileC build/TestApp.build/Release-iphoneos/TestApp.build/Objects-normal/armv7/com_codename1_telephony_Constants.o ../build/xcode/src/app/com_codename1_telephony_Constants.m normal armv7 objective-c com.apple.compilers.llvmgcc42

And after this command, there is a lot of compile errors:
build/xcode/src/app/com_codename1_telephony_Constants.m:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__TIB_com_codename1_telephony_Constants'
...
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build3644309836102685804xxx/dist/../build/xcode/src/app/com_codename1_telephony_Constants.m:843: error: '__TIB_com_codename1_telephony_Constants' undeclared (first use in this function)

It's posible to do something like this, I mean, aggregate extras (not *Impl.*) native files in a cn1lib for iOS? If it's posible, for each .h file is necessary a .m? It's posible to use precompile directives?

I can change my approach trying to define my constants with "extern const int MY_INT_CONST;", but I'do like to know if there is something that can be done to maintain the j2obj based conversion script (avoiding rewrite stuff now and automatize future Constants.java changes).

PS: I'do like to publish this project on github and make it open. I don't know if there is some guideline for this, I mean, now I'm using com.codename1.telephony namespace, so I don't know if is better to use com.codename1x or even not use codename1 at all. At the moment, it basically has one class (TelephonyInfo) that gets MNC, MCC, country code and carrier name from Androids (Network and SIM data) and iOS (from SIM only, due Apple restrictions). The cn1lib is basically a TelephonyManager (from Android) and CTTelephonyNetworkInfo (iOS) mesh up.

Thanks and Best Regards
com_codename1_telephony_Constants.h
error (8).txt

Shai Almog

unread,
Jun 24, 2014, 1:17:14 AM6/24/14
to codenameone...@googlegroups.com, fabrici...@gmail.com
Hi,
search the log for com_codename1_telephony_Constants.o you will see a list of files pointing to the m file at line 8 etc.  If you did something like extend a constants interface in your native interface I'd avoid that.

Ivan Stoiev

unread,
Jun 24, 2014, 2:10:12 AM6/24/14
to codenameone...@googlegroups.com, fabrici...@gmail.com
Hi Shai,

    From iOS stuff, I have com_codename1_telephony_Constants.h just like I've send, and the tuple com_codename1_telephony_TelephoneInfoImpl.h/com_codename1_telephony_TelephoneInfoImpl.m, generated by NetBeans "Generate Native Access" (com.codename1.telephony.TelephonyInfo extends NativeInteface)

    On top of com_codename1_telephony_TelephoneInfoImpl.m there is a #import  "com_codename1_telephony_Constants.h".

    It's weird this com_codename1_telephony_Constants.o reference. There is no com_codename1_telephony_Constants.m, nor com_codename1_telephony_Constants object or anything that can be compiled referencing *Constants* on iOS "space".

   From the other side (CN1 perspective), there is a com.codename1.telephony.Constants class, but that has no direct reference to iOS files, and it no extends or is extended. But it is used on Android and java-like native's TelephoneInfoImpl. Maybe there is an issue. If builder works converting from java compiled stuff to iOS, Constants.java could be clashing somehow with my Constants.h native file? (both would be using same "namespace" at conversion point).

   It make sense? Or am I talking nonsense.

   Anyway, it seems a "bad practice" to use CN1 classes inside *Impl* native files, even when is posible (for Android worked, I do not replicated CN1 Constants.java). I will try to decouple things here and see what happens.

Thanks

Ivan Stoiev

unread,
Jun 24, 2014, 11:07:36 PM6/24/14
to codenameone...@googlegroups.com, fabrici...@gmail.com
Thanks Shai, avoiding same class names between native and CN1 clases do the job. There is other issue that i`m facing, but I post on another thread.



On Tuesday, June 24, 2014 2:17:14 AM UTC-3, Shai Almog wrote:
Reply all
Reply to author
Forward
0 new messages