Thumbnail image

New Feature: Smart New Version Check & UIKit Previews Since Version 2.2.2

Table of Contents

Abstract

While working on multiple mobile app projects, I noticed two recurring problems:

  • Users often don’t update the app because they never know a new version is available.
  • UIKit developers struggle to preview views quickly without running the whole app.

So in this update, we introduce two improvements to make development and user experience smoother.

Let’s Code

Auto-Check for New App Versions

Apps should always stay up to date with the latest performance and stability improvements. This new feature automatically checks for the latest version on the App Store and displays an update popup when needed.

image

Auto-Check for New App Versions - TTBaseUIKitExample

Info
First, if you haven’t installed TTBaseUIKit yet, you should read the setup guide at ttbaseuikit-ui-framework.

Then, you just need to call

import TTBaseUIKit
TTBaseCheckNewVersion.shared.onCheck()

If you don’t want the library to automatically fetch your app information using the buildId, simply provide it manually via paramConfig.appId.

let paramConfig:ParamConfig = ParamConfig()
paramConfig.appId = 1191396802
paramConfig.forceUpdateNewVersion = true
paramConfig.isGetNewVersionMessageByAppStore = true
TTBaseUIKitConfig.withDefaultConfig(withFontConfig: fontConfig, frameSize: sizeConfig, view: customView, style: styleConfig, params: paramConfig)?.start(withViewLog: false)
  • appId: Your application’s ID on the Apple App Store.
  • forceUpdateNewVersion: Set to true if you want to require users to update the app to the latest version before they can continue using it.
  • isGetNewVersionMessageByAppStore: Set to true if you want to retrieve the update message directly from the App Store.

Or you can customize the messages using the following language file:

"TTBaseUIkit.NewVersion.Title" = "New update available";
"TTBaseUIkit.NewVersion.SubTitle" = "This update brings enhanced performance and optimized stability. Update now to get the most out of the app";
"TTBaseUIkit.NewVersion.Button.Update" = "Update Now";
"TTBaseUIkit.NewVersion.Button.Later" = "Maybe Later";

Preview UIKit Views with PreviewProvider

SwiftUI already gives us powerful live previews, but UIKit developers have always lacked something similar. Now you can preview any UIKit view directly inside Xcode using PreviewProvider.

  • No need to run the app just to check small UI changes.
  • Faster UI iterations.
  • Easier debugging for layout, spacing, and edge cases.

UIViews

If you want to quickly preview UIViews, you can use TTBaseUIViewPreview.

 struct TTBaseUIViewPreview_Previews: PreviewProvider {
     static var previews: some View {
         TTBaseUIViewPreview {
             let testView:TTBaseUIView = TTBaseUIView()
             testView.setBgColor(UIColor.gray.withAlphaComponent(0.2))
             testView.setConerDef()
             return testView
         }
         .size(height: 200.0)
         .padding()
     }
 }

ViewControllers

If you want to quickly preview ViewControllers, you can use TTBaseUIViewControllerPreview.

struct MenuViewController_Previews: PreviewProvider {
    static var previews: some View {
        TTBaseUIViewControllerPreview {
            let vc = MenuViewController()
            return UINavigationController.init(rootViewController: vc)
        }
    }
}

Cells

If you want to quickly preview cells in table views and collection views, use TTBaseCellPreview.

 struct TTBaseCellPreviewPreview: PreviewProvider {
     static var previews: some View {
         TTBaseCellPreview(size: .init(width: 340, height: 80)) {
             let cell = TTIconTextSubtextTableViewCell()
             cell.panel.setHeightAnchor(constant: 80.0)
             return cell
         }
         .size(height: 80.0)
         .previewLayout(.sizeThatFits)
     }
 }
image

Preview UIKit - TTBaseUIKit Example

Conclusion

Both features aim to reduce the time spent on repetitive tasks and improve the overall development flow:

  • Automatic version checking: keeps users on the latest build.
  • UIKit previews: lets developers see UI changes instantly without running the app.

These updates continue the original goal of the base framework: build faster, debug smarter, and write less repetitive code.

TTBaseUIKit is a framework that helps you build iOS applications in the fastest and most efficient way, by providing base views written in both UIKit Programmatically and SwiftUI. The current release of TTBaseUIKit supports all versions of iOS and OS X since the introduction of Auto Layout on each platform, in Swift language with a single codebase.

What’s Next?

We’ve finished implementing the new version checking feature. In the next post, we’ll introduce the app update notification feature, helping users understand what’s new and what to pay attention to after updating the app. Happy coding! See you soon ^^

Posts in this Series