Skip to content

Commit dc2b5f4

Browse files
committed
update
1 parent 8eb9b70 commit dc2b5f4

8 files changed

+41
-1
lines changed

Sources/sharelink-for-swiftui/ShareLinkButton.swift

+3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
// Created by Igor on 29.10.2023.
66
//
77

8+
#if canImport(SwiftUI)
89
import SwiftUI
10+
#endif
911

1012
/// A SwiftUI view that provides a button to share data using `UIActivityViewController`.
1113
@available(iOS 14.0, *)
14+
@MainActor
1215
public struct ShareLinkButton<Label: View>: View {
1316

1417
/// State to control the presentation of the share sheet.

Sources/sharelink-for-swiftui/protocol/Transportable.swift

+5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
// Created by Igor on 01.07.24.
55
//
66

7+
#if canImport(UIKit)
78
import UIKit
9+
#endif
10+
11+
#if canImport(CoreLocation)
812
import CoreLocation
13+
#endif
914

1015
/// Protocol `Transportable` inherits `CustomStringConvertible` for providing textual descriptions of objects.
1116
/// This protocol and its extensions are available only on iOS and available since iOS 14.

Sources/sharelink-for-swiftui/swiftui/ShareLinkView.swift

+9
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@
44
// Created by Igor Shel on 29.10.2023.
55
//
66

7+
#if canImport(SwiftUI)
78
import SwiftUI
9+
#endif
10+
11+
#if canImport(UIKit)
812
import UIKit
13+
#endif
14+
15+
#if canImport(CoreLocation)
16+
import CoreLocation
17+
#endif
918

1019
/// A SwiftUI view that wraps a `UIActivityViewController` to share data.
1120
struct ShareLinkView: UIViewControllerRepresentable {

Sources/sharelink-for-swiftui/uikit/ActivitySheetController.swift

+2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
// Created by Igor Shel on 29.10.2023.
66
//
77

8+
#if canImport(UIKit)
89
import UIKit
10+
#endif
911

1012
/// A custom `UIActivityViewController` subclass that customizes the presentation of the activity sheet.
1113
final class ActivitySheetController: UIActivityViewController {

Sources/sharelink-for-swiftui/uikit/TransportableItem.swift

+5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
//
44
// Created by Igor Shel on 29.10.2023.
55

6+
#if canImport(UIKit)
67
import UIKit
8+
#endif
9+
10+
#if canImport(LinkPresentation)
711
import LinkPresentation
12+
#endif
813

914
/// A class that conforms to `UIActivityItemSource` to provide transportable items for sharing activities.
1015
final class TransportableItem<T: Transportable>: NSObject, UIActivityItemSource {

Sources/sharelink-for-swiftui/utils/AttributedStringBuilder.swift

+2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
// Created by Igor on 02.07.24.
66
//
77

8+
#if canImport(UIKit)
89
import UIKit
10+
#endif
911

1012
/// Builder class for creating `NSAttributedString` with custom attributes.
1113
final class AttributedStringBuilder {

Sources/sharelink-for-swiftui/utils/PrintFormatters.swift

+4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
// Created by Igor on 01.07.24.
55
//
66

7+
#if canImport(UIKit)
78
import UIKit
9+
#endif
810

911
/// Creates a `UISimpleTextPrintFormatter` for printing a string with a title.
1012
///
1113
/// - Parameters:
1214
/// - value: The string to be printed.
1315
/// - title: The title to be displayed above the string.
1416
/// - Returns: A `UISimpleTextPrintFormatter` configured with the provided string and title.
17+
@MainActor
1518
func printStringFormatter(_ value: String, _ title: String) -> UISimpleTextPrintFormatter {
1619
// Create attributed string for title using the builder
1720
let titleStr = AttributedStringBuilder()
@@ -38,6 +41,7 @@ func printStringFormatter(_ value: String, _ title: String) -> UISimpleTextPrint
3841
///
3942
/// - Parameter value: The image to be printed.
4043
/// - Returns: A `UIViewPrintFormatter` configured with the provided image.
44+
@MainActor
4145
func printImageFormatter(_ value: UIImage) -> UIViewPrintFormatter {
4246
return UIImageView(image: value).viewPrintFormatter()
4347
}

Sources/sharelink-for-swiftui/utils/TransportableItemBuilder.swift

+11-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44
// Created by Igor on 01.07.24.
55
//
66

7-
import UIKit
7+
#if canImport(SwiftUI)
88
import SwiftUI
9+
#endif
10+
11+
#if canImport(UIKit)
12+
import UIKit
13+
#endif
14+
15+
#if canImport(CoreLocation)
916
import CoreLocation
17+
#endif
1018

1119
/// Final builder class for creating transportable items with additional attributes for sharing.
20+
@MainActor
1221
final class TransportableItemBuilder<T: Transportable> {
1322

1423
/// The item to be shared, conforming to the `Transportable` protocol.
@@ -149,6 +158,7 @@ fileprivate func resolveTitle<T: Transportable>(item: T, title: String?) -> Stri
149158
/// - item: The item to be printed, conforming to the `Transportable` protocol.
150159
/// - resolvedTitle: The resolved title for the item.
151160
/// - Returns: A `UISimpleTextPrintFormatter` configured with the provided item and title.
161+
@MainActor
152162
fileprivate func createStringFormatter<T: Transportable>(item: T, resolvedTitle: String) -> UISimpleTextPrintFormatter {
153163
switch item {
154164
case let item as String:

0 commit comments

Comments
 (0)