Skip to content

Commit 587f195

Browse files
authored
Fix Test App using CocoaPods (#439)
1 parent 434e47b commit 587f195

File tree

5 files changed

+122
-112
lines changed

5 files changed

+122
-112
lines changed

TestApp/Integrations/CocoaPods/Podfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
platform :ios, '11.0'
1+
platform :ios, '14.0'
22

33
target 'TestApp' do
44
# Comment the next line if you don't want to use dynamic frameworks
@@ -23,7 +23,7 @@ end
2323
post_install do |installer|
2424
installer.pods_project.targets.each do |target|
2525
target.build_configurations.each do |config|
26-
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
26+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
2727
config.build_settings['ENABLE_BITCODE'] = 'NO'
2828
end
2929
end

TestApp/Integrations/CocoaPods/Podfile+lcp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
platform :ios, '11.0'
1+
platform :ios, '14.0'
22

33
target 'TestApp' do
44
# Comment the next line if you don't want to use dynamic frameworks
@@ -25,7 +25,7 @@ end
2525
post_install do |installer|
2626
installer.pods_project.targets.each do |target|
2727
target.build_configurations.each do |config|
28-
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
28+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
2929
config.build_settings['ENABLE_BITCODE'] = 'NO'
3030
end
3131
end

TestApp/Sources/Reader/Common/DRM/LCPManagementTableViewController.swift

+95-91
Original file line numberDiff line numberDiff line change
@@ -8,109 +8,113 @@ import ReadiumNavigator
88
import ReadiumShared
99
import UIKit
1010

11-
protocol LCPManagementTableViewControllerFactory {
12-
func make(publication: Publication, delegate: ReaderModuleDelegate?) -> LCPManagementTableViewController?
13-
}
11+
#if LCP
1412

15-
class LCPManagementTableViewController: UITableViewController {
16-
@IBOutlet var stateLabel: UILabel!
17-
@IBOutlet var typeLabel: UILabel!
18-
@IBOutlet var providerLabel: UILabel!
19-
@IBOutlet var issuedLabel: UILabel!
20-
@IBOutlet var updatedLabel: UILabel!
13+
protocol LCPManagementTableViewControllerFactory {
14+
func make(publication: Publication, delegate: ReaderModuleDelegate?) -> LCPManagementTableViewController?
15+
}
2116

22-
@IBOutlet var startLabel: UILabel!
23-
@IBOutlet var endLabel: UILabel!
24-
@IBOutlet var printsLeftLabel: UILabel!
25-
@IBOutlet var copiesLeftLabel: UILabel!
17+
class LCPManagementTableViewController: UITableViewController {
18+
@IBOutlet var stateLabel: UILabel!
19+
@IBOutlet var typeLabel: UILabel!
20+
@IBOutlet var providerLabel: UILabel!
21+
@IBOutlet var issuedLabel: UILabel!
22+
@IBOutlet var updatedLabel: UILabel!
2623

27-
@IBOutlet var renewButton: UIButton!
28-
@IBOutlet var returnButton: UIButton!
24+
@IBOutlet var startLabel: UILabel!
25+
@IBOutlet var endLabel: UILabel!
26+
@IBOutlet var printsLeftLabel: UILabel!
27+
@IBOutlet var copiesLeftLabel: UILabel!
2928

30-
public var viewModel: LCPViewModel!
29+
@IBOutlet var renewButton: UIButton!
30+
@IBOutlet var returnButton: UIButton!
3131

32-
weak var moduleDelegate: ReaderModuleDelegate?
32+
public var viewModel: LCPViewModel!
3333

34-
override func viewWillAppear(_ animated: Bool) {
35-
title = NSLocalizedString("reader_drm_management_title", comment: "Title of the DRM management view")
36-
reload()
37-
}
34+
weak var moduleDelegate: ReaderModuleDelegate?
3835

39-
@IBAction func renewTapped() {
40-
let alert = UIAlertController(
41-
title: NSLocalizedString("reader_drm_renew_title", comment: "Title of the renew confirmation alert"),
42-
message: NSLocalizedString("reader_drm_renew_message", comment: "Message of the renew confirmation alert"),
43-
preferredStyle: .alert
44-
)
45-
let confirmButton = UIAlertAction(title: NSLocalizedString("confirm_button", comment: "Confirmation button to renew a publication"), style: .default, handler: { _ in
46-
Task {
47-
do {
48-
try await self.viewModel.renewLoan()
49-
self.reload()
50-
self.moduleDelegate?.presentAlert(
51-
NSLocalizedString("success_title", comment: "Title for the success message after renewing a publication"),
52-
message: NSLocalizedString("reader_drm_renew_success_message", comment: "Success message after renewing a publication"),
53-
from: self
54-
)
55-
56-
} catch {
57-
self.moduleDelegate?.presentError(error, from: self)
36+
override func viewWillAppear(_ animated: Bool) {
37+
title = NSLocalizedString("reader_drm_management_title", comment: "Title of the DRM management view")
38+
reload()
39+
}
40+
41+
@IBAction func renewTapped() {
42+
let alert = UIAlertController(
43+
title: NSLocalizedString("reader_drm_renew_title", comment: "Title of the renew confirmation alert"),
44+
message: NSLocalizedString("reader_drm_renew_message", comment: "Message of the renew confirmation alert"),
45+
preferredStyle: .alert
46+
)
47+
let confirmButton = UIAlertAction(title: NSLocalizedString("confirm_button", comment: "Confirmation button to renew a publication"), style: .default, handler: { _ in
48+
Task {
49+
do {
50+
try await self.viewModel.renewLoan()
51+
self.reload()
52+
self.moduleDelegate?.presentAlert(
53+
NSLocalizedString("success_title", comment: "Title for the success message after renewing a publication"),
54+
message: NSLocalizedString("reader_drm_renew_success_message", comment: "Success message after renewing a publication"),
55+
from: self
56+
)
57+
58+
} catch {
59+
self.moduleDelegate?.presentError(error, from: self)
60+
}
5861
}
59-
}
60-
})
61-
let dismissButton = UIAlertAction(title: NSLocalizedString("cancel_button", comment: "Cancel renewing the publication"), style: .cancel)
62+
})
63+
let dismissButton = UIAlertAction(title: NSLocalizedString("cancel_button", comment: "Cancel renewing the publication"), style: .cancel)
6264

63-
alert.addAction(dismissButton)
64-
alert.addAction(confirmButton)
65-
// Present alert.
66-
present(alert, animated: true)
67-
}
65+
alert.addAction(dismissButton)
66+
alert.addAction(confirmButton)
67+
// Present alert.
68+
present(alert, animated: true)
69+
}
6870

69-
@IBAction func returnTapped() {
70-
let alert = UIAlertController(
71-
title: NSLocalizedString("reader_drm_return_title", comment: "Title of the return confirmation alert"),
72-
message: NSLocalizedString("reader_drm_return_message", comment: "Message of the return confirmation alert"),
73-
preferredStyle: .alert
74-
)
75-
let confirmButton = UIAlertAction(title: NSLocalizedString("confirm_button", comment: "Confirmation button to return a publication"), style: .destructive, handler: { _ in
76-
Task {
77-
do {
78-
try await self.viewModel.returnPublication()
79-
80-
self.navigationController?.popToRootViewController(animated: true)
81-
self.moduleDelegate?.presentAlert(
82-
NSLocalizedString("success_title", comment: "Title for the success message after returning a publication"),
83-
message: NSLocalizedString("reader_drm_return_success_message", comment: "Success message after returning a publication"),
84-
from: self
85-
)
86-
87-
} catch {
88-
self.moduleDelegate?.presentError(error, from: self)
71+
@IBAction func returnTapped() {
72+
let alert = UIAlertController(
73+
title: NSLocalizedString("reader_drm_return_title", comment: "Title of the return confirmation alert"),
74+
message: NSLocalizedString("reader_drm_return_message", comment: "Message of the return confirmation alert"),
75+
preferredStyle: .alert
76+
)
77+
let confirmButton = UIAlertAction(title: NSLocalizedString("confirm_button", comment: "Confirmation button to return a publication"), style: .destructive, handler: { _ in
78+
Task {
79+
do {
80+
try await self.viewModel.returnPublication()
81+
82+
self.navigationController?.popToRootViewController(animated: true)
83+
self.moduleDelegate?.presentAlert(
84+
NSLocalizedString("success_title", comment: "Title for the success message after returning a publication"),
85+
message: NSLocalizedString("reader_drm_return_success_message", comment: "Success message after returning a publication"),
86+
from: self
87+
)
88+
89+
} catch {
90+
self.moduleDelegate?.presentError(error, from: self)
91+
}
8992
}
90-
}
91-
})
92-
let dismissButton = UIAlertAction(title: NSLocalizedString("cancel_button", comment: "Cancel returning the publication"), style: .cancel)
93+
})
94+
let dismissButton = UIAlertAction(title: NSLocalizedString("cancel_button", comment: "Cancel returning the publication"), style: .cancel)
9395

94-
alert.addAction(dismissButton)
95-
alert.addAction(confirmButton)
96-
// Present alert.
97-
present(alert, animated: true)
98-
}
96+
alert.addAction(dismissButton)
97+
alert.addAction(confirmButton)
98+
// Present alert.
99+
present(alert, animated: true)
100+
}
99101

100-
internal func reload() {
101-
typeLabel.text = "Readium LCP"
102-
stateLabel.text = viewModel.state
103-
providerLabel.text = viewModel.provider
104-
issuedLabel.text = viewModel.issued?.description
105-
updatedLabel.text = viewModel.updated?.description
106-
startLabel.text = viewModel.start?.description ?? "-"
107-
endLabel.text = viewModel.end?.description ?? "-"
108-
renewButton.isEnabled = viewModel.canRenewLoan
109-
returnButton.isEnabled = viewModel.canReturnPublication
110-
111-
Task {
112-
printsLeftLabel.text = await viewModel.printsLeft()
113-
copiesLeftLabel.text = await viewModel.copiesLeft()
102+
internal func reload() {
103+
typeLabel.text = "Readium LCP"
104+
stateLabel.text = viewModel.state
105+
providerLabel.text = viewModel.provider
106+
issuedLabel.text = viewModel.issued?.description
107+
updatedLabel.text = viewModel.updated?.description
108+
startLabel.text = viewModel.start?.description ?? "-"
109+
endLabel.text = viewModel.end?.description ?? "-"
110+
renewButton.isEnabled = viewModel.canRenewLoan
111+
returnButton.isEnabled = viewModel.canReturnPublication
112+
113+
Task {
114+
printsLeftLabel.text = await viewModel.printsLeft()
115+
copiesLeftLabel.text = await viewModel.copiesLeft()
116+
}
114117
}
115118
}
116-
}
119+
120+
#endif

TestApp/Sources/Reader/ReaderFactory.swift

+14-10
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,22 @@ extension ReaderFactory: OutlineTableViewControllerFactory {
2828
}
2929
}
3030

31-
extension ReaderFactory: LCPManagementTableViewControllerFactory {
32-
func make(publication: Publication, delegate: ReaderModuleDelegate?) -> LCPManagementTableViewController? {
33-
guard let license = publication.lcpLicense else {
34-
return nil
31+
#if LCP
32+
33+
extension ReaderFactory: LCPManagementTableViewControllerFactory {
34+
func make(publication: Publication, delegate: ReaderModuleDelegate?) -> LCPManagementTableViewController? {
35+
guard let license = publication.lcpLicense else {
36+
return nil
37+
}
38+
39+
let controller = storyboards.drm.instantiateViewController(withIdentifier: "DRMManagementTableViewController") as! LCPManagementTableViewController
40+
controller.moduleDelegate = delegate
41+
controller.viewModel = LCPViewModel(license: license, presentingViewController: controller)
42+
return controller
3543
}
36-
37-
let controller = storyboards.drm.instantiateViewController(withIdentifier: "DRMManagementTableViewController") as! LCPManagementTableViewController
38-
controller.moduleDelegate = delegate
39-
controller.viewModel = LCPViewModel(license: license, presentingViewController: controller)
40-
return controller
4144
}
42-
}
45+
46+
#endif
4347

4448
/// This is a wrapper for the "OutlineTableView" to encapsulate the "Cancel" button behaviour
4549
class OutlineHostingController: UIHostingController<OutlineTableView> {

TestApp/Sources/Reader/ReaderModule.swift

+9-7
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ final class ReaderModule: ReaderModuleAPI {
7777

7878
extension ReaderModule: ReaderFormatModuleDelegate {
7979
func presentDRM(for publication: Publication, from viewController: UIViewController) {
80-
guard let drmViewController: LCPManagementTableViewController = factory.make(publication: publication, delegate: delegate) else {
81-
return
82-
}
83-
let backItem = UIBarButtonItem()
84-
backItem.title = ""
85-
drmViewController.navigationItem.backBarButtonItem = backItem
86-
viewController.navigationController?.pushViewController(drmViewController, animated: true)
80+
#if LCP
81+
guard let drmViewController: LCPManagementTableViewController = factory.make(publication: publication, delegate: delegate) else {
82+
return
83+
}
84+
let backItem = UIBarButtonItem()
85+
backItem.title = ""
86+
drmViewController.navigationItem.backBarButtonItem = backItem
87+
viewController.navigationController?.pushViewController(drmViewController, animated: true)
88+
#endif
8789
}
8890

8991
func presentOutline(of publication: Publication, bookId: Book.Id, from viewController: UIViewController) -> AnyPublisher<Locator, Never> {

0 commit comments

Comments
 (0)