Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search

News & Updates

SDL iOS 5.0 Released!

Hello again, iOS developers! We've been making continual improvements on the new manager structure ever since it was released in November, 2016. In the year that passed, we've released now 15 updates on the 4.X branch. 5.0.0 work continued in parallel to many of those releases and represents almost 740 commits by numerous authors. To see everything that changed, see the release notes!

For most developers, v5.0 won't change too much of how you interact with SDL, but it makes SDL generally friendlier and easier to use. If you are a navigation app developer, v5.0 provides a big change to help your SDL experience. If you are a Swift developer, we hope you enjoy the vastly improved Swift support.

How Do I Get It?

Because this is a major version change, if you're using CocoaPods they will not automatically update you. Update your podfile to:

pod 'SmartDeviceLink-iOS', '~> 5.0'

You can also use the dynamic framework from our releases page, or Carthage.

All the New Stuff


Enum Changes

Enums have completely changed in v5.0 to greatly improve Swift compatibility and cut tens of thousands of lines of code. They are now all simple strings. Whereas before you might call:

Obj-C

[SDLHMILevel FULL]

Swift

.full()

You now call:

Obj-C

SDLHMILevelFull

Swift

.full


RPC Event Handler Improvements

When sending an RPC with a handler (introduced in v4.3), you now have more exact types passed back into that handler than just an SDLRPCNotificationNotification.

Before your code might be:

Obj-C

SDLSubscribeButton *button = [[SDLSubscribeButton alloc] initWithHandler:^(__kindof SDLRPCNotification * _Nonnull notification) {
    if (![notification isKindOfClass:[SDLOnButtonPress class]]) {
        return;
    }
    SDLOnButtonPress *buttonPress = (SDLOnButtonPress *)notification;
    if (buttonPress.buttonPressMode != SDLButtonPressMode.SHORT) {
        return;
    }
}];
[manager sendRequest:button];

Swift

let button = SDLSubscribeButton { [unowned store] (notification) in
    guard let buttonPress = notification as? SDLOnButtonPress else { return }
    guard buttonPress.buttonPressMode == .short() else { return }

    // Button was pressed
}!
button.buttonName = .seekleft()
manager.send(request: button)

You now have instead:

Obj-C

SDLSubscribeButton *button = [[SDLSubscribeButton alloc] initWithHandler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) {
    if (buttonPress != nil && buttonPress.buttonPressMode != SDLButtonPressModeShort) {
        return;
    }
}];

[manager sendRequest:button];

Swift

let button = SDLSubscribeButton { [unowned store] (press, event) in
    guard press.buttonPressMode == .short() else { return }

    // Button was pressed
}
button.buttonName = .seekLeft
manager.send(request: button)

Note that you no longer have to have pre-existing knowledge to cast into the correct types.

File Manager Enhancements

The file manager now has the ability to send multiple files in one call and receive a callback when all the uploads have completed.

Obj-C

// Upload a batch of files with a completion handler when done
[self.sdlManager.fileManager uploadFiles:files completionHandler:^(NSError * _Nullable error) {
    <#code#>
}];

// Upload a batch of files, being notified in the progress handler when each completes (returning whether or not to continue uploading), and a completion handler when done
[self.sdlManager.fileManager uploadFiles:files progressHandler:^BOOL(SDLFileName * _Nonnull fileName, float uploadPercentage, NSError * _Nullable error) {
    <#code#>
} completionHandler:^(NSError * _Nullable error) {
    <#code#>
}];

Swift

// Upload a batch of files with a completion handler when done
sdlManager.fileManager.upload(files: softButtonImages) { (error) in
    <#code#>
}

// Upload a batch of files, being notified in the progress handler when each completes (returning whether or not to continue uploading), and a completion handler when done
sdlManager.fileManager.upload(files: softButtonImages, progressHandler: { (fileName, uploadPercentage, error) -> Bool in
    <#code#>
}) { (error) in
    <#code#>
}


SDLConfiguration Changes

SDLConfiguration, which used to initialize SDLManager, has changed slightly. When creating a configuration, a logging configuration is now required. Furthermore, if you are creating a video streaming NAVIGATION or PROJECTION app, you must now create an SDLStreamingMediaConfiguration and add it to your SDLConfiguration before initializing the SDLManager. Additionally, if your app is in Swift, your initialization may have changed.

Obj-C

SDLConfiguration *config = [SDLConfiguration configurationWithLifecycle:lifecycleConfig lockScreen:[SDLLockScreenConfiguration enabledConfiguration] logging:[SDLLogConfiguration debugConfiguration]];

Swift

let configuration: SDLConfiguration = SDLConfiguration(lifecycle: lifecycleConfiguration, lockScreen: SDLLockScreenConfiguration.enabledConfiguration(), logging: SDLLogConfiguration())


Video Streaming Enhancements

Video streaming has been overhauled in SDL 5.0; SDL now takes care of just about everything for you automatically, including HMI changes and app state changes.

When setting your SDLConfiguration, you will have to set up an SDLStreamingMediaConfiguration.

SDLStreamingMediaConfiguration *streamingConfig = [SDLStreamingMediaConfiguration insecureConfiguration];
SDLConfiguration *config = [[SDLConfiguration alloc] initWithLifecycle:lifecycleConfig lockScreen:[SDLLockScreenConfiguration enabledConfiguration] logging:[SDLLogConfiguration debugConfiguration] streamingMedia:streamingConfig];

When you have a NAVIGATION or PROJECTION app and set this streaming configuration, SDL will automatically start the video streaming session on behalf of your app. When you receive the SDLVideoStreamDidStartNotification, start sending video data!

For more information about Video Streaming, see the dedicated section.

Touch Manager Delegate Changes
The touch manager delegate calls have all changed and previous delegate methods won't work. If you are streaming video and set the window, the new callbacks may return the view that was touched, otherwise it will return nil. For example:

- (void)touchManager:(SDLTouchManager *)manager didReceiveSingleTapForView:(UIView *_Nullable)view atPoint:(CGPoint)point;


Other Changes

Numerous other changes were made in 5.0.

Logging Changes
An entirely new logging system has been designed for speed, efficiency, and power. For more details on how to use it, see the updated documentation on the SDL website.

Immutability, Nullability, Generics

RPC collections – primarily arrays – are now immutable for safety and speed. The project also now uses nullability and generic tags throughout the project.


Thanks for reading! We look forward to seeing the great apps you build with SDL and to bringing you more improvements in the future. If you need to contact us, we're around StackOverflow, Github, and Slack. For more detailed information, see our guides.

Joel Fischer

iOS Lead

30 Nov 2017

Previous Article