Skip to content

Commit

Permalink
feat!: Add support for live update differentials (#83)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This _requires_ an update to LiveUpdates 0.5.0
  • Loading branch information
Steven0351 committed Feb 8, 2024
1 parent 9657c97 commit 32609b1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions IonicPortals.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Pod::Spec.new do |s|
s.source = { git: 'https://github.com/ionic-team/ionic-portals-ios.git', tag: s.version.to_s }
s.source_files = 'Sources/IonicPortals/*.swift'
s.dependency 'Capacitor', '~> 5.0'
s.dependency 'IonicLiveUpdates', '>= 0.1.2', '< 0.5.0'
s.swift_version = '5.4'
s.dependency 'IonicLiveUpdates', '>= 0.5.0', '< 0.6.0'
s.swift_version = '5.7'
end
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"repositoryURL": "https://github.com/ionic-team/ionic-live-updates-releases",
"state": {
"branch": null,
"revision": "fe3474212b612bdbb0496f81db854530b39ba0d5",
"version": "0.4.0"
"revision": "1b04d7e2afe633302dd4f4c4560eb3cd8d3719f9",
"version": "0.5.0"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm", .upToNextMajor(from: "5.0.0")),
.package(url: "https://github.com/ionic-team/ionic-live-updates-releases", "0.1.2"..<"0.5.0"),
.package(url: "https://github.com/ionic-team/ionic-live-updates-releases", "0.5.0"..<"0.6.0"),
],
targets: [
.target(
Expand Down
10 changes: 8 additions & 2 deletions Sources/IonicPortals/Portal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public struct Portal {
public var liveUpdateConfig: LiveUpdate? = nil {
didSet {
guard let liveUpdateConfig = liveUpdateConfig else { return }
try? liveUpdateManager.add(liveUpdateConfig)
try? liveUpdateManager.add(
liveUpdateConfig,
existingCacheUrl: bundle.url(forResource: startDir, withExtension: nil)
)
}
}

Expand Down Expand Up @@ -79,7 +82,10 @@ public struct Portal {
self.liveUpdateManager = liveUpdateManager
self.liveUpdateConfig = liveUpdateConfig
if let liveUpdateConfig = liveUpdateConfig {
try? liveUpdateManager.add(liveUpdateConfig)
try? liveUpdateManager.add(
liveUpdateConfig,
existingCacheUrl: bundle.url(forResource: self.startDir, withExtension: nil)
)
}
self.assetMaps = assetMaps
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/IonicPortals/PortalUIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class PortalUIView: UIView {
func initView () {
if PortalsRegistrationManager.shared.isRegistered {
if let liveUpdateConfig = portal.liveUpdateConfig {
self.liveUpdatePath = try? portal.liveUpdateManager.latestAppDirectory(for: liveUpdateConfig.appId)
self.liveUpdatePath = portal.liveUpdateManager.latestAppDirectory(for: liveUpdateConfig.appId)
}

addPinnedSubview(webView)
Expand All @@ -56,7 +56,7 @@ public class PortalUIView: UIView {
/// Reloads the underlying `WKWebView`
@objc public func reload() {
if let liveUpdate = portal.liveUpdateConfig,
let latestAppPath = try? portal.liveUpdateManager.latestAppDirectory(for: liveUpdate.appId),
let latestAppPath = portal.liveUpdateManager.latestAppDirectory(for: liveUpdate.appId),
liveUpdatePath == nil || liveUpdatePath?.path != latestAppPath.path {
liveUpdatePath = latestAppPath
return webView.setServerBasePath(path: latestAppPath.path)
Expand Down

0 comments on commit 32609b1

Please sign in to comment.