Our BlogTips, Tricks, and Thoughts from Cerebral Gardens

With Xcode 9, it’s possible to mix and match Swift 3 and 4 libraries together. In the build settings for the project you set the version of Swift to use by configuring the SWIFT_VERSION setting. You’re able to override the project setting at the target level, thereby building some targets with Swift 3, and others with Swift 4.

If you’re using CocoaPods as your dependancy manager, there’s an issue when mixing and matching.

As you know, when using CocoaPods, you end up with an Xcode workspace that contains your main project, and a Pods project. Whenever you run pod install or pod update, CocoaPods will set the SWIFT_VERSION for all targets to be whatever your main project is set to, or it will fallback to Swift 3 if the main project doesn’t have the SWIFT_VERSION specified.

This means Xcode will try and compile all targets with the same version of Swift, regardless of what version of Swift is actually needed. There’s no built-in way for you to specify the version of Swift to use for each pod you’re including. There is a way for the pod maintainer to specify the version needed in the podspec (they need to set pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' } see XCGLogger.podspec for an example), but I’ve found it’s rare at this time for it to be set (hopefully this post will help change that).

Even if the pod sets the version of Swift to use, we run into a problem when Xcode resolves the setting. Xcode will prefer the target’s direct setting over the podspec’s suggestion, and since pod update always sets a direct setting on the target, the pod spec’s suggestion is never used (not surprising it’s rarely set).

The solution is to add a post_install script to the end of your podfile:

Let's examine this script.

It’s a post_install script so CocoaPods will execute the script after is has updated all of the included pods and updated the project file.

The script starts by looping through the build configurations of the Pod project and sets the default Swift version to 4.0 (lines 2-5).

Then it loops through all of the project’s targets (lines 7-19). It checks the target name against a known list of targets (line 8) and sets each of the configurations for matching targets to Swift 3 (lines 10-12). If the target isn’t in the known list, the script unsets the Swift version (lines 15-17), which will allow the pod to set the version itself using the pod_target_xcconfig setting we noted above. If the pod doesn’t set the version, Xcode will use the default Swift version we set at the start.

You will need to tweak the script for your project, specifically to set your default Swift version, and then to add the targets that require a different version on line 8.

If you’ve found this article helpful, please subscribe to the RSS feed and follow me on Twitter

It would be awesome if you’d download our new app All the Rings. It’s free and we really think you’ll like it!

If you see any errors, want to suggest an improvement, or have any other comment, please let me know.

All the Rings

Today we're proud to announce the launch of All the Rings, a companion to the built-in activity app that helps you stay focused, motivated, and most importantly, close all the rings, every day. If you're looking for an enhanced activity experience, All the Rings is for you and it's free to download on the App Store. You can read about the inspiration behind All the Rings here. (tl;dr: We often missed our activity goals by small margins, so we created a companion to the activity app that would solve the problem.) For now, let's dive in so you can see what All the Rings is all about.

More Alerts

The first key feature we wanted to implement was more alerts and the ability to customize them. In my previous blog post I talked about just missing stand alerts. If you have an Apple Watch already, you know how it goes. You get the reminder and think "I'll stand up as soon as I finish..." and next thing you know it's too late. A single hourly alert is often not enough, but now you have the option of increasing your alert reminders so that you wont miss it so easily. You can now also receive move and exercise alerts to make sure you're hitting those goals too. 

Track Your Streaks

The second feature we wanted to add was the ability to better track streaks. We didn't call the app All the Rings for nothing. The idea here was that an increased awareness of your daily progress was critical in closing all the rings, every day. At a glance you can now look at your individual move, exercise, and stand streaks, as well as your All the Rings streak. Just for fun (and bragging rights, of course), we added is the ability for you to share this information and help you stay motivated.

Detailed Activity Stats

The third feature we wanted to incorporate was more detailed activity stats. At a glance we wanted the ability to see certain move, exercise, and stand data that was not available to us before. I had questions about my activity data and I wanted the answers. How many times did I reach my goals and what are my overall percentages? What was my best day? What are my overall averages? How many times have I increased or decreased my move goal? Am I making any progress? We answer those questions and then some. And once again, you can easily share this information.

Maximizing Workout Data

Once we got going with our initial feature list, we notice another area with opportunities for improvement: workout data. After playing tennis one evening, Dave and I noticed a huge spike in our activity performance as a result of that workout. In that moment we decided to tap into recorded exercise data to determine the efficiency of our favourite workouts. For example, if I needed 250 calories to hit my goal, I wanted to know which workout would get me there the fastest. ie. how many calories are burned per minute. While we were at it, we figured we would also let users sort their exercise data by most calories burned per workout or average calories burned per workout. You can also share the cumulative data from each type of workout you've logged.

All the Rings on the Apple Watch

Obviously, where All the Rings really shines is on the Apple Watch. Our goal was to make a companion app that complimented the built-in activity app, but at the same time could serve as a fully functional, standalone fitness tool that would be easy to use and get results. With one tap you can see your activity progress for the day and start a workout if you need to. All the Rings is all about efficiency too. No need to use two separate apps anymore.

Complications to Suit Everyones Needs

Choosing which complications appear on your watch face is a big deal. Screen real estate is at a premium, so we want you to get the most out of All the Rings' complications. Wether you want to see all the details or just see what your focused on, we've got you covered. Just go into the All the Rings Settings on your iPhone and select Configure Complications to choose from all of the options. My personal favourite is the circular move ring with the current stand hour indicator. At a glance, I can see how close I am to achieving my move goal and if I got my stand for the current hour. If the star is empty I still need to stand, if it's filled in I've got it already. So simple, yet so effective. You can see some of the other configurations below.

Set Multiple Goals for a Single Workout

For many people, the ability to set only one workout goal just doesn't cut it. Say you need an additional 250 calories and 15 minutes of exercise to close your rings for the day. With All the Rings you now have the option to set those goals. During your workout you will get progress alerts and a final alert when you hit each goal so you'll know when it's safe to wrap things up. Now that's workout #GOALS!

No More Screen Hopping

Focus and fluidity is essential when you're on the move. With All the Rings you can quickly see the status of your move and exercise progress during your workout without having to jump between the workout and activity app. But, that's not all. Your calories burned, heart rate, distance, and pace are front and center. Tap on each icon and get even more information including basal energy, average heart rate, speed, and steps - all on one screen.

We initially made All the Rings to improve our activity experience, and we want this app to fulfill your activity needs too. All the Rings wants to make it easier for you to close all the rings, every day, and that's why we're offering a free basic version of the app, with several paid Power Pack options to suit every budget. We even have a section inside the app that let's you vote on new features. We can't wait for you to try it and would love to hear your feedback!

It was a cold winter day last December. We had been out running errands all day, but apparently not moving enough to earn our 30 mins of exercise. At 11:58pm Dave noticed he still needed 3 minutes. He ran around the house in a desperate attempt to close his exercise ring, hoping just maybe the watch would be forgiving and give him credit for the 3 minutes. It was not to be. As the minutes ticked away into the new day, it became clear the 30th minute would never be filled. A 55 day exercise streak broken. "Damn it, my watch should have warned me" he said. And the idea for our newest app was born that night out of frustration.

Dave's story is not the exception. How many times have you been only a few calories away from achieving your move goal? Or missed getting your stand goal because you got the reminder and thought "I'll stand up as soon as I finish..." and next thing you know it's ten past and you've missed your window? It kept happening to Dave and I and it was really starting to get on our nerves. Instead of huffing and puffing about it, we decided to make a companion to the built in activity app that would solve the problem.

Once we decided to move forward with the idea, we realized there were a few more areas that had room for improvement. Over the past year, we've been working towards an enhanced activity experience - think, the activity app on steroids. It's called All the Rings, and it's available now on the App Store. You can read a detailed breakdown of everything All the Rings has to offer here.

Big news from Apple today:

Starting on May 1st 2017, commissions for all app and in-app content will be reduced from 7% to 2.5% globally.
Screenshot via @drbarnard on Twitter

Apple is reducing commissions paid to sites who promote our apps by 64%! That's a huge cut and they're only giving everyone involved 7 days notice.

The app economy has been tanking for the last few years. Apple must know this by now, even though they tout how great it is (maybe it is for a few big companies such as Niantic Labs, Nintendo etc). Personally I think this change in commission rate must be part of something larger, aimed to help rejuvenate the ailing app economy.

Back in June, 2016, Apple announced the first change in the percentage developers pay Apple, dropping the 30% rate to 15% but only for those using subscriptions, and only after a customer has been a subscriber for at least a year. For the most part, this would only have helped a few developers so far, since only a limited number of developers were even allowed to use subscriptions until the June changes. Those would be the Netflix/HBO type apps that are worth billions and don't need the extra help.

What I'd like to see at WWDC this year, is for Apple to announce they are finally reducing the 30% rate we pay to something more reasonable. Let's say 15%?

Assuming that's the plan, how about this as a proposed alternative? Instead of dropping the rate to 15% across the board, Apple could drop the rate to 15% for apps installed organically, and 20% for apps installed through an affiliate link. That extra 5% could then be paid to the affiliate who earned the sale. As a developer, I'm fine with that since it only helps those who help me.

I feel this would be a win-win for all involved. Developers get a much needed drop in their commission rate. Promotion sites such as iMore, touchArcade, etc will get a small bump instead of a drastic cut in their earnings, and Apple gets to keep the new 2.5% affiliate commission rate. I know dropping the developer rate isn't ideal for Apple, but it would make a big difference for the people who help keep their devices in demand.

What do you think about this proposal? Please @ me on Twitter and let me know your thoughts.

With the recent announcement of some App Store changes, and WWDC just days away, I figured I’d better write about an idea I had before it’s too late. I’ll keep this much shorter than the version that’s been floating around in my head.

I would suggest that Apple release their grip on the App Store, and start allowing other stores on iOS/tvOS which would, essentially create an App Mall. Open it up so that anyone can create a store. These will be distinct apps developed like any other third party app, clearly branded to avoid user confusion with Apple’s App Store. I envision stores created by brands you already know: TouchArcade, 148Apps, AppShopper, Google, Microsoft, Panic, OmniFocus, RelayFM (for sponsored apps) etc; as well as new ones that will appear.

These stores would be akin to radio stations. If a person likes Rock and Roll, they tune in to a Rock and Roll station. If they prefer Jazz, they listen to a Jazz station. Every once in a while you listen to something different. We’ll have stores that focus on pro apps, stores for games, a store for writers, developers, parents etc. Users will come to know and trust the curators of their favourite stores. This plan delegates some of the curation of apps out to the community where it can be handled much better (just because of sheer numbers). It doesn’t take away from Apple’s App Store curation, rather it enables a method to better group apps and aid with app discovery. Instead of trying to fit 2+ million apps into 25 categories, there will be another layer on top to help sort.

One huge side effect to this plan is that Apple would have more control over it’s own App Store. They will be able to delist a tonne of bad apps, and stop adding new bad apps by raising the criteria that allows apps to be listed in the official App Store. If an app is ugly as sin, riddled with spelling errors, etc, they can refuse to include it in their store, just as Saks Fifth Avenue can refuse to stock substandard products. Right now, Apple has a set of rules, and if your app follows those rules it should be allowed in the store. Ugly apps should never be featured anyway, but they still come up and clutter the search results, they still show up in the “Customers Also Bought” section. With my new plan, those apps won’t show up at all. It’s my belief that Apple has to generally accept any app that follows their rules, or else they’ll start to run afoul of anti-competition laws. Since there is no other way to sell apps to users with iOS/tvOS devices than through the Apple App Store, if they reject apps based on religious beliefs, politics, bad UI, etc, they are preventing other companies from operating, and could get into trouble.

It would sort of be like Panasonic selling a radio, and then saying no Justin Bieber songs can be played on them. How long would it be before Panasonic was dragged into court by the Department of Justice? So my point here is that because Apple would be allowing developers to list their apps in other stores, they’ll be free to be more selective in their own store.

None of this affects app review, signing, pricing or privacy BTW. All apps would still go through review (though it would be more for weeding out malware or buggy software). Apps would still be signed by the developers and installed from Apple’s servers. Just as the TestFlight app can install apps that aren’t in the App Store, third party stores would also be able to use an API to trigger app installs (securely of course, apps wouldn’t be able to install other apps without the user’s explicit permission). The price of an app would be the same, and the payment would still be handled by Apple. So privacy is preserved as Apple would still be the only one to know who the customer is. Apple could still take their 30% (or now 15% in some cases, hopefully more cases soon). The third party store developer would be compensated via the already existing affiliate program. Or depending on the store, they may charge the developer for a listing, just as grocery stores charge food producers for the valuable space on the end of the aisle.

The goal of this idea is to help with app discovery. By opening up the App Store in this way, it empowers the developers in our community to help solve this major problem that’s really hurting the platform, without compromising the security or privacy of the platform that users have come to expect.