Devsugar

Latest

  • Testing for OS X vs iOS

    by 
    Erica Sadun
    Erica Sadun
    12.26.2012

    Yesterday, I was messing around building shared NSLayoutConstraint code to be used across iOS and OS X. I put in a few #if TARGET_OS_MAC directives, assuming they'd just work. They didn't. Turns out that you should always check for TARGET_OS_IPHONE first, before TARGET_OS_MAC because the latter is true on the iPhone but the former is not on OS X. Here are some of the most common checks suggested to me yesterday as I messed with this dilemma. #if TARGET_OS_MAC #if TARGET_OS_IPHONE #if TARGET_IPHONE_SIMULATOR #if TARGET_OS_EMBEDDED #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) #if defined(__IPHONE_OS_MIN_VERSION_REQUIRED) And here are the results of running them on the Simulator, iPhone device and OS X: SIMULATOR Target OS Mac Target OS iPhone No Target OS Embedded Target iPhone Simulator Mac OS X Version Min Required is NOT defined iPhone OS X Version Min Required is NOT defined PHONE Target OS Mac Target OS iPhone Target OS Embedded No Target iPhone Simulator Mac OS X Version Min Required is NOT defined iPhone OS X Version Min Required is NOT defined OS X Target OS Mac No Target OS iPhone No Target OS Embedded No Target iPhone Simulator Mac OS X Version Min Required is defined iPhone OS X Version Min Required is NOT defined Since I was most interested in determining whether to use NSBox/NSView vs UIView, my solution ended up looking like this: #if TARGET_OS_IPHONE #define VIEW_CLASS UIView #elif TARGET_OS_MAC #define VIEW_CLASS NSView #endif This approach ensured that the iPhone platform triggered first, and then the second check mandated OS X. This created definitions that allowed my code to successfully compile and execute cross-platform. Thanks Gwynne Raskind and everyone else in #iphonedev

  • Dev Juice: Help me fix my UIView animations

    by 
    Erica Sadun
    Erica Sadun
    06.21.2011

    Dear Dev Juice, I'm having an issue with UIView animations, that I'm struggling to describe in keywords, so I can't find anything helpful with Google. The problem is that I can't seem to work out how to make a UIButton move relative to the bottom of the parent view, as I shrink the parent view. I've managed to get the other views inside the parent to scale with an autoresize mask, but I cannot for the life of me work out how to make the bottom (or even center) of my button clip on to the bounds of the view. Not sure if that accurately paints the picture, and I'm not sure if it's relevant, but I'm making a widget for NotificationCenter. Hope you can help, I'm tearing my hair out. Thanks, Rory W. Dear Rory, It's still the autoresizing mask you have to deal with, but you need to be working with the struts instead of the springs. The Autosizing pane in Interface Builder lets you establish a fixed distance between a view and its parent's edge. Imagine setting a view at 40 points from the top and left of the superview. Enabling the top and left struts in the inspector fixes that view at its relative position. When you use a right or bottom strut, those distances are also maintained. The view must either move or resize to stay the same distances from those sides. The equivalents of struts in code are UIViewAutoresizingFlexibleLeftMargin, UIViewAutoresizingFlexibleRightMargin, UIViewAutoresizingFlexibleTopMargin, and UIViewAutoresizingFlexibleBottomMargin. These flags allow a view to resize by expanding or shrinking in the direction of a given margin without affecting the size of any items inside. Although each of these correspond to the struts of Interface Builder's Autosizing pane, they act in the opposite way. In IB, struts fix the margins; the flags allow flexible resizing along those margins. Enjoy your afternoon sip of Dev Juice!

  • Dear Aunt TUAW: Installing new betas borks my production Xcode

    by 
    Erica Sadun
    Erica Sadun
    06.20.2011

    Dear Aunt TUAW, Every time I install a new Xcode beta these days, it kills my production Xcode and I can't submit to App Store. What gives? I thought you said that Xcode installs could live side-by-side in separate folders! Your loving nephew, Scott McA. Dear Scott, Although you can use separate folders for each installation of Apple's IDE, many of the tools used to create and submit packages live in the /usr/bin directory. And, when it comes to a shared folder like /usr/bin, the rule is last-installed-wins -- your subsequent Xcode installation will overwrite the older versions of the tools in that folder. To get around this you can disable the UNIX Development install option on the "Installation Type" screen of the Xcode installer. This option, which is enabled by default, adds command-line development tools onto the shared install volume. Unselect it during your beta install, and you should be able to skip the development tools re-install when you use the older Xcode version. Auntie adds that qualifying 'should' because a good fresh install of a release Xcode almost always fixes any problems left around by a beta install, even if you pick all the right options while installing. Hugs and good luck, Auntie T.

  • Apple releases Xcode 4.0.2 (4A2002a) to developers

    by 
    Erica Sadun
    Erica Sadun
    04.14.2011

    How doth Apple's Xcode 4 Improve each shining Hour, And offer enhancements every day For every Developer! How skilfully Apple builds its tools! How neat it I.D.E's And labours hard to make it well With the sweet SDKs she releases. In Works of Labour or of Skill I would be busy too: For Developers find some Mischief still For idle Hands to do. In Books, or Work, or healthful Apps Let my first Years be past, That I may give for every Day Some released code at last. -- Isaac "now an Apple Developer" Watts, 1715

  • Apple releases Xcode 4 GM. Again!

    by 
    Erica Sadun
    Erica Sadun
    03.03.2011

    Apple has just posted another GM seed (number 2 if you're keeping count) of Xcode 4. Build 4A304a is ready for you to download, install, use and love. You need to be a paid member of either the iOS or the Mac dev programs to access this build. Now, if Apple would only get around to, you know, releasing Xcode 4..., it would make life ever so much more interesting. Be aware that if you are beta testing Lion, you will need to download and install the separate Lion-specific tools. Xcode 4 GM is built for Snow Leopard. A tip of the developer's cowboy hat to Morgan for telling us about the re-release

  • Apple releases iOS 4.3 GM seed to devs

    by 
    Erica Sadun
    Erica Sadun
    03.03.2011

    iOS 4.3 will be released to the general public next Friday, on March 11. Today, Apple uploaded the gold master seed for developers. The release remains under the NDA umbrella until next Friday, however, with details outside of those publicly discussed by Apple remaining off limits. The new 4.3 firmware will include many new improvements, including enhanced AirPlay and Personal Hotspot support. If you are a paid developer, head on over to the Apple iOS developer site to download your SDK and firmware. You will need to sign in with your credentials in order to get behind the paid firewall for these items.

  • Dear Aunt TUAW: How do I install a Lion partition on my MacBook Air?

    by 
    Erica Sadun
    Erica Sadun
    02.25.2011

    Dear Aunt TUAW, I'm in the Mac Developer program and I'd really like to be able to install Lion on my MacBook Air as a second OS. What are the best strategies to do this? Is it worth going out and buying a second SSD drive and swapping that out with my primary Snow Leopard system? Thanks for letting me know! Love and Kisses, Your nephew G

  • iTunes adds international promo codes, push notification security upgraded

    by 
    Erica Sadun
    Erica Sadun
    12.08.2010

    A couple of big changes occurred today in the iOS ecosystem. First, application promo codes may now be used internationally instead of being limited to US store customers only. Second, the push notification system has been upgraded to use more secure 2048-bit TLS/SSL certificates. International promo code distribution will greatly help those developers whose products are meant primarily for use outside the United States. This particularly affects applications where English is not the primary language for use or US customers are not the central audience. Now, developers can send review codes to local newspapers, magazines and blogs without having to request that those outlets create US iTunes accounts. The push notification system's upgraded security requires that you download an updated server certificate. Apple recommends that you test and validate your communication channels so that your deployed applications will not experience service outages. Further information about both developments is available on Apple's iTunes Connect and developer sites. Developers can use their dev credentials to log in.

  • Dear Aunt TUAW: Can I AirPlay to my Mac?

    by 
    Erica Sadun
    Erica Sadun
    12.08.2010

    Dear Aunt TUAW, Do you think a Mac will be able to accept an AirPlay feed in the future? Here's why I ask -- I'm considering getting a Mac mini for my home theater. But I realized that a great feature of AppleTV is the AirPlay functionality. It seems strange that the mini (that costs 7x more) lacks this functionality. Have you heard any rumblings that accepting an AirPlay stream could come to Mac OS X? Love & snuggles, Your adoring nephew Todd V.

  • Why the Mac App Store rocks for developers

    by 
    Erica Sadun
    Erica Sadun
    10.20.2010

    No matter how good your application is, no matter how novel, how brilliant, how special -- none of it matters if you don't have anyone to use it. The iOS App Store changed the way developers work by providing a streamlined channel between software developers and potential customers. Consider my APIkit scanner application. After opening the app to public beta a few months ago, I may have gotten about 200-300 users. Total. (And a grand total of zero feedback, but that's a completely different gripe about public betas.) Contrast with App Store. As far as I can calculate, I have now shipped well over a million apps on App Store -- that's extrapolating from the 600+ thousand copies that iTunes Connect tells me I've pushed out in the last six months, not including updates and such -- just individual purchases. And no, I haven't earned much from those purchases because nearly everything I've put on App Store to date has been free. That's not the point. Being able to touch that many people's lives, and offer them a few nice utilities is the point. Even as a primarily free developer, it's brilliant to know that I can create apps that matter, that entertain, and that help. I love when people write me and say: "This app is fun" or "helpful" or "silly" or "delightful." And I wouldn't have been able to do that without App Store. I've got a ton of lonely little Mac apps sitting on my back burner that I think can help a lot of people. And now there's a chance that I can share them in a meaningful way. Now, step back and consider this from a business point of view. If App Store has done this much to help me reach people as a free dev, consider what it can do for a Mac developer's bottom line. App Store sells apps. It connects customers to content and developers to an audience. And that's why it matters.

  • iOS 4.2 SDK beta 3 available for download

    by 
    Erica Sadun
    Erica Sadun
    10.12.2010

    Apple has posted an updated beta for the iOS 4.2 SDK. iOS 4.2 is expected to debut "in November" for general consumption. If you are part of the developer program, you can head on over to the dev center now, authenticate with your credentials and download the newest release. As always, beta SDKs remain behind an NDA wall, so we cannot post specific details about changes. Developers will find full release notes and update read-me's at the site itself. A final warning: If you plan to seek alternate means of acquiring and installing 4.2 beta firmware for iDevices, don't. You may very well render your iPhone or iPad inoperative. The OS will not work without an accompanying developer certificate. Good luck and happy developing. Thanks to everyone who sent this in.

  • New iOS developer betas posted

    by 
    Erica Sadun
    Erica Sadun
    09.28.2010

    Apple has posted several new betas for members of the paid iOS developer program. Point your browser to the developer site, and use your credentials to log in. You'll find new betas for iOS 4.2 as well as several other items that we're not sure we can specifically mention without breaking NDAs. Download. Enjoy. Have fun. Thank you everyone who pinged us!

  • Apple TV Lowtide (Front Row) running on iPod touch

    by 
    Erica Sadun
    Erica Sadun
    09.28.2010

    It's been Apple TV-palooza here at TUAW today. Shortly after discovering that the Apple TV iOS firmware could be downloaded and unpacked, we took our first peek under the hood and saw just how similar the new Apple TV, with its Lowtide software, was to previous Apple TV releases. Soon after, we discovered that the Lowtide application was built with multi-device support, including the iPad, in its list of supported hardware. Now, developer Dustin Howett has managed to port Lowtide to an iPod touch and run it under iOS 4.1. You can see him running the Apple TV Lowtide software in this video. It's really amazing to see just how compatible the diverse systems are.

  • More on Apple TV: Playback services may extend to iPad

    by 
    Erica Sadun
    Erica Sadun
    09.28.2010

    Could Lowtide be targeted towards playback on the iPad? That's what indications in the application's Info.plist property list seem to hint at. As TUAW continues to explore the new Apple TV iOS disk image, all kinds of interesting hints keep bubbling out. The property list in question lists two entries for its UIDeviceFamily property. UIDeviceFamily = ( 3, 2 ); In human terms, those numbers refer to both Apple TV (the 3 device family) and the iPad (the 2 device family). As you might guess, the 1 device family includes the iPhone and iPod touch. These device families generally group related physical form factors. All iPods and iPhones use a similar 320x480 base geometry, even though units with new Retina displays physically enhance the addressability of that screen size with more pixels per point. Click the Read More link to see more about what we've found in the disk image.

  • Apple TV under the hood: first look

    by 
    Erica Sadun
    Erica Sadun
    09.28.2010

    As TUAW posted earlier, the iOS 4.1 firmware distribution for Apple TV has just gone live on Apple's Phobos web server. TUAW downloaded a copy and used the dev-team's decrypt keys to peek under the hood. Here's what we found about the "Mojave" Apple TV distribution. First, as expected, there's no SpringBoard.app in Core Services. SpringBoard is the application that runs your iPhone's home screen, letting you launch applications by touching them. Instead, Apple TV seems to run Lowtide, an application responsible for all user interactions, which is derived from the previous Front Row application. Lowtide handles media playback, rentals, DRM management (Fair Play, of course), and other basic services.

  • Apple releases preview 3 of Xcode 4

    by 
    Erica Sadun
    Erica Sadun
    09.02.2010

    Okay, I might be a little bit fangrrlish about the new Xcode 4 IDE. But seriously, it's really an awesome update to the existing Xcode tools. Yes, it's still majorly buggy and yes, there are still many features missing in action -- but it's such a treat to see how the new tools are evolving into their final form. Today, Apple has released developer preview 3 of the new Xcode 4 suite, which you can download by heading over to the developer.apple.com site. You will need to sign in with your online or paid developer credentials to access the page and the preview dmg. I'm a little iffy about what the NDA situation is with regards to the release (I believe it is under NDA until it leaves beta) so I'll leave finding out about the details (there's a Readme and release notes) to you.

  • Xcode 4 Preview 2 available for download

    by 
    Erica Sadun
    Erica Sadun
    07.22.2010

    Have I mentioned how much I adore Xcode 4? I would marry it, bear its children and clean up after it -- that's how much I love it. But Xcode 4 hasn't been readily available for general use. Until now. As of this evening, you can download Xcode 4 Preview 2 and throw yourself into its exuberant yum. At least you can if you're a member of one of the paid developer programs. Yes, all that Xcode 4 goodness is now yours to enjoy, whether you went to WWDC or not. So point your browser over to Apple's developer site, log in with your Mac or iPhone paid developer credentials, and download yourself a big hot steaming pile of IDE yum. It's like the chocolate lava volcano cake of development tools. Thanks, Luke Rhodes

  • devsugar: Accessing an iPhone camera capture session

    by 
    Erica Sadun
    Erica Sadun
    07.22.2010

    With the imminent demise of UIGetScreenImage, a number of readers have asked me how they can use the newer AVFoundation approach to access screen data in their iPhone applications. I went ahead and built some sample code that, when I'm finished messing with it, will be part of chapter 7 of my revised cookbook. I have uploaded the current version to github. It consists of a simple helper class that allows you to start and stop a capture session. You can request an image from this helper (namely, the last captured image from the buffer), which in this example is loaded into a central image view at the end-user's request. You can also ask it for a view with an embedded preview, using the current session. The example project adds that preview to the navigation bar. I threw this example together pretty quickly, and as always, I welcome suggestions and improvements.

  • devsugar: Farewell, UIGetScreenImage()

    by 
    Erica Sadun
    Erica Sadun
    07.21.2010

    Last December, Apple relented on the use of the otherwise private UIGetScreenImage() API. This function allows iOS developers to capture a screenshot on a device, regardless of the contents of the screen. In contrast, the standard SDK-safe approach to screen captures ([theView.layer renderInContext:context]) did not allow applications to access video layers, camera previews, or some OpenGL content. iOS developer Manfred Nerurkar writes on his blog that he was just called by his Apple Developer Relations contact and told that Apple has made an about face on this issue. Apps using UIGetScreenImage will no longer be greenlit for the App Store. Instead, developers will need to use standard Quartz methods (as mentioned aboved) or migrate their camera capture code to AVFoundation. As Nerurkar points out, this decision will force developers to refactor their code and, in doing so, limit screen capture to iOS 4.0 or later deployment. iPhone 2G users will not be able to use camera-centered utilities as iOS 4 AVFoundation functionality cannot be included on the earlier platform. Any 3G and 3GS users who have not upgraded from iOS 3.x will also be affected. That means that Nerurkar's iCamcorder and iWebcamera will lose a large part of their audience. Nerurkar's Drahtwerk firm is not the only one affected. Popular scanner apps such as Occipital 's Red Laser (now bought out by eBay) have a large early model/slow adopter iPhone user base, and if they have to be updated to use the newer methods they will be leaving those users behind. More discussions are ongoing at the Apple developer forums (behind the paid dev firewall).

  • iOS 4.1 SDK Beta 1 ready for download

    by 
    Erica Sadun
    Erica Sadun
    07.14.2010

    Developers start your engines! Apple has just posted the first beta of iOS 4.1 at its iPhone Developer website. The new beta includes firmware for the iPhone 3G and later and the iPod touch 2G and later. Further details about the beta and its capabilities lie behind an ongoing nondisclosure wall, however. Registered developers, head on over and get the details yourself. Thanks, everyone who tipped us!