GLBasic forum

Main forum => GLBasic - en => Topic started by: coder14 on 2013-Feb-16

Title: iOS & Android Development
Post by: coder14 on 2013-Feb-16
Hello everyone. Of late, I've been trying to compile simple examples, with great difficulty for iOS, and with no success for Android. Are there any practical examples to accomplish this, or tutorials that might help? I can't seem to find any sort of guide in the GLBasic documentation or in this forum.

Does GLBasic pre-compile to Objective-C for iOS, and if so, is the source file accessible/editable? I can only see a bunch of .a and .m files and a .pbxproj file in the distribute folder. And does it pre-compile to Java for Android apps?

Furthermore, would it be possible to access the hardware functions of these devices, like the GPS, compass, phone, messaging, etc.?

Any help or direction would be greatly appreciated.

Thank you.
Title: Re: iOS & Android Development
Post by: bigsofty on 2013-Feb-17
GLB compiles to C++ with some Objective C for linkage. It is then complied to a .IPA via XCode.

GLB also compiles to C++ for Android, with some Java for linkage. It is then compiled to .APK using the Android SDK+NDK.

Both of the above have inline C++ available for native calls to API's(See INLINE in the manual and look into the code archives for snippets) or you could patch the JAVA or iOS Obj-C linkage code within the GLB build chain(not advisable IMHO).

You can see the intermediate C++ code in "C:\Users\UsersName\AppData\Local\Temp\glbasic\". This could be edited and compiled separately but there is no inbuilt method for making these temp file changes permanent though, better off using the INLINE command for that.
Title: Re: iOS & Android Development
Post by: matchy on 2013-Feb-17
Learn how to install a iOS wrapper and there are many examples on the forum.
Title: Re: iOS & Android Development
Post by: coder14 on 2013-Feb-18
Quote from: bigsofty on 2013-Feb-17
GLB compiles to C++ with some Objective C for linkage. It is then complied to a .IPA via XCode.

GLB also compiles to C++ for Android, with some Java for linkage. It is then compiled to .APK using the Android SDK+NDK.

Thanks bigsofty for that answer.  Everything to C++ except for some linker code.

What about hardware access, like the camera, phone, compass, GPS, etc.? There's no mention of them in GLBasic.
Title: Re: iOS & Android Development
Post by: matchy on 2013-Feb-18
Sometimes, I feel invisible.
:sick: :help: :shit:
Title: Re: iOS & Android Development
Post by: r0ber7 on 2013-Feb-18
I saw you matchy! ;-)

I don't know what an iOS wrapper is though. But I was helped by the info given by bigsofty. I'm on a quest to do ads. :P
Title: Re: iOS & Android Development
Post by: coder14 on 2013-Feb-18
Quote from: matchy on 2013-Feb-17
Learn how to install a iOS wrapper and there are many examples on the forum.
Sorry matchy. I did see your answer, but that's just beyond me. All these iOS and Android stuff is alien to me at the moment, and the prospect of learning Objective-C and Java/XML is daunting to say the least.

I may be slow or something, but coming from a BASIC background, I can't understand why it should be such a task to perform a simple string manipulation in those languages (and even in C/C++) when it just takes a couple of simple lines in BASIC.

So, installing a wrapper, let alone an iOS one, naturally escapes my attention.

Nevertheless, thank you for your answer!  :nw:
Title: Re: iOS & Android Development
Post by: coder14 on 2013-Feb-18
Quote from: r0ber7 on 2013-Feb-18I don't know what an iOS wrapper is though. But I was helped by the info given by bigsofty. I'm on a quest to do ads. :P

Hi r0ber7. Any luck with your Android issues?
Title: Re: iOS & Android Development
Post by: matchy on 2013-Feb-19
Are you able to use the forum search feature because there are 9 pages of iOS wrapper info?
Title: Re: iOS & Android Development
Post by: r0ber7 on 2013-Feb-19
Quote from: coder14 on 2013-Feb-18
Hi r0ber7. Any luck with your Android issues?

Still learning. I have knowledge of C/C++ and Java, so that's useful. I have a simple program running on an Android phone right now. It does require some learning, but thanks to this thread now at least I know where to look. Once I understand how wrappers and inline code work, I think I will try to use some native API stuff for testing. There is much info on the forum, but for me sometimes it gets confusing, especially when a certain basic level of knowledge is required to understand what people are talking about. I'm very new to Android development and I'm still learning about the basics, also trying to understand how Eclipse works and so on.
But I think anything can be done, it's just a matter of persistence.  :) Maybe, when I understand a bit more, I will write a tutorial for dummies, but right now I myself am a dummy, lol.
Title: Re: iOS & Android Development
Post by: coder14 on 2013-Feb-19
Quote from: matchy on 2013-Feb-19
Are you able to use the forum search feature because there are 9 pages of iOS wrapper info?

No, 9 pages are returned when a search for "wrapper" is done, but besides one or two slight examples, still no help. Time for you to become invisible again.


Quote from: r0ber7 on 2013-Feb-19Maybe, when I understand a bit more, I will write a tutorial for dummies, but right now I myself am a dummy, lol.

Aren't we all. It'll be really great if the Android & iOS functionalities of GLBasic are extended. But if we need to wrap each and every missing function ourselves, we'll need to get really familiar with Objective-C and Android Java. And if that's the case, we might as well just code in them directly.
Title: Re: iOS & Android Development
Post by: matchy on 2013-Feb-19
Invisible eh?  :rant:   dude, in the future, a new GLBer will be asking the same thing and how will you help?

Unless I have access to more forums, here's an example from the old days for iAd wrapper, where it's actually shared and developed with the community:
http://www.glbasic.com/forum/index.php?topic=4664.0
Title: Re: iOS & Android Development
Post by: Omadan on 2013-Feb-19
Indeed coder which is why I am going to start Obj-c, and focus on that, as I posted the other day.

Though my love for this little program will remain forever, I feel somewhat limited at times, and things are moving way too fast.

:P
Title: Re: iOS & Android Development
Post by: kanonet on 2013-Feb-19
Quote from: coder14 on 2013-Feb-19Time for you to become invisible again.
Made my day!
Title: Re: iOS & Android Development
Post by: coder14 on 2013-Mar-18
Coming back to my original question, I'd like to access iOS & Android hardware functions, like the GPS, compass, phone, messaging, etc.

Can anyone please help me on this? An example on how to initiate INLINE API calls or how to write such a wrapper would be most helpful.

Thank you kindly.


Dear Moderators,
Please don't lock this thread too. I promise to be good.
Thank you.
Title: Re: iOS & Android Development
Post by: matchy on 2013-Mar-18
Quote from: kanonet on 2013-Feb-19
Quote from: coder14 on 2013-Feb-19Time for you to become invisible again.
Made my day!
Now you see me...  :puke: .. now you don't
Title: Re: iOS & Android Development
Post by: MrTAToad on 2013-Mar-18
There are a few bits about for accessing iOS stuff around - and possibly for Android too.  I suspect you'll need to search around for it though.
Title: iOS & Android Development
Post by: Kitty Hello on 2013-Mar-19
I think your expectations are too high. What you want to do is very sophisticated stuff. Sure, if someone writes a library that solves your special problem, its easy. But that is what codig is about. It's reading other code and trying to understand it and then change and extend it to your needs. I think you should start smaller.
Or give exact requirements (what platform, what do you want to access and why). Many problems can be solved a lot easier when we know your background.
Title: Re: iOS & Android Development
Post by: jSmith on 2013-Mar-19
How can I include the iPhone date picker controller into one of my GLB apps? I found this sample which is supposed to display the date picker and I think some other stuff:

Code (glbasic) Select
#import "ViewController.h"
#import "ViewController2.h"



@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
   
    self.countryNames = @[@"Australia",@"China",@"France",@"Great Britain", @"Japan"];
    self.exchangeRates = @[ @0.9922f, @6.5938f, @0.7270f, @0.6206f, @81.57f ];
   
    UIBarButtonItem *nextBarItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFastForward target:self action:@selector(cmdNext_Tapped:)];
   
    self.navigationItem.rightBarButtonItem = nextBarItem;
}


-(IBAction)cmdNext_Tapped:(UIBarButtonItem *)sender{
    ViewController2 *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController2"];
   
    [self.navigationController pushViewController:viewController animated:YES];
}

-(void) viewWillAppear:(BOOL)animated{
   
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - PickerView DataSource

- (NSInteger) numberOfComponentsInPickerView:(UIPickerView *)pickerView{
    return 1;
}

- (NSInteger) pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
   
    //if (component==0) {
    //   return 1;
    //}else
   
    return [self.countryNames count];
}

- (NSString *) pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
    return self.countryNames [row];
}

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
    float rate = [self.exchangeRates[row] floatValue];
    float dollars = [self.txtInput.text floatValue];
    float result = dollars * rate;
   
    NSString *resultString = [[NSString alloc] initWithFormat: @"%.2f USD = %.2f %@", dollars, result,
                          self.countryNames[row]];
    self.myLabel.text= resultString;

}

- (IBAction)txtFieldReturn:(UITextField *)sender {
    [sender resignFirstResponder];
}
@end


Can this be made into a GLB wrapper? There are also many other files in the project like AppDelegate, some .h and .m and .pch files.
Title: Re: iOS & Android Development
Post by: Ian Price on 2013-Mar-19
There's nothing obvious in that code that speaks of dates - seems to be country & currency based. Perhaps it's using a rolling/kinetic display like a date picker, so you can replace that data? Dunno.

Anyway, I presume you mean something like this -
(http://dailycoding.com/FileSharing/iPhone_DatePicker.png)

Could you not use simple arrays within GLB code and sprites to re-create/emulate that? You could then use the data without diving into XCode etc.
Title: Re: iOS & Android Development
Post by: spacefractal on 2013-Mar-19
http://www.glbasic.com/forum/index.php?topic=8660.0 is a example to import functions to integrate iCloud. Im guess its similar here (a hint to Coder14) how to import c code (which is here glBasic is excellent when those basic commands came to short sometimes).

Im wonder too why he asked the same thing again and again, and what glbasic can and not can, and have not researched very much? Glbasic is not designed to integrate with all hardware, but was more designed as a simple language with platform compatible in mind. Glbasic can do extends with inline, which is what im like Glbasic, even there would been no basic anymore. Im personly would also access camera too, but Glbasic could not do that, so im used BlitzMax instead.

PS. I have to say im for some years ago got banned in BlitzMax for a similar reason, which was property my own fault (there was some negative post, and im stupid used some %ยค& words). But oh well, its was just a few days and did apologize soon after. So Im thinks its same here? So give him a change too as me thinks he will learn from that. Also here too, im did clash Spicypixel too with a dumb post, but we did apologize together, so no problems.
Title: Re: iOS & Android Development
Post by: bigsofty on 2013-Mar-20
One of GLBasic strengths is that it is a Basic language with no limitations, if you need something, no matter how low-level or on what supported platform, there is always the option of a small C patch. It's not a matter of what it can't do, it's only a matter of how hard it is to do.
Title: Re: iOS & Android Development
Post by: matchy on 2013-Mar-20
Quote from: jSmith on 2013-Mar-19
Can this be made into a GLB wrapper? There are also many other files in the project like AppDelegate, some .h and .m and .pch files.

As a developer, no because it's a trick question. As a programmer, sure. Create a hello world wrapper and get back to me!
Title: Re: iOS & Android Development
Post by: jSmith on 2013-Mar-20
@Ian: That was just an example. If I can see how to make such a routine into a wrapper then maybe I could try to apply the same method to other Obj-C code.

@bigsofty: It seems that the level of difficulty for this is quite high.

@matchy: If you show me how to create a wrapper maybe I can create a Hello World one.
Title: Re: iOS & Android Development
Post by: matchy on 2013-Mar-21
Try the iOS Keyboard wrapper!

http://www.glbasic.com/forum/index.php?topic=6706.msg67781#msg67781
Title: Re: iOS & Android Development
Post by: jSmith on 2013-Mar-22
Quote from: matchy on 2013-Mar-21
Try the iOS Keyboard wrapper!

http://www.glbasic.com/forum/index.php?topic=6706.msg67781#msg67781

Thanks matchy! I'm studying that now. Darn Obj-C.  :'(
Title: Re: iOS & Android Development
Post by: jSmith on 2013-Apr-16
IRONY! I've been reading up a whole lot on Obj-C, and believe it or not, I am now able to write simple apps in XCode!!!  :enc:

The darn OO syntax still baffles me somewhat, but there are TONS of ready examples for the taking. It even supports OpenGL directly, and I was able to run the MoveMe example on the emulator. And the Interface Builder is WOW Easy! And it's ALL FREE! :booze:

Does anyone else have any hands-on experience with XCode/Objective-C?
Title: Re: iOS & Android Development
Post by: matchy on 2013-Apr-16
Sounds good jSmith. For me, simple Youtube tutorials helped a lot in the starting out.
Title: Re: iOS & Android Development
Post by: r0ber7 on 2013-Apr-27
Quote from: jSmith on 2013-Apr-16
IRONY! I've been reading up a whole lot on Obj-C, and believe it or not, I am now able to write simple apps in XCode!!!  :enc:

The darn OO syntax still baffles me somewhat, but there are TONS of ready examples for the taking. It even supports OpenGL directly, and I was able to run the MoveMe example on the emulator. And the Interface Builder is WOW Easy! And it's ALL FREE! :booze:

Does anyone else have any hands-on experience with XCode/Objective-C?

I just got finished writing an example app for a client, which uses the camera & keyboard. XCode is pretty damn good once you get used to it. I had trouble with [[this]] too at first, but now I'm pretty much used to it. I knew C before this, just not ObjC. Turns out it's pretty similar. :) If I get stuck, Stackoverflow basically answers all my XCode questions.  :good:
Title: Re: iOS & Android Development
Post by: jSmith on 2013-Apr-28
Quote from: r0ber7 on 2013-Apr-27XCode is pretty damn good once you get used to it. I had trouble with [[this]] too at first, but now I'm pretty much used to it.
You took the words right out of my mouth. At first, Apple's Obj-C tutorials confused me with terms like sending/receiving messages to/from classes, but all the those square brackets simply nest multiple function calls within a single line - something that I've done many times in BASIC. Plus, it's so easy to learn when there are tons of ready, working examples. I'm currently studying their OpenGL system, and by simply clicking the OpenGL Game template in XCode's new project window, you instantly get a WORKING MODEL of an OpenGL animation app!

And if ever we get stuck:
Quote from: r0ber7 on 2013-Apr-27...Stackoverflow basically answers all my XCode questions.  :good:
That's a buzzing forum with real experts.  :enc: