chameleon - iconfactoryfiles.iconfactory.net/craig/chameleon.pdf · 2011. 4. 10. · chameleon...
TRANSCRIPT
![Page 1: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/1.jpg)
ChameleonGetting your iOS app onto the Mac
![Page 2: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/2.jpg)
What is it?
• UIKit for Mac OS X
• Implements same API as iOS
• Written by Sean Heber – @BigZaphod
• I’m the first guinea pig – @chockenberry
![Page 3: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/3.jpg)
Why did we do it?
• Twitterrific for Mac
• About 50K lines of iOS code to rewrite
• And new code to maintain in parallel
• Started doing that…
• Then Sean got lazy… sort of.
![Page 4: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/4.jpg)
Where are we now?
• Nine months later
• 90% of our code base is platform agnostic
• Simultaneous releases for Mac and iOS
• UI consistency across products
• 2x revenue from same code
![Page 5: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/5.jpg)
How can you use it?
• http://chameleonproject.org/
• Source code available on github
• API coverage about 60%
• No documentation
• Buy an expensive T-shirt
![Page 6: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/6.jpg)
Documentation
• This talk is the starting point
• Thanks to @VTM_iPhone for video
• Not going to cover internals
• Talk about things we learned
• Porting guide for Mac
![Page 7: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/7.jpg)
Make it Mac!
Documents
Windows
Menubar Status Item
Dock Icon
Toolbars
![Page 8: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/8.jpg)
Where is UIKit?
Sidebar
Timeline
Timeline
Popovers
![Page 9: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/9.jpg)
Refactoring
• It has to happen
• Multiple windows
• Menubar
• Application delegates differ
• Section 6.4 – “Apple sets a high bar”
![Page 10: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/10.jpg)
“Epic refactor is epic”
• 100+ files changed
• 1,100 word commit message for rev 3896
• Implemented application controller
• Actions & state managed by controller
• Controller is subclassed per platform
![Page 11: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/11.jpg)
TwitterrificController
• TwitterrificController base class
• TwitterrificController_iOS
• TwitterrificController_iPhone
• TwitterrificController_iPad
• TwitterrificController_Mac
![Page 12: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/12.jpg)
Document Window
Document WindowController
UIKitView : NSView
UIViewController
Twitterrific Controller(Mac)
Timeline
![Page 13: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/13.jpg)
Application Delegate
Application Delegate
UIViewController
Twitterrific Controller(iOS)
Timeline
![Page 14: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/14.jpg)
UIKitView
• Every UIKitView has a UIScreen
• 1:1 relationship with view and screen
• UIWindow accessor creates window
• Matches screen bounds
• Or do it yourself:myUIWindow.screen = myUIKitView.UIScreen;
![Page 15: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/15.jpg)
UIKitView- (void)setViewController:(UIViewController *)newViewController{ if (newViewController != viewController) { [viewController.view removeFromSuperview]; [viewController release]; viewController = [newViewController retain]; // unlike iOS, bounds can change often and radically viewController.view.autoresizingMask =
UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight;
viewController.view.frame = self.UIWindow.bounds; [self.UIWindow addSubview:viewController.view]; // .. just like in iOS application delegate }}
![Page 16: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/16.jpg)
Demo
![Page 17: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/17.jpg)
Deficiencies
• Partial implementation (table view editing)
• Missing classes (switch and tab view)
• Nib loading: use -loadView
![Page 18: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/18.jpg)
Deficiencies
• Accessibility
• Multi-touch and gesture recognizers
• WebView on 10.6 and Core Animation
• Subpixel anti-aliasing possible, but hard
![Page 19: Chameleon - Iconfactoryfiles.iconfactory.net/craig/Chameleon.pdf · 2011. 4. 10. · Chameleon Getting your iOS app onto the Mac. What is it? • UIKit for Mac OS X](https://reader035.vdocuments.mx/reader035/viewer/2022081621/612a0cace7028c279c1cf000/html5/thumbnails/19.jpg)
Q & A
http://chameleonproject.org/
http://files.iconfactory.net/craig/MultiApple.zip
Buy a T-shirt before April 20th!