Trying to build my first iOS External

Are you developing an External using the LiveCode Externals SDK?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Trying to build my first iOS External

Post by Nakia » Mon Jul 15, 2013 5:11 am

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...

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Trying to build my first iOS External

Post by Nakia » Mon Jul 15, 2013 7:42 am

lastly, if anyone has some suggestions on good books/online courses to learn objective c that would be also greatly appreciated..

gpb01
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Sat Jun 04, 2011 5:41 pm
Location: Switzerland

Re: Trying to build my first iOS External

Post by gpb01 » Mon Jul 15, 2013 11:34 am

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

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Trying to build my first iOS External

Post by Nakia » Tue Jul 23, 2013 11:14 pm

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Trying to build my first iOS External

Post by Simon » Wed Jul 24, 2013 12:06 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: Trying to build my first iOS External

Post by monte » Fri Jul 26, 2013 1:19 am

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

LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Trying to build my first iOS External

Post by Nakia » Sun Aug 04, 2013 11:35 am

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

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Trying to build my first iOS External

Post by Nakia » Mon Aug 12, 2013 9:30 am

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?
Attachments
xCodeErrors.png

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Trying to build my first iOS External

Post by Nakia » Mon Aug 12, 2013 11:32 am

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"

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Trying to build my first iOS External

Post by Klaus » Mon Aug 12, 2013 1:24 pm

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

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: Trying to build my first iOS External

Post by monte » Mon Aug 12, 2013 11:22 pm

It's a command:

Code: Select all

currentWifiSSID
answer the result
Might want to change it to a function I think...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Trying to build my first iOS External

Post by Nakia » Mon Aug 12, 2013 11:41 pm

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.
Attachments
ioswifissid.lcext.zip
(13.33 KiB) Downloaded 640 times

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: Trying to build my first iOS External

Post by monte » Tue Aug 13, 2013 12:45 am

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
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Trying to build my first iOS External

Post by Nakia » Thu Aug 15, 2013 11:17 am

Managed to get it on Github with a license as suggested.

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

trevix
Posts: 950
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Trying to build my first iOS External

Post by trevix » Sun Nov 20, 2022 2:41 pm

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
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

Post Reply

Return to “Building Externals”