Categories
Uncategorized

The best USB cable organizers that you might not realize you have

lego minifig usb cable holders

It’s something that the Sugru community (apparently, there is one) has discovered:

this article also appears in the GSG blog

Categories
Swift Kick

How to fix the “Apple Mach-O Linker / Undefined symbols for architecture” error in Xcode 6 beta 6

swift kickIf you’ve been faithfully downloading all the Xcode 6 betas to work with the latest version of Swift, you’re probably used to dealing with new betas breaking your code. In many cases, it’s due to changes in Swift, but once in a while, it’ll be completely unrelated to the language.

When I tried to compile my simple shoot ’em up game using Xcode 6 beta 6, I kept getting a couple of errors with text like this:

Apple Mach-O Linker error, Undefined symbols for architecture

You’re pretty insulated from the details of compiling and linking in Swift, and I hadn’t modified the code since I last ran it in beta 5, which left Xcode as the thing that changed and broke the build. A quick search on Stack Overflow revealed that deleting the DerivedData directory, which contains dSYM data (debug symbols — information used during the build process and for debugging), fixes the problem.

The default location for DerivedData is:

/Users/[your username]/Library/Developer/Xcode/DerivedData

Wait! I can’t find the Library folder in my home directory!

The Library folder is hidden by default in order to prevent non-technical users from messing around with it. However, as a developer, there are times that you’ll need to access it. Here’s how you make it visible within Finder in Mavericks:

  1. Open a Finder window.
  2. Go to your Home folder (the keyboard shortcut is commandShift-H).
  3. In the View menu, select Show View Options (the keyboard shortcut is command-J).
  4. Make sure that the Show Library Folder checkbox is checked.

view options window

Categories
Uncategorized

California court ruling: Employers need to provide some reimbursement for work-related use of personal mobile phones

the california ruling

In the case of Cochran v. Schwan’s Home Service, Colin Cochran filed a class action suit against his employer, the largest direct-to-home food delivery service in the U.S., on behalf of customer service managers who weren’t being reimbursed for work-related use of personal mobile phones. Cochran won, and the ruling is expected to have a significant impact on the way companies do BYOD, and in some cases, may even “bring it down”, if the somewhat alarmist title of this CIO article covering the case’s outcome is to be believed.

2nd court of appeal

The Second District Appellate Court of California.

The case was first taken to the Los Angeles Superior Court, and then the Second District Appellate Court, where the ruling was made on Tuesday, August 12th. Judge Teresa Sanchez-Gordon had said that a class action was not the best way to resolve the issue, noting that examination was required to resolve the question of whether Cochran or his live-in girlfriend paid his mobile bill. In the end, the court ruled that even if a family member or friend pays the costs of using a personal mobile device, if that device is used for work-related purposes, the employer is still required to provide reasonable reimbursement for the employee.

“If an employee is required to make work-related calls on a personal cell phone, then he or she is incurring an expense for purposes of labor law,” Judge Judith Ashmann-Gerst wrote for the court. “It does not matter whether the phone bill is paid for by a third person, or at all. In other words, it is no concern to the employer that the employee may pass on the expense to a family member or friend, or to a carrier that has to then write off a loss. It is irrelevant whether the employee changed plans to accommodate work-related cell phone usage. Also, the details of the employee’s cell phone plan do not factor into the liability analysis. Not only does our interpretation prevent employers from passing on operating expenses, it also prevents them from digging into the private lives of their employees to unearth how they handle their finances vis-a-vis family, friends and creditors. To show liability under the labor code, an employee need only show that he or she was required to use a personal cell phone to make work-related calls, and he or she was not reimbursed. Damages, of course, raise issues that are more complicated.”

smartphones
It wasn’t all that long ago that there were predictions that BYOD stipends would eventually go away and that BYOD for work would be like business clothes: something for which employees would cover the costs and not expect any reimbursement. It was expected in some circles that BYOD stipends would disappear just like reimbursements for telecommuters who used at-home wifi did. The ruling will likely not only render those predictions wrong, it may even lead to the return of reimbursement for wifi for work done at home.

Hyoun Park, Principal Consultant at DataHive Consulting who’s been following the case, says that there are some technical wrinkles in the ruling that need to be worked out. “The court didn’t care about whether you bought 100 megabytes or an unlimited plan. They’re just saying that the company should pay for a portion of the bill. So there’s going to be an argument there.”

california flag

In the end, organizations in California with BYOD programs or who require their employees to use their own mobile phones for work will need to review how mobile devices are used in their day-to-day business, and if necessary, make adjustments. They’ll need to review their mobile device use policies and decide if they want to continue requiring employees to provide their own mobile devices for work use. If they decide to rely on individual-liable devices, they’ll need to make certain they know which employee-owned mobile assets are being used for work purposes, implement a stipend or reimbursement policy, and have some kind of mobile management platform to stay on top of these measures.

On the other hand, if a California business decides to simply disallow the use of personal mobile devices for work, they’ll need to come up with an alternative for employees who require mobile devices. This arrangement will also require management of all sorts, from a corporate-liable device policy to manage the inventory, and once again, some kind of mobile management platform to watch over these incredibly portable company assets.

While the ruling won’t take effect until 30 days after it was made and applies only in the state of California, there’s a good chance that it’ll soon affect personal mobiles used for business outside The Golden State. We’ll keep you up-to-date on these developments.

this article also appears in the GSG blog

Categories
Uncategorized

Mobile device news roundup: Smartphone shipping record broken in 2Q14, Android and iOS account for over 96% of global market, Lenovo now selling more mobile devices than PCs

A record-breaking number of smartphones shipped in 2Q14

top 5 smartphone os shipments 2013-14

Click the graph to see it at full size.

For the first time ever, more than 300 million smartphones were shipped in a single quarter. The market research and analyst firm IDC stated in their most recent press release that according to their Worldwide Quarterly Mobile Phone Tracker data, smartphone vendors shipped a record-breaking 301.3 million units in the second quarter of 2014. In the same quarter in 2014, smartphone vendors shipped 240.5 million, making this year’s change a 25.3% year-over-year increase.

The chart above is based on the table of 2013 and 2014 smartphone shipments included in IDC’s press release, which we’ve reproduced below:

Operating System

2Q14 Shipment Volume
(millions)

2Q14 Market Share

2Q13 Shipment Volume
(millions)

2Q13 Market Share

2Q14/2Q13 Growth

Android

255.3

84.7%

191.5

79.6%

33.3%

iOS

35.2

11.7%

31.2

13.0%

12.7%

Windows Phone

7.4

2.5%

8.2

3.4%

-9.4%

BlackBerry

1.5

0.5%

6.7

2.8%

-78.0%

Others

1.9

0.6%

2.9

1.2%

-32.2%

Total

301.3

100%

240.5

100%

25.3%

Some of IDC’s observations on the data:

  • With almost 85% of the global market share, Android have set a new market share record, doubling their share from a mere three years ago. Samsung account for just under 30% of the Android shipments, a drop from their 40% share two years ago.
  • The second quarter is always the slowest for iOS, as they traditionally release a new phone around the end of the third quarter. The tradition is expected to continue this year, with a lot of expectation that Apple will unveil the next iPhone on September 9.
  • Windows phone is the “clear number 3 smartphone platform,” to use IDC’s words. IDC reports that while Windows Phone’s shipments for 2014 are down from 2013, but their 2Q14 shipments are an improvement over their 1Q14 numbers.
  • With less than 1% market share, it’s time for even the most resilient of BlackBerry holdouts to face the fact that theirs is no longer a viable platform.

It’s an Android/iOS world; we just live in it

apple android worldBased on IDC’s numbers, the combined share of Android and iOS is 96.4% this quarter, leaving the remaining players to fight over the remaining 5.6%. Android and iOS were the only mobile operating systems to see year-over-year growth this quarter, with Android shipments up 33%, and iOS shipments up nearly 13%. Every other OS vendor lost share between this year and last.

Lenovo sells more mobile devices than PCs, becomes the world’s number 4 smartphone vendor

You’d never know it from their US site, pictured below, which appears to be solely focused on PCs and servers…

lenovo us site

…but Lenovo now sells more mobile devices than PCs. In fact, they’re the number 4 smartphone vendor, according to IDC, who published this data in there Worldwide Quarterly Mobile Phone Tracker report:

Vendor

2Q14 Shipment Volume
(millions)

2Q14 Market Share

2Q13 Shipment Volume
(millions)

2Q13 Market Share

2Q14/2Q13 Growth

Samsung (Android)

74.3

25.2%

77.3

32.3%

-3.9%

Apple (iOS)

35.1

11.9%

31.2

13.0%

12.4%

Huawei (Android)

20.3

6.9%

10.4

4.3%

95.1%

Lenovo (Android)

15.8

5.4%

11.4

4.7%

38.7%

LG (Android)

14.5

4.9%

12.1

5.0%

19.8%

Others

135.3

45.8%

97.5

40.6

38.7%

Most of Lenovo’s smartphone sales are in China, where they’re the number one smartphone vendor. They aim to change that with the assistance of their recent purchase of Motorola, who’ve been releasing some impressive yet inexpensive smartphones, such as the Moto G and Moto E (which we raved about back in May).

For more, here’s the Wall Street Journal’s Yun-Hee Kim talking to IDC analyst Brian Ma about Lenovo’s next big ambition: to expand their presence in North America and Europe and take on Apple and Samsung:

Thanks to Phil Caruso, GSG’s Director, Channel Programs for the heads-up!

this article also appears in the GSG blog

Categories
Uncategorized

GSG’s new “Mobility 101” video: Telecom Expense Management, or TEM

tem slide

We’ve just posted a new video titled Telecom Expense Management, or TEM. It explains why your business needs TEM, and what makes up a good telecom expense management system.

Here’s the video. We promise it’ll be enlightening and amusing:

About Mobility 101

mobility 101 tem title card

This video is the second in our ongoing Mobility 101 series, which covers various aspects of enterprise mobility: mobile technology, applications, services, and management. We know that the last thing that you want to do is sit through another long, boring presentation, so we’ve made sure that every video is ten minutes or shorter and not like most of the stultifying slide decks you’ve had to suffer through. We’ve worked to make them entertaining as well as educational.

In case you missed our first one, Intro to MMS, here it is:

We’ll be posting new videos regularly to our channel on YouTube, located at this easy-to-remember URL: bit.ly/gsgyoutube.

this article also appears in the GSG blog

Categories
Uncategorized

Techie amusements

Here’s a little geeky humor to get your week started…

It’s one of the reasons I write native apps

javascript and the good parts

Okay, JavaScript isn’t that bad, but sometimes, it’s hair-pullingly bad.

We could all use one of these converter boxes

xkcd - universal converter box

Good ol’ XKCD; Randall Munroe always know how to channel geek desires into comics.

Sometimes, all you need is a little rebranding

victorian i-pads

With a little glue and some gears, you could sell them as steampunk at double the price.

Dilbert thinks your baby is ugly

dilbert software baby

Does anyone remember the term “egoless programming”?

Categories
Swift Kick

A simple “shoot-em-up” game with Sprite Kit and Swift, part one: Last things first – the complete project

In case you were wondering: yes, this code has been updated so that it’s compatible with the iOS APIs that came after the XCode 6 beta period.

a simple shoot em up game

swift kick

Here’s a fun programming exercise that you might want to try if you’ve been meaning to learn both Swift and game development for iOS: building a simple “shoot ’em” game using both!

alienThis game features alien slugs (pictured on the left) that appear at random “altitudes” onscreen and travel from left to right or right to left, right in the line of fire of your ship, located near the bottom of the screen at the center. The player shoots at them by tapping on the screen; the locations of the player’s taps determine the direction of the shots.

As I said, it’s a simple game, but it introduces a fair number of concepts including:Spaceship

  • Drawing, positioning, scaling and moving sprites with Sprite Kit
  • Operator overloading and extensions in Swift
  • Vector math
  • Responding to user taps
  • Figuring out when two sprites collide
  • Playing sound effects and a continuous soundtrack

I thought I’d do things “backwards” with this article series by giving you what you need to complete the project first, and then exploring the code section by section in subsequent articles. That way, you can immediately see what the final result should look like and do some experimenting and exploring on your own.

How to build the simple shoot ’em up game

  1. Create a new iOS project in Xcode based on the Game template. Give the project any name you like; I named mine SimpleShootEmUp.
  2. Make sure the app uses landscape orientation only by selecting your the project and target in the Project Navigator, and then in the Deployment section, make sure that Portrait is unchecked and Landscape Left and Landscape Right are checked.
  3. Download the .zip file of resources for the game, then unzip it. There’ll be two folders, Images.atlas and Sounds, which you should drag into your project. A dialog box will appear; make sure that Copy items into destination group’s folder (if needed) is checked, and that your project’s target is selected.
  4. And finally, replace the contents of the GameScene.swift file that was automatically generated for your project with the code below. I’ve commented it rather heavily to help you get a better idea of what’s going on:
//
// GameScene.swift
// SpriteKitTutorial1
//
// Written by Joey deVilla - August 2014
// Last updated September 30, 2014
// using XCode 6.0.1
//
// A simple shoot-em-up game that shows some Sprite Kit basics in Swift.
// Some of the code was adapted from the simple game featured in
// Ray Wenderlich's article, "Sprite Kit Tutorial for Beginners"
// at RayWenderlich.com
// (http://www.raywenderlich.com/42699/spritekit-tutorial-for-beginners).

import SpriteKit
import AVFoundation


// MARK: - Vector math operators and CGPoint extensions
// ====================================================
// In this app, we're using CGPoints to do some vector math (yes, there's a CGVector type,
// but in this case, it's just more convenient to use CGPoints to represent both vectors
// and points).
//
// I've marked these as private to limit the scope of these overloads and extensions
// to this file.

// Vector addition
private func + (left: CGPoint, right: CGPoint) -> CGPoint {
  return CGPoint(x: left.x + right.x, y: left.y + right.y)
}

// Vector subtraction
private func -(left: CGPoint, right: CGPoint) -> CGPoint {
  return CGPoint(x: left.x - right.x, y: left.y - right.y)
}

// Vector * scalar
private func *(point: CGPoint, factor: CGFloat) -> CGPoint {
  return CGPoint(x: point.x * factor, y:point.y * factor)
}

private extension CGPoint {
  // Get the length (a.k.a. magnitude) of the vector
  var length: CGFloat { return sqrt(self.x * self.x + self.y * self.y) }
  
  // Normalize the vector (preserve its direction, but change its magnitude to 1)
  var normalized: CGPoint { return CGPoint(x: self.x / self.length, y: self.y / self.length) }
}

// MARK: -

class GameScene: SKScene, SKPhysicsContactDelegate {
  
  // MARK: Properties
  // ================
  
  // Background music
  // ----------------
  private var backgroundMusicPlayer: AVAudioPlayer!
  
  // Game time trackers
  // ------------------
  private var lastUpdateTime: CFTimeInterval = 0  // Time when update() was last called
  private var timeSinceLastAlienSpawned: CFTimeInterval  = 0  // Seconds since the last alien was spawned
  
  // Ship sprite
  // -----------
  // For simplicity's sake, we'll use the spaceship that's provided in Images.xcassets
  // when you start a new Game project
  private let ship = SKSpriteNode(imageNamed: "Spaceship")
  
  // Physics body category bitmasks
  // ------------------------------
  // We'll use these to determine missle-alien collisions
  private let missileCategory: UInt32 = 0x1 << 0   // 00000000000000000000000000000001 in binary
  private let alienCategory: UInt32   = 0x1 << 1   // 00000000000000000000000000000010 in binary
  
  
  // MARK: Events
  // ============
  
  // Called immediately after the view presents this scene.
  override func didMoveToView(view: SKView) {
    // Start the background music player
    var error: NSError?
    let backgroundMusicURL = NSBundle.mainBundle().URLForResource("background-music", withExtension: "aiff")
    backgroundMusicPlayer = AVAudioPlayer(contentsOfURL: backgroundMusicURL, error: &error)
    backgroundMusicPlayer.numberOfLoops = -1
    backgroundMusicPlayer.prepareToPlay()
    backgroundMusicPlayer.play()
    
    // Set the game's background color to white
    backgroundColor = SKColor(red: 1, green: 1, blue: 1, alpha: 1)
    
    // Position the player's ship halfway across the screen,
    // near the bottom
    ship.setScale(0.25)
    ship.position = CGPoint(x: size.width / 2, y: ship.size.height * 1.25)
    addChild(ship)
    
    // Game physics
    physicsWorld.gravity = CGVector(0, 0) // No gravity in this game...yet!
    physicsWorld.contactDelegate = self // We'll handle contact between physics bodies in this class
    
    spawnAlien() // Start the game with a single alien
  }
  
  // Called exactly once per frame as long as the scene is presented in a view
  // and isn't paused
  override func update(currentTime: CFTimeInterval) {
    var timeSinceLastUpdate = currentTime - lastUpdateTime
    lastUpdateTime = currentTime
    if timeSinceLastUpdate > 1 {
      timeSinceLastUpdate = 1.0 / 60.0
      lastUpdateTime = currentTime
    }
    updateWithTimeSinceLastUpdate(timeSinceLastUpdate)
  }
  
  // Called whenever the user touches the screen
  override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {
    // Select one of the user's touches. Given the event loop's speed, there aren't likely
    // to be more than 1 or 2 touches in the set.
    let touch = touches.anyObject() as UITouch
    let touchLocation = touch.locationInNode(self)
    
    // Reject any shots that are below the ship, or directly to the right or left
    let targetingVector = touchLocation - ship.position
    if targetingVector.y > 0 {
      // FIRE ZE MISSILES!!!
      fireMissile(targetingVector)
    }
  }
  
  // SKPhysicsContactDelegate method: called whenever two physics bodies
  // first contact each other
  func didBeginContact(contact: SKPhysicsContact!) {
    var firstBody: SKPhysicsBody!
    var secondBody: SKPhysicsBody!
    
    // An SKPhysicsContact object is created when 2 physics bodies make contact,
    // and those bodies are referenced by its bodyA and bodyB properties.
    // We want to sort these bodies by their bitmasks so that it's easier
    // to identify which body belongs to which sprite.
    if contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask {
      firstBody = contact.bodyA
      secondBody = contact.bodyB
    }
    else {
      firstBody = contact.bodyB
      secondBody = contact.bodyA
    }
    
    // We only care about missile-alien contacts.
    // If the contact is missile-alien, firstBody refers to the missile's physics body,
    // and second body refers to the alien's physics body.
    if (firstBody.categoryBitMask & missileCategory) != 0 &&
      (secondBody.categoryBitMask & alienCategory) != 0 {
        destroyAlien(firstBody.node as SKSpriteNode, alien: secondBody.node as SKSpriteNode)
    }
  }
  
  
  // MARK: Game state
  // ================
  
  func updateWithTimeSinceLastUpdate(timeSinceLastUpdate: CFTimeInterval) {
    // If it's been more than a second since we spawned the last alien,
    // spawn a new one
    timeSinceLastAlienSpawned += timeSinceLastUpdate
    if (timeSinceLastAlienSpawned > 0.5) {
      timeSinceLastAlienSpawned = 0
      spawnAlien()
    }
  }
  
  func spawnAlien() {
    
    enum Direction {
      case GoingRight
      case GoingLeft
    }
    
    var alienDirection: Direction!
    var alienSpriteImage: String!
    
    // Randomly pick the alien's origin
    if Int(arc4random_uniform(2)) == 0 {
      alienDirection = Direction.GoingRight
      alienSpriteImage = "alien-going-right"
    }
    else {
      alienDirection = Direction.GoingLeft
      alienSpriteImage = "alien-going-left"
    }
    
    // Create the alien sprite
    let alien = SKSpriteNode(imageNamed: alienSpriteImage)
    
    // Give the alien sprite a physics body
    alien.physicsBody = SKPhysicsBody(rectangleOfSize: alien.size)
    alien.physicsBody?.dynamic = true
    alien.physicsBody?.categoryBitMask = alienCategory
    alien.physicsBody?.contactTestBitMask = missileCategory
    alien.physicsBody?.collisionBitMask = 0
    
    // Set the alien's initial coordinates
    var alienSpawnX: CGFloat!
    var alienEndX: CGFloat!
    if alienDirection == Direction.GoingRight {
      alienSpawnX = -(alien.size.width / 2)
      alienEndX = frame.size.width + (alien.size.width / 2)
    }
    else {
      alienSpawnX = frame.size.width + (alien.size.width / 2)
      alienEndX = -(alien.size.width / 2)
    }
    let minSpawnY = frame.size.height / 3
    let maxSpawnY = (frame.size.height * 0.9) - alien.size.height / 2
    let spawnYRange = UInt32(maxSpawnY - minSpawnY)
    let alienSpawnY = CGFloat(arc4random_uniform(spawnYRange)) + minSpawnY
    alien.position = CGPoint(x: alienSpawnX, y: alienSpawnY)
    
    // Put the alien onscreen
    addChild(alien)
    
    // Set the alien's speed
    let minMoveTime = 2
    let maxMoveTime = 4
    let moveTimeRange = maxMoveTime - minMoveTime
    let moveTime = NSTimeInterval((Int(arc4random_uniform(UInt32(moveTimeRange))) + minMoveTime))
    
    // Send the alien on its way
    let moveAction = SKAction.moveToX(alienEndX, duration: moveTime)
    let cleanUpAction = SKAction.removeFromParent()
    alien.runAction(SKAction.sequence([moveAction, cleanUpAction]))
  }
  
  func fireMissile(targetingVector: CGPoint) {
    // Now that we've confirmed that the shot is "legal", FIRE ZE MISSILES!
    
    // Play shooting sound
    runAction(SKAction.playSoundFileNamed("missile.mp3", waitForCompletion: false))
    
    // Create the missile sprite at the ship's location
    let missile = SKSpriteNode(imageNamed: "missile")
    missile.position.x = ship.position.x
    missile.position.y = ship.position.y + (ship.size.height / 2)
    
    // Give the missile sprite a physics body
    missile.physicsBody = SKPhysicsBody(circleOfRadius: missile.size.width / 2)
    missile.physicsBody?.dynamic = true
    missile.physicsBody?.categoryBitMask = missileCategory
    missile.physicsBody?.contactTestBitMask  = alienCategory
    missile.physicsBody?.collisionBitMask = 0
    missile.physicsBody?.usesPreciseCollisionDetection = true
    
    addChild(missile)
    
    // Calculate the missile's speed and final destination
    let direction = targetingVector.normalized
    let missileVector = direction * 1000
    let missileEndPos = missileVector + missile.position
    let missileSpeed: CGFloat = 500
    let missileMoveTime = size.width / missileSpeed
    
    // Send the missile on its way
    let actionMove = SKAction.moveTo(missileEndPos, duration: NSTimeInterval(missileMoveTime))
    let actionMoveDone = SKAction.removeFromParent()
    missile.runAction(SKAction.sequence([actionMove, actionMoveDone]))
  }
  
  func destroyAlien(missile: SKSpriteNode, alien: SKSpriteNode) {
    // Play explosion sound
    runAction(SKAction.playSoundFileNamed("explosion.wav", waitForCompletion: false))
    
    // When a missile hits an alien, both disappear
    missile.removeFromParent()
    alien.removeFromParent()
  }
  
}

 

Once that’s done, the game’s ready to run. Go ahead and run it, play, explore the code, experiment, and learn! In the next installment, I’ll start explaining the code, starting with some Sprite Kit basics.

Credit where credit is due

  • Much of the code is a Swift adaptation of the code in Ray Wenderlich’s September 2013 article, Sprite Kit Tutorial for Beginners. If you’re serious about learning iOS development, you want to bookmark Ray’s site, RayWenderlich.com, the home of not just tutorial articles, but tutorial videos, very in-depth books, and even starter kits for budding iOS game developers.
  • The alien images were taken from Backyard Ninja Design’s Free Stuff page, specifically the set of sprite from their “Crapmunch” game.
  • The ship image is the one included in the example game that’s automatically created when you generate a game project.
  • The background music is FU4, created by Partners in Rhyme, and can be found on their Free Royalty-Free Music Loops page.