Tag Archives: apple

Logging during development with Apple Watch hardware

Inserting breakpoints or logging statements (such as NSLog) is relatively straightforward with an iPhone-only iOS app. But how do you log from the WatchKit Extension (aka Watch app)?

The good news is that logging isn’t filled with many complicated steps. The bad news is that the logging works intermittently.

  1. Add your NSLog statements in your WatchKit Extension. This is probably your InterfaceController.m
  2. Run the watch app on iOS Device + watchOS Device (in the WatchKit App scheme)
  3. Select Debug > Attach to Process > (click on your watch app name)
  4. Profit! You should see your NSLogs when they are triggered in the app lifecycle in Xcode

debug

If logging isn’t working, try typical Xcode debug steps such as:

  • deleting the app on your phone & re-running it in Xcode
  • restarting the phone and/or watch devices
  • clean Xcode (cmd + shift + k) and re-run the app
  • quit & restart Xcode

Setup Apple Watch for Development Guide

While working in Xcode and running my watch app on my actual hardware watch for the first time, I ran into this error on my watch the first time: “Failed to install [app], error: Application Verification Failed.” This stack overflow answer provides the solution, but I wanted help illustrate the steps I took to fix the error. Disclaimer: this worked for me, but there are probably more optimal ways of fixing the error.

  1. In Xcode, get the UDID of your Apple Watch (WIndow > Devices). The UDID is labeled “Identifier” and you can double click on the Identifier device hash to select & copy it.
    1
  2. Visit the Apple Developer Portal at https://developer.apple.com/devcenter/ios/index.action and click on “Certificates, Identifiers & Profiles” in the right sidebar.
    2
  3. Click on Devices > All in the left sidebar.
    3
  4. Click on the Plus Sign (+) in the top right.
    4
  5. In Register Device, provide a Name (whatever you want) and your watch UDID (from step 1 above).
    5
  6. Submit the form to register your watch device.
  7. In “Certificates, Identifiers & Profiles”, locate your .watchkitextension Provisioning Profile for your app. Select & download this profile.
    7
  8. Locate your downloaded profile file on your computer & double click the Provisioning Profile.
  9. Restart Xcode.
  10. Build your project and you will encounter a iOS Development Certificate alert.
    10
  11. Warning, this step may be dangerous (proceed at your own risk). This worked for me. Click on “Revoke and Request”. This will revoke your current certificate and request a new one. You will probably get an email notifying you that “Your Certificate Has Been Revoked”.
  12. Run your Xcode project. Your watch app should now load the development build on your actual watch hardware.

About the author: Rex Feng enjoys iOS development and has released Pomodoro Pro for the iPhone & Apple Watch. You can follow him @rexfeng.

Fix no matching provisioning profiles validation issue

Here’s a quick problem & solution that worked for me. Hopefully this helps others out there.

Situation:

Validating an archive prior to submitting the build to the App Store, but it fails validation. I am using App Groups (for the phone app & watch app).

Problem:

Validating my archive created two “no matching provisioning profiles found” errors. The error was specifically related to “none of the valid provisioning profiles allowed the specified entitlements betareports-active com.apple.security.application-groups”.

Solution:

In my case, my development was able to use App Groups, but the production/distribution environment was not setup yet.

Under Provisioning Profiles > Distribution (https://developer.apple.com/account/ios/profile/), create an Distribution / App Store for each App ID that you need. In my case, I had to create one for the phone app & one for the watchkit extension. Make sure to download each after generating them. Double click on your downloaded files to automatically load them into Xcode.

When I tried to validate my archive again, I was able to successfully validate (after generating & loading my new Provisioning Profiles).

iOS Programming

I’ve started learning iOS programming. Objective-C seems very low level, but it’s alright as an older object oriented language. Learning the Apple frameworks seems to the be tricky part. There’s a lot for me to learn with using Xcode (since I don’t normally use IDEs) and frameworks like Cocoa Touch.

I spoke to someone recently who suggested skipping Objective-C and going directly to Swift. Or even a tool like PhoneGap. Personally, I side with Aaron Hillegass’ take:

I have three messages for these people:

  • If you want to be an iOS developer, you will still need to know Objective-C.
  • Objective-C is easier to learn than Swift. Once you know Objective-C,
  • it will be easy to learn Swift.

To take a longer perspective on iOS, I want to build my foundation up from Objective-C to iOS. This is similar to how learning Ruby is critical for being a Rails developer.

With that said, I’m eager to get my hands dirty with iOS prototypes through different online courses.

iOS Simulator

When previewing a site on my iPhone (1136 x 640), I wasn’t satisfied with using my iPhone 5 or a Chrome browser Window Resizer app.

Turns out it’s super simple to use the iOS Simulator with Xcode on OS X (version 10.8.5).

Select Xcode > Open Developer Tool > iOS Simulator

xcode

You’ll be presented with an iPhone to navigate within. Select Safari and you can use a site like localhost:3000 for development.

 
ios_sim

iOS Redeem App Code Mockup

New rule: if I have to google “how to [do something],” your UI needs improvement.

While redeeming an iOS app, I couldn’t figure out where to enter in the app code. I instinctively went to the Search section, as I know that has a text input section at the top:

iPhone App Store Search screen

No dice.

So as with everything in modern life, I went to Google for help. It turns out it’s at the bottom of the Featured screen.

iPhone App Store Featured screen top

Scrolling down…

iPhone App Store Featured screen bottom

I find the Redeem button, and the rest is cake.

Without googling, I wouldn’t have stumbled upon Featured > New > page bottom to find the Redeem button.

I recognize that for most people, redeeming an app code is not a typical, common use case. That said, it should be somewhere logical. I’ve mocked up the Search screen with a Redeem button:

iPhone App Store Search screen mockup

This way, the user is able to associate entering in names of apps, keywords, or app codes in one convenient field.

The upside is an extremely easy to find Redeem button. A possible downside is that users will get led astray while searching for paid apps (by hunting for app codes instead of proceeding to checkout).

Ron Johnson: We want [jcp] to be your favorite store.

Last year, Ron Johnson left Apple as Senior Vice President of Retail Operations to become J.C. Penney’s (JCP) CEO. Before joining Apple, he was at Target. As Gruber points out today, “The Ron Johnson Era at JC Penney Has Begun.”

jcp Ad by Ken Segall

Johnson took out a two-page ad in several major newspapers with the mission of turning JCP into your favorite store. This is an amazing leadership step that sets the tone and gives an extremely ambitious goal to its employees.

This amazes me because you can see how he’s cutting out the bullshit. With the realization that almost everything sold at JCP is on sale (~72% of the time, discounted over 50%), he’s getting rid of confusing sales. Everything will just be at the sale price without consumers deciphering “SALE 60% off” tags, “Save an Additional 40%” signs, etc. plastered everywhere. Also, he’s implementing about “100 sleek, neat sections” into stores.

As a consumer, I find it extremely hard to imagine a future scenario where JCP is my go-to choice for anything, let alone my favorite store. That doesn’t mean I can’t give Johnson points for trying. If my company was in mass market retail and needed to turn around sales, stealing an A-level player from Steve Job’s pick for retail operations is as good as it gets.

I don’t have any vested interests with JCP performing well or poorly. But given the choice, I’d like to see Johnson turnaround in real-time a company that most people have completely written off as irrelevant (like Apple ten years ago). It would make a good case study.

(via daring fireball)

Apple Keyboard Shortcuts

We get it. Apple is the company that pays attention to the details. No detail too small, they create their own reality. With a strong internal design culture, they provide customers what they want before they ask for it. But sometimes they misfire (such as their power cords).

I recently started using OS X Lion. Spotlight (command + space) is amazing. Hot corners are cool. The difference between switching applications (command + tab), switching windows (command + `), and switching tabs (control + tab) sucks.

Looking at OS X’s menu bar, how would you ever figure out that that a sloping line with a horizontal line indicates the option key?

Menu Bar example (top to bottom: command, shift, and option)

The command key is clearly labelled on the keyboard. Not sure how you would easily describe the command key symbol’s shape over the phone.

The shift (the up arrow circled above) and the delete key (not circled) can be deduced by your average power user, so I’ll give Apple a pass.

The option symbol, which I’m still not sure how to easily describe (the bottom circled symbol) is a mystery.

Here is what an Apple keyboard looks like:

Apple Keyboard (from left to right: shift, option, and command)

While Apple is known for their attention to detail, the usage of the option symbol to indicate keyboard shortcuts in the menubar is useless as the option symbol only makes itself evident through 1.) web searching or 2.) consulting an expert Mac user. It doesn’t have to be this way. The easiest solution would be for Apple to print the symbol of the option symbol onto the keyboard.

Steve Jobs on Excuses

Steve Jobs by Getty

Inside Apple by Adam Lashinsky:

Jobs imagines his garbage regularly not being emptied in his office, and when he asks the janitor why, he gets an excuse: The locks have been changed, and the janitor doesn’t have a key. This is an acceptable excuse coming from someone who empties trash bins for a living. The janitor gets to explain why something went wrong. Senior people do not. “When you’re the janitor,” Jobs has repeatedly told incoming VPs, “reasons matter.” He continues: “Somewhere between the janitor and the CEO, reasons stop mattering.” That “Rubicon,” he has said, “is crossed when you become a VP.

This makes sense.

A junior employee at the bottom of the chain of command (such as a janitor) can have a legitimate excuse for why something was not done. It’s plausible that the janitor does not have the authority to get the key he needs, so it is not the janitor’s fault.

Whereas a member of management (such as a VP) has no excuse. If the key is missing, the VP has authority to find the person with the key, force open the door, hire a locksmith, etc. The VP needs to problem solve and cannot explain away things that were not accomplished as the VP has sufficient authority to get it done.

It’s interesting to note that Jobs is quoted using the term ‘reason’ and not ‘excuse.’ The former being legitimate and the latter being a scapegoat. That is, the former is only available to people at the staff level who are not sufficiently authorized/empowered.

(via MacStories via HN)