Page 1 of 1

Trying to build my first iOS External

Posted: Mon Jul 15, 2013 5:11 am
by Nakia
Hi,

Firstly, let me declare I have zero idea about any other programming language other than LC!!

That being said I am needing to build an IOS External to retrieve the SSID of the currently connected WiFi network (will use mergNic to confirm the device is actually connected to a WiFi Network )

Monte has been a great help and pointed me to a stack overflow question which has given me what I believe I need to achieve this and after following the Externals Guide from RunRev I have managed to make a start.

I am now at the point of adding the required detail to mm file about the "Method" ??? I need to use to do this (Hopefully)

This is the code I have in the mm file from the stack overflow question but I keep getting the following errors in XCode
: Expected a type and : Missing context for method declaration




#import <SystemConfiguration/CaptiveNetwork.h>

+ (NSString *)currentWifiSSID {
// Does not work on the simulator.
NSString *ssid = nil;
NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
for (NSString *ifnam in ifs) {
NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
if (info[@"SSID"]) {
ssid = info[@"SSID"];
}
}
return ssid;
}

this is my .idl file
//
// ioswifissid.lcidlc
// ioswifissid
//
// Created by Nakia Brewer on 15/07/13.
// Copyright 2013 Nakia Brewer. All rights reserved.
//

// The name of the external (note external name must be all lowercase!)
external ioswifissid

use c++-naming
use objc-objects

command currentWifiSSID
out ssid as objc-string



Any pointers would be greatly appreciated...

Re: Trying to build my first iOS External

Posted: Mon Jul 15, 2013 7:42 am
by Nakia
lastly, if anyone has some suggestions on good books/online courses to learn objective c that would be also greatly appreciated..

Re: Trying to build my first iOS External

Posted: Mon Jul 15, 2013 11:34 am
by gpb01
Nakia wrote:lastly, if anyone has some suggestions on good books/online courses to learn objective c that would be also greatly appreciated..
This is a good book that I can suggest ... iPhone Programming: The Big Nerd Ranch Guide http://www.amazon.com/iOS-Programming-R ... anch+Guide ;)

Guglielmo

Re: Trying to build my first iOS External

Posted: Tue Jul 23, 2013 11:14 pm
by Nakia
Thanks for the reply..

I think I will need to cancel this project, obj-c is just beyond my skill set for now until I do a LOT of heavy reading.

Cheers

Re: Trying to build my first iOS External

Posted: Wed Jul 24, 2013 12:06 am
by Simon
Hi Nakia,
There is this:
http://www.runrevplanet.com/index.php?o ... &Itemid=65
But I don't know if Pascal is easier or more difficult.

Simon

Re: Trying to build my first iOS External

Posted: Fri Jul 26, 2013 1:19 am
by monte
Hey Kia... sorry I didn't see this post. You're nearly there mate:

ioswifissid.mm

Code: Select all

#import <SystemConfiguration/CaptiveNetwork.h>

NSString * currentWifiSSID (void)
 {
     // Does not work on the simulator.
     NSString *ssid = nil;
     NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
     for (NSString *ifnam in ifs)
     {
          NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
          ssid = [info objectForKey:@"SSID"];
          if (ssid)
              break;
     }
     return ssid ? ssid : @"";
}
ioswifissid.lcidl

Code: Select all

//
// ioswifissid.lcidlc
// ioswifissid
//
// Created by Nakia Brewer on 15/07/13.
// Copyright 2013 Nakia Brewer. All rights reserved.
//

// The name of the external (note external name must be all lowercase!)
external ioswifissid

use c++-naming
use objc-objects

command currentWifiSSID
   return objc-string


Re: Trying to build my first iOS External

Posted: Sun Aug 04, 2013 11:35 am
by Nakia
Sorry about my huge delay in response, been moving house.

Thanks for everyone's replies, I will give this a spin tomorrow and report back on my result.
If I manage to get it to work I'll happily upload the compiled external here just in case someone else has a use for it.

Cheers

Re: Trying to build my first iOS External

Posted: Mon Aug 12, 2013 9:30 am
by Nakia
Finally got back to this today,

my XCode still spewing out errors like crazy with just you code Monte.
Maybe there is a setting wrong in my project?

Re: Trying to build my first iOS External

Posted: Mon Aug 12, 2013 11:32 am
by Nakia
Hmmm, importing Foundation.h seemed to help....
# import <Foundation/Foundation.h>

Only getting "yellow" errors now but the build succeeds..

so, I thought I might try it on a device..
I have used the copy files pane to add the ioswifissid.lcext

and I have a button with
on mouseUp
put currentWifiSSID into tSSID
answer tSSID
end mouseUp

unfortunately all I get answered is "currentWifiSSID"

Re: Trying to build my first iOS External

Posted: Mon Aug 12, 2013 1:24 pm
by Klaus
Hi Nakia,

does it work when you use it like a function, which it obviously is:
...
put currentWifiSSID() into tSSID
answer tSSID
...
Just guessing, no idea about C etc... ;-)


Best

Klaus

Re: Trying to build my first iOS External

Posted: Mon Aug 12, 2013 11:22 pm
by monte
It's a command:

Code: Select all

currentWifiSSID
answer the result
Might want to change it to a function I think...

Re: Trying to build my first iOS External

Posted: Mon Aug 12, 2013 11:41 pm
by Nakia
Thanks for the replies and sorry to ask what may appear as dumb questions,
this is just very new for me and I have ZERO knowledge on C (although I plan to learn)

Good news is it actually works and as promised I have uploaded it.

As Monte pointed out you need to use

currentWifiSSID
answer the result

The result will be empty if no wireless network is connected.

Re: Trying to build my first iOS External

Posted: Tue Aug 13, 2013 12:45 am
by monte
Hi Kia

Good stuff.

Can I recommend putting it on GitHub and putting a license on it. The more stuff up there for the platform the better.

Cheers

Monte

Re: Trying to build my first iOS External

Posted: Thu Aug 15, 2013 11:17 am
by Nakia
Managed to get it on Github with a license as suggested.

Placed under description "ioswifissid" - Livecode IOS External - Get WIFI SSID

Re: Trying to build my first iOS External

Posted: Sun Nov 20, 2022 2:41 pm
by trevix
Hello.
I tested your extension at the time and it was working great.
Now on iOS 15 I am not abale to install it anymore.
Do you have any clue?
Will you ever create the same extension for Android?

Thanks