Software

5 Best Practices Beginner Mobile Game Developers Must Know

Entire Post Here

Introduction

For those who don’t know what Cocos2D is, it is the most popular game engine on iOS and was around before Sprite Kit (the official Apple Framework), and Sprite Kit also takes a lot of ideas from Cocos2D. What is great about Cocos2D is that it is open source, and with company called Portable it is also possible to write the game on iOS and then port it to Android.

A couple of great games were also have been made by Cocos2D, a great example being Badland, which won Apple’s design prize for games. It is definitely a very popular and well-maintained game engine.

Another tool that we’re using a lot is SpriteBuilder. If you used Unity before, it is very similar to Unity but it’s for 2D games where it allows you to create great game content, to create levels, and to do all that visually without writing code for the game content part. This means when you’re building games with SpriteBuilder or Cocos2D, you’ll get a nice separation between your content (e.g. levels, menus, etc.) and your core game mechanics.

Not all of the points here are iOS-specific, but one thing you should have realized when you started game development is that it’s pretty platform-agnostic. A lot of content also apply to PC games and web games.

#1 Don’t make assumptions about the screen size

When starting out with game development, a lot of people will use constants for the screen work. In the past, the only resolution for any screen size we had was 480 x 320 on the iPhone 4. That means people could make assumptions about the size of the screen, and you could code in constants and use them to position things on the screen.

After the iPhone 5 came out with a different screen size, all of these inexperienced developers’ games needed an entire redesign for the new screen sizes.

So, now with the current state of the platform, even for iOS where we don’t have that many different devices, we have enough different devices that you definitely can’t make assumptions about how big the screen size is. We should always place things relative to the screen size and not make hard code assumptions about the screen size.

let screenWidth = 320 
myButton.x = screenWidth - 50

We have constants for the screen width, and you calculate the position for an object on the screen based on that…this is usually a very bad practice. Instead, you have to think about what width to write while you basically correspond to the screen size like this:

// cocos2D example 
myButton.x = self.contentSize.width - 50

In Cocos2D, for example, that would be the content size property on the scene. So each scene has a content size property, and if you, for example, have a full scene and that content size property will be the full screen size.

But it’s also possible to have your scene smaller than the full screen. Either way, if you press the button relative to that scene, then you should calculate the position based on the content size.

That’s just a very simple example where you shouldn’t use constants for width and height. Calculate the things based on scenes or whatever is relevant to your specific example.

This is really important to keep in mind. That would save you a lot of time from redesigning your game for every different devices type (e.g. iPad, iphone6, iphone5, etc). The good news is that SpriteBuilder and Cocos2D have some good support for such relative layouts. This makes things pretty easy once you start thinking about how to implement a flexible design.

Beyond that very basic rule, there is another thing to think about and that’s basically I would like to divide the things I show on the screen into two categories. One for UI components, such as buttons or the HUD (Heads-up-Display) that shows current points in the game, and the other one for actual gameplay.

Entire Post Here

Understanding Async Programming with Starbucks

Helpful post to get a better understanding of Asynchronous programming.

Full article is here

coffee.jpg

've worked and trained with many developers over the years, and I found that many people struggle to get their head around asynchronous programming. Asynchronous structures like Futures, Promises and Blocks are literally everywhere now. Yet, they're still difficult to understand, so I thought I can help you wrap your head around it with some help from Starbucks. That said, grab your Pumpkin Spice Latte and get ready for a Caffeine-fueled adventure through the world of Async programming ☺

Pre-Starbucks - The Synchronous Model

Let's take a moment to picture yourself in line at your favorite coffee store, where they can process only one transaction at the time. You get to the counter, what happens next?

  • You put in an order for a quadruple espresso (it's going to be a long day ahead)
  • You pay the extortionate price (when did coffee get so expensive?!)
  • You stand still...
  • While you stand your server goes and crushes some beans;
  • You stand still...
  • The barista turns some handle's, bangs a big metal thing loudly, steams, froth;
  • You stand still...
  • Everyone behind you stands still...
  • The barista holds the little paper cup under the coffee machine as it pours your drink in;
  • Everyone behind you waits, checking their phones/watches, wondering who the awkward person ordering a quadruple espresso is;
  • Finally, the barista gives you your coffee;
  • You grab your drink; add any additions of your choice and leave;
  • Now the Server moves on to the next person, who orders a single bottle of water they've been holding the entire time, they pay and leave immediately!

Welcome to the world of synchronous programming! You ask a function to do something and you wait until they've done it. And if someone else wants to do something that could be much quicker, they have to wait!

Read the rest here ...

A Collective Searchable List Of APIs Organized by Topic

See this link for more

Just some examples:

  • BestBuy
  • Amazon
  • Bing
  • Box
  • BrainTree
  • Business.gov
  • Eventful
  • Facebook
  • Flickr
  • Foursquare
  • Google App Engine
  • IBM Watson
  • Last.fm
  • Netflix
  • Product Hunt
  • Stripe
  • Twillio

See this link for more

Swifter Swift - an absolute must repository

Swift-Logo.jpg

Link here

SwifterSwift is a collection of over 500 native Swift extensions, with handy methods, syntactic sugar, and performance improvements for wide range of primitive data types, UIKit and Cocoa classes –over 500 in 1– for iOS, macOS, tvOS, watchOS and Linux.

List of All Extensions

  • SwiftStdlib Extensions
  • Foundation Extensions
  • UIKit Extensions
  • AppKit Extensions
  • CoreGraphics Extensions
  • CoreLocation Extensions
  • MapKit Extensions
  • SpriteKit Extensions
  • Misc. Extensions

How cool is this?

SwifterSwift is a library of over 500 properties and methods, designed to extend Swift’s functionality and productivity, staying faithful to the original Swift API design guidelines.

Link here

Bad UX Roundup #17: Rain, Information Architecture, and Ergonomics

1_renPtFYaWW4qwiEZj-12Cg.png

Read the entire article

Another week, another assortment of atrocious design worthy of MOMA. In the interest of variety, I have added a few newcomers to this issue. One is a piece of architectural design and the other is a brand I have never featured before. Of course, I have also included the requisite examples from big brands like Facebook and Apple, because those companies are bad design factories. All in all, it’s a good haul this week.

If you’re wondering what gravity has to do with all of this, you’re just going to have to keep reading.

Important lessons

  • Know your user and the circumstances in which they will be using your product.
  • Sometimes simpler really is better.

Read the entire article

Junior Programmer Job Advice

StockSnap_KG40JUP28N.jpg

Read the entire post here

A few years ago I conducted one of the most interesting interviews to this day. And, it came with a big twist in the end.

We were looking for a junior AngularJS developer. Writing basic directives, simple two-way data bindings, clean code - yes. Deep understanding of the digest loop, interceptors, XSRF protection, fancy design patterns - no, not necessarily.

Then out of the blue, THE MOST gorgeous candidate applied.

Strong background with not just Angular but plenty of backend frameworks as well, he had even coded mobile apps in his spare time. Had that slightly arrogant half-smile going on, as if to say "Don't know why you even bother, dude, I'm your man."

Here comes the twist, though.

For 20 minutes of intro talk, we barely spoke about Angular. Such was his urgency to showcase all the various assets of his skill set that what I really wanted to hear was a sentence and a half about some dull directive he wrote one time.

Then came the technical part. In the next 30 minutes, I could actually see his confidence evaporating from the room, although I was trying to be as friendly as possible. Turned out his Angular knowledge was shallow, the tip of the iceberg, "I saw that in a tutorial once" type.

Although he was presenting himself as a senior developer, he was a mere junior level for this position.

Expectedly, he didn't get the job. We hired a quite younger girl with less overall experience but much more focused on what we needed.

See, not that he wasn't smart - he was. I'm sure he would have caught up eventually.

His problem was different - he didn't have a niche. He hadn't picked a thing. He was ok for everything but good for nothing.

 

This is your #1 Junior Developer Mistake - not picking your niche early.

Read the entire post here

33 awesome GitHub lists for iOS development

awmleer-401721-unsplash.jpg

Read full article here

Looking for interview questions & answers? Need to find iOS chart or animation library? Or maybe you are just curious to check new open-source apps, free courses, coming conferences or people to follow on Twitter. Whatever you’re looking or need, you will find that on GitHub :)

There are really a lot of iOS gems done by the community! We made our research and collected the most useful repositories for you. For sure, you will find there a bunch of practical resources and a lot of inspiring ideas. 
Check it out!

Read full article here

Clean Swift Architecture - an alternative to MVC

 

Read the entire article here

A couple of years ago, all of the iOS apps were small containing less than 10 screens. The codebase was small, storyboards were working excellent, and it was easy to maintain your project. From an architectural point of view, MVC was doing a great job.

How about today?

Today, we are facing big technological advancements and an insane app market growth. In other words, apps are becoming big and complex. We are working on projects that contain 20, 30 or even 40 screens making it impossible to be maintained with MVC.

As technology moves forward, so should we (developers).

Recently, I really got tired from MVC and started looking for a new architecture. After a short research, I have noticed the Clean Swiftarchitecture and instantly fell in love with it! This architecture was exactly what I was looking for. 🚀

About the Clean Swift Architecture

Clean Swift (a.k.a VIP) is Uncle Bob’s Clean Architecture applied to iOS and Mac projects. The Clean Swift Architecture is not a framework. It is a set of Xcode templates to generate the Clean Architecture components for you. That means you have the freedom to modify the templates to suit your needs.

In an MVC project, your code is organized around and grouped by models, views, and controllers. In Clean Swift, your project structure is built around scenes (or screens). Here is an example how does one scene looks like. In other words, we will have a set of components for each scene that will "work" for our controller. These are the components:

  • Models
  • Router
  • Worker
  • Interactor
  • Presenter
  • Configurator

Read the entire article here

How to optimize swift and iOS build times

Here is a FREE opens source repository that can help speed your builds

Includes:

  • Type checking of functions and expressions
  • Slowly compiling files
  • Build active architecture only
  • dSYM generation
  • Whole Module Optimization
  • Whole Module Optimization for CocoaPods
  • Third-party dependencies
  • Modularization
  • XIBs
  • Xcode Schemes
  • More

Here is a FREE opens source repository that can help speed your builds

Worst Software Learning Advice

I agree that a lot of advice I see is not that great.  He sums it up well and makes it funny.  I don't have a degree and I learned most everything through informal methods like online tutorials and videos.  

Snapchat Snapkit Developer Support Sadly Sad

Original post on Medium

Part 1 of a periodically updated diary of my attempts to work with Snapchat’s Snapkit

As an iOS Developer I thought it would be interesting to try to add Snapchat’s Snapkit features to an app I have under development.

Snapchat is playing catch-up in a race to keep its platform relevant and wants software developers to embrace its tools. Facebook and Twitter have long had development kits available for apps such that logging in to an app with Facebook and Twitter is commonplace. And posting to both is built in to probably thousands of apps.

snapssss1.png

After just scratching the surface of the offerings, I am not impressed with Snapchat’s documentation nor support.

Oh for the love of good documentation

These are the very first lines of the iOS API Reference

This documentation assumes you already made contact with us. The Snap Kit developer portal is the place for adding your application, exchanging keys, and getting set up with the proper API credentials.

It is not at all clear to me how or why one would “make contact” with Snapchat. I suspect this document is out of date and that it was written when Snapchat was working with partners. As far as I can tell, the API is now completely open to anyone interested. So I’m either wrong and need to contact Snapchat (How?) or this very first paragraph is utterly misleading and out of date.

Next up I thought I would integrate Snapchat login. My app already has authentication via Google, Twitter and Facebook (do you see that Snapchat… you need to blow me away just to enter the game)

Here’s some instruction from the Login Kit documentation

snapppssssss2.png

This line about SCSDKRedirectUrl is mind boggling

  • SCSDKRedirectUrl (string): The URL that will handle and complete login requests; must be a valid URL in the form foo://bar — without bar, redirects will fail

I’m sorry, what? What URL will complete and handle the login? And what does “foo://bar” without the bar mean? And if it means what I think it does — why would you write something like that? (I think it means .. ‘someurl://’)

I guess as a developer I’m supposed to know what the URL syntax should look like. But wait, Snapchat has a few GitHub repositories with examples.

But wait, only one of the examples is written in Swift (remember I’m developing for iOS).

Since I like to try to solve my own problems, I thought perhaps the sample app would shed some light on the mysteries of SCSDKRedirectURL. This URL is supposed to go into the info.plist. Let’s see what the example app from Snapchat has in the info.plist

<dict> 
      <key>CFBundleTypeRole</key>
      <string>Editor</string>
      <key>CFBundleURLSchemes</key>
      <array>
      <string><!-- Insert your redirect url scheme here -->   
      </string>
      </array>
</dict>

Fantastic, that clears things right up.

As I was already in GitHub and already looking at the sample app supplied by Snapchat, I thought I’d file this lack of clarity as a bug against the sample repo. It’s issue #3 Redirect URL — Clarity in documentation please

Someone named David cleared things up in response to the bug

So if you registered my-app://auth/snap then you would have this entry in your Info.plist:
<key>SCSDKRedirectUrl</key>
<string>my-app://auth/snap</string>

as well as:

<key>CFBundleURLTypes</key>
 <array>
 <dict>
 <key>CFBundleTypeRole</key>
 <string>Editor</string>
 <key>CFBundleURLSchemes</key>
 <array>
 <string>my-app</string>
 </array>
 </dict>
 </array>

Thanks David

As a side note, Snapchat support has no idea how to handle Snapkit requests. I can’t stop giggling when I read the response when I ask if they are the right folks to get help from.. “We’ll need to look further into this”

Yes, yes you will!

Aaaaaaaa.png

Ever suffer from a detached head in Xcode?

Xcode is a joy and a curse. And the git integration sometimes goes wonky. About every month I get a detached head. Here’s a great fix that I’ll add one more small teak to..

  • Step 1. Create a branch called “temp” by typing: git branch temp
  • Step 2. Switch over to your new branch by checking it out: git checkout temp
  • Step 3. Point the master pointer to the temp branch pointer (the-f means force): git branch -f master temp . //here ‘master’ would be any branch that has a head that you want to realign
  • Step 4. Check out master (or whatever the problem branch was)
  • Step 5. Now we delete our temp branch: git branch -d temp
  • Step 6. Push our new changes to the remote repository: git push origin master //or whatever the problematic branch was

More on image sizing - stickers

Found this link very helpful

Small: 100 x 100 pt @3x scale (300 x 300 pixel image)

Medium: 136 x 136 pt @3x scale (378 x 378 pixel image)

Large: 206 x 206 pt @3x scale (618 x 618 pixel image)

Huge collection of fantastic tips for Swift Development

All I can say is Wow! Check this out. Swift tips and tricks

UI helper - iOS Sizing / resolutions

Need help with all the iPhone and iPad sizes and the assets (graphics/images) you need?

This site is super handy http://iosres.com/

Error Domain=PlugInKit Code=13 "query cancelled

So subtle yet so vexing.

Error Domain=PlugInKit Code=13 “query cancelled

To fix this, I changed one tiny piece of code, but there are a number of related issues to check

Original

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage
        userChosenPhotoFromGalleryOrCamera.image = chosenImage
        self.dismiss(animated: true, completion: nil)

        userChosenPhotoFromGalleryOrCamera.isHidden = false
    }

Get rid of self.dismiss and replace with picker.dismiss

New

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage
        userChosenPhotoFromGalleryOrCamera.image = chosenImage
        picker.dismiss(animated: true, completion: nil)

        userChosenPhotoFromGalleryOrCamera.isHidden = false
    }

Forcing iOS orientation for single or all ViewConroller

The app I am building really makes sense in portrait mode only. So I want to force that. And also, there is just too much to test with all the orientations. So why not?

Here are some resources that helped me:

Very helpful iOS Toolkit for 2018

Hello folks, I would like to update some of my toolset for 2018 that I use for iOS development tools, cloud service, websites, repos, libraries and some miscellaneous that I am still currently using.

This article will continue to be updated all year round. Some tools can be deleted, some others not. You can find some of the updates from my 2017 toolset and some new advice with the reasons behind.

I will also be in WWDC 2018. Hope to see some of you there :)!

Cloud Service

I use Macbook Pro 2015. It is fair enough but there is a problem with the compiling time. When I started my current job, I can not estimate project size and compiling time details. Also there is not another alternative such as iMac or Hackintosh for working faster with big projects. One day, while talking with my friends they asked me why I do not use cloud Apple hardware. It was a missing tool in my list that supports developers who don’t want to run development and testing in house. MacStadium services fit very well with developers, dedicated iOS build infrastructure quickly when they can’t afford to purchase hardware.

Also, they are about to roll out a program offering free dedicated Mac minis to open source developers!

Read the entire article here

Warning: Attempt to present <*> on <*> whose view is not in the window hierarchy

Ever seen this error?

Warning: Attempt to present <*> on <*> whose view is not in the window hierarchy

It is only a warning, but I like not to have warnings. And this one just got me curious so I wanted to fix it.

The bottom line issue is that you have a view controller that did not finish loading and another view controller is presenting.

The fix that worked for me was to present the secondary view controller here..

override func viewDidAppear(_ animated: Bool) {
self.present(authViewController, animated: true, completion: nil)
    }