Bundling Shared Code in Frameworks
Now we have a working custom keyboard that reuses the code from our app and extends our features into other apps on the system. However, there’s one shortcut we took that’s a little ugly, and cleaning it up will show us an important technique for sharing code on iOS.
“What shortcut?” you might be asking. It’s back where we added our Twitter utility code, ParsedTweet.swift and TwitterAPIRequestUtilities.swift, to both the PragmaticTweets app target and the PragmaticTweepsKeyboard extension target. That means this code is built twice, and two copies of it exist in memory at runtime. Sure, it’s small, so it’s not a big deal for now. But as our app grows, we can do better.
When we share code between an app and ...
Get iOS 9 SDK Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.