Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Cross-platform Services

surlacsurlac Posts: 315New Users
Is there any way to write classes that interact with web-services and compile it in a library (*.so shared lib probably)?
The purpose is to attach that lib to Android app in the future.

Replies

  • mashercakesmashercakes Posts: 748Registered Users
    You can, but an iOS shared library won't work on Android without being recompiled.
    TalkBoard - a communication aid and visual support app for children and adults with autism, communication difficulties or learning difficulties. Available now for iPad, iPhone and iPod Touch.
    surlac
  • surlacsurlac Posts: 315New Users
    Will I be able to expose all interaction with services within this library? I mean, can I use some iOS-specific classes (ASIHTTPRequest library for example) or I forced to work with low-level classes (raw sockets) to make it work on Android? Thanks, mashercakes! It's all pretty fuzzy for me right now.
  • mashercakesmashercakes Posts: 748Registered Users
    Depends what to mean by "expose". If you mean reveal to the user which API calls are being used, then probably not since the library is precompiled. If you just mean can the library access the iOS API, then I don't see why not. I've never tried it, but a library which can't access the APIs would be pretty useless.

    Here's a link to an iOS static library tutorial. It's just over a year old so won't be up to date with the latest Xcode and iOS, but the principles should still apply. As you can see, the sample code makes calls to NSMutableArray, implying that access to standard iOS objects and methods is possible.
    TalkBoard - a communication aid and visual support app for children and adults with autism, communication difficulties or learning difficulties. Available now for iPad, iPhone and iPod Touch.
    surlac
  • mashercakesmashercakes Posts: 748Registered Users
    Just re-read your post. You definitely won't be able to use high level iOS API calls on android. You'll have to use lower level stuff or it won't cross-compile.
    TalkBoard - a communication aid and visual support app for children and adults with autism, communication difficulties or learning difficulties. Available now for iPad, iPhone and iPod Touch.
    surlac
  • surlacsurlac Posts: 315New Users
    Thank you mashercakes for putting me right! Now it's clear to me, that to make it run on iOS-only devices I can compile it to *.a iOS-level library, and I can include all dependant obj-c libraries (ASIHTTPRequest, etc.).

    But to make it able to run both on Android and iOS I need to go lower, on Unix level and write the lib on C/C++, without calling any obj-c related code. Then I can wrap it with JNI and use in Java code.

    So it looks to me, that writing services-layer twice (both for Android and iOS) will be easier than to go down to unix-programming.
    Post edited by surlac on
  • mashercakesmashercakes Posts: 748Registered Users
    That's absolutely correct. It's just like cross-compiling for Windows and OS X. A library written using Cocoa won't cross-compile on Windows, and one written for DirectX won't compile on OS X. But write the library in a lower-level API which might exist on both platforms and you'll be more likely to be able to cross-compile.

    And I agree, that writing it twice using a higher-level language is probably more straightforward, though others may disagree.
    TalkBoard - a communication aid and visual support app for children and adults with autism, communication difficulties or learning difficulties. Available now for iPad, iPhone and iPod Touch.
    surlac
  • surlacsurlac Posts: 315New Users
    Also, there is one-code-base (hybrid) frameworks like PhoneGap or Appcelerator Titanium, to compile to both platforms, but I have no idea how is it possible to organize Services layer (OData/Rest/WSDL) with such a dynamic thing like JavaScript.
    Can anybody suggest if it is possible?
    Post edited by surlac on
  • mashercakesmashercakes Posts: 748Registered Users
    I'm assuming the JavaScript layer is on the backend, in which case this is only relevant in terms of availability of classes which will interface with it in ways which are useful to you.

    With regard to the "hybrid frameworks" you mention, they probably just use shared libraries which happen to have been ported to several platforms (think SDL). If the code you write around that library is portable (e.g. C++) then it's more likely that your classes will cross compile. At that point in time, your classes' ability to function correctly relies on the library's ability to interact appropriately with the OS on which it is running.
    TalkBoard - a communication aid and visual support app for children and adults with autism, communication difficulties or learning difficulties. Available now for iPad, iPhone and iPod Touch.
Sign In or Register to comment.