You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Erik Jan de Wit <ed...@redhat.com> on 2014/08/28 11:19:48 UTC

plugin with swift

Hi all,

I’ve been experimenting with swift and ported the HelloWorld plugin [1] to Swift. There was one trick to make it work together with cordova, that was to specify the name of the class to export it under so it could be referenced:

@objc(HWPHello) class Hello : CDVPlugin {

Then it’s ‘exported’ under “HWPHello” that is what we put into the plugin.xml that can then be found at runtime by cordova

There remains one problem in order to use CDVPlugin in Swift one needs to add a bridging header file and add that to the swift compiler options. The file can be part of the plugin but can cordova on plugin install add the needed compiler settings?

[1] https://github.com/edewit/cordova-plugin-hello/tree/swift

Re: plugin with swift

Posted by Shazron <sh...@gmail.com>.
I agree, the time for messing with pbxproj files is over. In hindsight
we should have moved to workspaces and xcconfig files, but what can
you do. We should get rid of this technical debt asap by 4.0

On Thu, Aug 28, 2014 at 9:44 AM, Carlos Santana <cs...@gmail.com> wrote:
> I guess I need to pay more attention to JIRA issues :-)
>
> I think using xcconfig files is huge step forward in managing xcode
> projects.
>
> xcconfig is the same pattern use by cocoapods, it allows more flexibility
> and and at the same time not messing up user's pbxproj
>
> One thing to also look is to flow information from plugin.xml into xcconfig
> and not use node-xcode.
>
>
>
> On Thu, Aug 28, 2014 at 12:03 PM, Shazron <sh...@gmail.com> wrote:
>
>> Right now - no. Although you could write a post-install hook that will
>> directly update the project file using node-xcode I suppose.
>>
>> In the future, we can just add this to the template (please file a
>> feature request so we don't forget). But I think the approach in this
>> issue is better, and will be simpler for the CLI to add items:
>> https://issues.apache.org/jira/browse/CB-5520
>>
>>
>> On Thu, Aug 28, 2014 at 2:19 AM, Erik Jan de Wit <ed...@redhat.com>
>> wrote:
>> > Hi all,
>> >
>> > I’ve been experimenting with swift and ported the HelloWorld plugin [1]
>> to Swift. There was one trick to make it work together with cordova, that
>> was to specify the name of the class to export it under so it could be
>> referenced:
>> >
>> > @objc(HWPHello) class Hello : CDVPlugin {
>> >
>> > Then it’s ‘exported’ under “HWPHello” that is what we put into the
>> plugin.xml that can then be found at runtime by cordova
>> >
>> > There remains one problem in order to use CDVPlugin in Swift one needs
>> to add a bridging header file and add that to the swift compiler options.
>> The file can be part of the plugin but can cordova on plugin install add
>> the needed compiler settings?
>> >
>> > [1] https://github.com/edewit/cordova-plugin-hello/tree/swift
>>
>
>
>
> --
> Carlos Santana
> <cs...@gmail.com>

Re: plugin with swift

Posted by Carlos Santana <cs...@gmail.com>.
I guess I need to pay more attention to JIRA issues :-)

I think using xcconfig files is huge step forward in managing xcode
projects.

xcconfig is the same pattern use by cocoapods, it allows more flexibility
and and at the same time not messing up user's pbxproj

One thing to also look is to flow information from plugin.xml into xcconfig
and not use node-xcode.



On Thu, Aug 28, 2014 at 12:03 PM, Shazron <sh...@gmail.com> wrote:

> Right now - no. Although you could write a post-install hook that will
> directly update the project file using node-xcode I suppose.
>
> In the future, we can just add this to the template (please file a
> feature request so we don't forget). But I think the approach in this
> issue is better, and will be simpler for the CLI to add items:
> https://issues.apache.org/jira/browse/CB-5520
>
>
> On Thu, Aug 28, 2014 at 2:19 AM, Erik Jan de Wit <ed...@redhat.com>
> wrote:
> > Hi all,
> >
> > I’ve been experimenting with swift and ported the HelloWorld plugin [1]
> to Swift. There was one trick to make it work together with cordova, that
> was to specify the name of the class to export it under so it could be
> referenced:
> >
> > @objc(HWPHello) class Hello : CDVPlugin {
> >
> > Then it’s ‘exported’ under “HWPHello” that is what we put into the
> plugin.xml that can then be found at runtime by cordova
> >
> > There remains one problem in order to use CDVPlugin in Swift one needs
> to add a bridging header file and add that to the swift compiler options.
> The file can be part of the plugin but can cordova on plugin install add
> the needed compiler settings?
> >
> > [1] https://github.com/edewit/cordova-plugin-hello/tree/swift
>



-- 
Carlos Santana
<cs...@gmail.com>

Re: plugin with swift

Posted by Shazron <sh...@gmail.com>.
Right now - no. Although you could write a post-install hook that will
directly update the project file using node-xcode I suppose.

In the future, we can just add this to the template (please file a
feature request so we don't forget). But I think the approach in this
issue is better, and will be simpler for the CLI to add items:
https://issues.apache.org/jira/browse/CB-5520


On Thu, Aug 28, 2014 at 2:19 AM, Erik Jan de Wit <ed...@redhat.com> wrote:
> Hi all,
>
> I’ve been experimenting with swift and ported the HelloWorld plugin [1] to Swift. There was one trick to make it work together with cordova, that was to specify the name of the class to export it under so it could be referenced:
>
> @objc(HWPHello) class Hello : CDVPlugin {
>
> Then it’s ‘exported’ under “HWPHello” that is what we put into the plugin.xml that can then be found at runtime by cordova
>
> There remains one problem in order to use CDVPlugin in Swift one needs to add a bridging header file and add that to the swift compiler options. The file can be part of the plugin but can cordova on plugin install add the needed compiler settings?
>
> [1] https://github.com/edewit/cordova-plugin-hello/tree/swift