Tuesday, January 20, 2015

Hello Mac From Swift

After my last post about using swift to make cocoa apps on Mac OS X, I got a few questions on how to make an outlet. I guess it is easier to see it happen. Also got questions on how to do window layout constrains with Xcode for Mac also.  As I said it is easier to see this than read about it, So I show you in this video with a very simple basic Cocoa app Hello Mac again with using swift.

There a million swift examples for iOS but not to many for Mac OS X cocoa based apps, so again I keep sharing more swift for Mac stuff in the future. As I am a more a Mac OS developer more than an iOS one.

Here the video; Enjoy.

Note: (If you do not see 1080p resolution then wait for YouTube to process the higher res version. should be not to long)

 

Saturday, January 17, 2015

Using Swift for Mac OS X apps

Yesterday I ran into an issue out of my control with a 3rd party cross platform tool I use. The issue was something that may end my development with it for Mac OS X. Now I not 100% sure if I will not find a work around with that tool. However it is very clear that I need to stop putting all my eggs into one basket and make a real move into using Apple's Xcode to build for Mac OS X in the future.

I already been learning swift for iOS, however when it comes to Mac OSX there very little info or example projects floating around. Even Apple developer site has only 3 swift examples for Mac OSX but have a ton for iOS. Mac and iOS are not the same.

I decided I going to do, if my schedule allows it one or more Mac swift project a day for the next 2 months and really learn how this is done. I have already meet a dozen other developers who want to learn swift for Mac also and are trying to find examples to.

That why I going to share much of what I learn each learning project I do here as, it may help some what.

I decided to skip the Hello world app and start with working with basic text strings and very basic button actions for my first mac demo.

Now first off for a Mac swift project there only one source file the AppDelegate.swift file that all your code goes in.

You still design the interface in Interface builder much like it was done with objective c. Just like with Objective-c each object needs to be assigned an outlet or a action however this is done in the same  AppDelegate.swift file.


This example will simply take the text from each 3 fields and add it together with the process button. And secondly with the clear button remove the text from all 4 fields.

The photo below shows the outlets for all 4 text fields. to create the outlet, first put Xcode into 2 views. the left one the interface view the right one the source code view for AppDelegate.swift. (If that file does not appear in the right side of the subview. At top left corner has 4 boxes like icon, click there to get a sub menu to switch the source code for the view.) To create the outlet simple select a field while holding down the control button and drag the string like graphic to the source code view as like the photo below. This will present you with a pop over window where you name the field (such as fldFieldName) that in turn makes an outlet. do this for each field. (below is an image of the added outlets, Note the window outlet was pre made by Xcode as was the functions for app launching and will terminate) 


Next Adding actions to the buttons. This is done similar to how you create a outlet however you need to add this code after the last function Xcode made but between the last "}" symbol. Also note when the pop over appear there a pop up menu if you select that, you can change the outlet to action. That what you want to do for the button, then assign it a name and hit return.

for my mini app I have the following:
 @IBAction func btnProcessName(sender: AnyObject) {
}

Now between the {} you add your code. Working with strings in Xcode is pretty simple and is similar to many other development languages. we take the object dot property such as:

@IBAction func btnProcessName(sender: AnyObject) {
        fldFullname.stringValue
    }

To assign as value to this fields string value (text) use the = symbol and basically just add the text together. This example does not current check if a field has no text however doing such would not be hard. 

The final action that makes a full name from 3 text fields for first, middle and last name looks like this:

 @IBAction func btnProcessName(sender: AnyObject) {
        fldFullname.stringValue = fldFirstName.stringValue + " " + fldMidName.stringValue + " " + fldLastName.stringValue   
    }
And last to clear all text from the text field as simple action very similar to many programming languages. 

 @IBAction func btnClearAllText(sender: AnyObject) {
        fldFirstName.stringValue = ""
        fldMidName.stringValue = ""
        fldLastName.stringValue = ""
        fldFullname.stringValue = ""
    }
And below are additional images of this very simple swift learning example for Mac OSX.

The full source code (and yes you can make your Xcode editor any color, like mine.)

And last an screen shot of the app test running (like my input;) )


I know I did not do a video, but my upstair neighbors are very loud with there yelling and screaming that a video would not work today. If you think a video would help I could do one in the future when they calm down upstairs.

I hope this helps some as it help me making it to learn myself.

Happy coding ;) thanks for visiting.

Friday, January 2, 2015

Happy New Year

Happy New Year

When I first started this blog part of posterous.com over 6 years now, (moved it to blogger 3 years ago) we meet some pretty cool people. Between my video collections at Vimeo, Screencast.com and YouTube we made over 100 free videos for just learning something cool to do with programing. Some of these videos are now outdated, as the technology world changes every second, (ok it seems like it does, every 6 to 14 months) and that causes some of this stuff to no longer work :(

This blog went from 583 unique visitors a month from 2013 to 8,704 in 2014. Wow! I almost feel I do not give that much content to deserve those numbers. Thank you.

We always try to make more content, but we do not get paid for this blog. We do it when we are in-between programming and multi- media work and jobs. If its slow we give more content, and if busy it will be less.

We also tell it like it is, no candy coating here, not many fancy edits. Why? because we are real people, only fake people edit out there flaws.

Thanks everyone for watching in 2014 and for supporting my little corner of the internet. Hope to see you here again in 2015.

Your friend,

Obleo ;) Happy Coding.

Thursday, December 11, 2014

Xojo vs Livecode best option for iOS Development?

I use both Livecode and Xojo I like them both. Xojo is way better than Livecode when it comes to Mac OSX and Linux. And Livecode way better at Windows. Livecode also supports Android and is one of the best 3rd party android development tools on the market.

However when it comes to iOS what my thoughts on the subject. First off Xojo just released version 1 of iOS support and Livecode has supported iOS for several years now. I used Livecode for iOS and liked it, but when I heard Xojo was going to support native iOs GUI I was excited.

Once iOS was released for Xojo I became disappointed fast, it was missing so much basic stuff that it was uncanny. Xojo is very very limited out of the box when compared to Livecode for iOS.

It was so limited that I made a chart highlighting some of the different things I came to need to when making iOS apps. Livecode supports most of them. Xojo supports only few of them. Lets take a look.


I really like how Xojo works and prefer it still over Livecode for Mac and Linux. And I like the IDE and the way BASIC works over small talk and Livecode IDE. However when it comes to Mobile Livecode wins for now. It supports more stuff out of the box for iOS and also supports Android with most of the same items as it does for iOS.

Another area that impressive is Livecode is now cheaper than Xojo if your going to make iOS apps. With Livecode your required to have Livecode Commercial License to sell iOS apps which cost $299 each year (that also includes 7 platforms for now and up to 8 in the near future.) For Xojo since there pricing change iOS cost $299 a year for only iOS. For Desktop its an extra $299 and for Pro its $699.

Also if your interested in just iOS and want to only do free iOS apps , Livecode for iOS only can be as low as $99. Xojo does not even have this option.

However Apple new swift changes the game even more. You can always switch over to Xcode and use swift for free, and that supports everything out of the box. The reason anyone would use Xojo or Livecode would be to make cross-platform apps.

I still like both tools and will keep using both tools, but for now Livecode wins iOS based on it supports way more needed stuff. However if you need or want Native GUI and learn declares for Xojo then Xojo can be a real improvement in overall quality of the end product.

------------------------------------

I personally have moved to Xcode and Swift for iOS as neither Xojo or Livecode does what I need to grow as a developer of iOS apps.

Swift is very easy to use as a programming language and Xcode supports everything. The case its not cross platform is not valid to me because Xojo and Livecode are not really cross-platform either when it comes to iOS. You can not take the same code base as a Linux or windows app and make it work with iOS with either of those tools without re programming it for iOS.

That fact of that alone makes Xcode and swift the best overall option. Plus its free to use, there millions of developers using it. Which gives more chances to get answers if you get stuck. And last if your looking for a paying job you likely find one for swift than with either of those tools.


Xojo for iOS Tip; Where are the iOS docs.

When your in Xojo for iOS and click on the toolbar help icon. The iOS help docs are not accessable, The Help button bring up the Docs for Mac, Windows, Linux and the Web.


There two ways to get it. One is to just use your web browser. And go to this web page: http://xojo.helpdocsonline.com/home

The other is to go to the menubar / help and select iOS Language Referance, which opens it it in the Xojo help viewer.



Adventures of iOS with Xojo Part 2 Tab Bar Now Working

If you been following along the first part I had a hell of an time figuring out the Tab bar set up. Well after a good night sleep and a good tip from a beta user,who had more info than me. Now it works and did another video showing how it does work.

When the help docs are vague it often seems harder than it actual is. Since I do not work for Xojo I can not help document for them but I can make a video like this in no time flat.


Wednesday, December 10, 2014

Adventures of iOS with Xojo Part 1 Tab Bar Blues

I was super happy to finally have a chance to work with iOS for Xojo. I knew there would be a learning curve. However never thought the would be a learning curve to just add user interface element like a tab bar.

Xojo included example project of a tab bar however that example has no code. It was done some way by the IDE. Trying to figure out how is the topic for this first part of the Adventures of iOS with Xojo.

I feel this is fitting for the first part because Xojo for iOS is not as easy as Xcode without better help docs. Would have thought it should have been, but its not. Since this has taken up hours trying to understand how Xojo for iOS works with just adding tab bars. also hearing other are experiencing about the same thing. Its fitting to start this series off this way.

Part 1; Xojo iOS Tab Bar Blues (in full motion color)

-

Tuesday, December 9, 2014

Xojo for iOS is here, a first look.

Xojo for iOS is here, a first look. I have some screenshots and basic info. Later in the week maybe a video.

Xojo has a pricing change so depending on what you need. you maybe paying less or if your like me you be paying more. Xojo has a blog post on this info.



Above is a screen of one of the included example apps in the Xojo IDE. (One of those annoying and reject-able noise apps.)


Above is a iOS simulator view of a date picker running on the iPad. This uses declares.



Above is the example notes app running in the iPad simulator.

Xojo for iOS is done very well. I have used several development platforms for iOS over the years (including such; Livecode, Unity, Cornia SDK, Phone Gap, Ruby Motion and a few others) And to be fair when I compare Xojo for iOS Xojo is one of the best I seen.

However Xojo does not have a full out of the box feature set at this time. It is a little limited what you can do without writing declares. However declares are pretty simple to understand and use, that it not that bad. However for the price some may think some of these things should be added out of the box and I would agree.

One thing xojo does that basically no one else has done besides Ruby Motion and Xcode is have Native iOS controls built in. Corona & Livecode has no native controls and was one major reason both tools are a disappointment.


iOS Xojo control palette


Another awesome feature is the code signing is built in to Xojo so we do not need to sign it ourselves our pay some other app developer some huge overprice license to do it either (like you do on mac).

One of the neatest but confusing features is the auto layout. What cool is it has auto layout, however it works no where close to Xcode and swift in ease of use. here a image below.


Auto layout palette

Xojo for iOS gets a thumbs up from me. However It still needs work to be a really contender to several other iOS toolsets for its cost. Consider that iOS for Xojo is at 1.0 I say its pretty good. It still has much more it needs to do to get many to switch however. I still think its worth checking out. 

More info at Xojo.com