Mobile Line Of Business

Richard Jones (MVP)

  Home  |   Contact  |   Syndication    |   Login
  202 Posts | 0 Stories | 36 Comments | 0 Trackbacks

News

Welcome to the Mobile Line Of Business Blog

Tag Cloud


Archives

About

Sunday evening,  early evening experiment.

Want to share some swift code between an iOS app and Watchkit app, simply.

I’ve tried to follow a few articles, but this worked for for me.

First up,  just right click your project, and add “New Project…"

Select Framework and library & then follow this...

NewImage

 

 

I then added a swift class (called Mega) as follows -

 

import Foundation

 

public class Mega
{
    publicinit()
    {
        
    }
 
    public func Rock()
    {
    println("Yeah")
    }

}

 

 

So then, I scrolled to project explorer, and added my framework to my watchkit app - 

NewImage

 

 

So all going well, I then did this in my WatchKit app.

 

import Brilliant

 

class MapController: WKInterfaceController

{

    @IBOutlet weak var ourmap: WKInterfaceMap!

    

    

    override func willActivate() {

        // This method is called when watch view controller is about to be visible to user

        super.willActivate()

 

        var m = Mega()

        m.Rock()

 

 

 

 

Then I got the output 

 

 

Yeah

A little complex, but this has great potential to share code and build libraries...

posted on Tuesday, February 3, 2015 2:14 PM