Skip to content

Commit 30bc73f

Browse files
committed
Try to solve the SwiftPM issue because it does not support mixed Objective-C and Swift code, really suck, Apple :)
1 parent 73a9ff0 commit 30bc73f

File tree

5 files changed

+44
-23
lines changed

5 files changed

+44
-23
lines changed

Package.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@ let package = Package(
2424
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
2525
.target(
2626
name: "SDWebImageSwiftUI",
27+
dependencies: ["SDWebImage", "SDWebImageSwiftUIObjC"],
28+
path: "SDWebImageSwiftUI/Classes",
29+
exclude: ["ObjC"]
30+
),
31+
// This is implementation detail because SwiftPM does not support mixed Objective-C/Swift code, don't dependent this target
32+
.target(
33+
name: "SDWebImageSwiftUIObjC",
2734
dependencies: ["SDWebImage"],
28-
path: "SDWebImageSwiftUI/Classes"),
35+
path: "SDWebImageSwiftUI/Classes/ObjC",
36+
sources: ["SDAnimatedImageInterface.h", "SDAnimatedImageInterface.m"],
37+
publicHeadersPath: "."
38+
)
2939
]
3040
)

SDWebImageSwiftUI.xcodeproj/project.pbxproj

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
324F61C7235E07EC003973B8 /* SDAnimatedImageInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 324F61C5235E07EC003973B8 /* SDAnimatedImageInterface.h */; settings = {ATTRIBUTES = (Public, ); }; };
11+
324F61C8235E07EC003973B8 /* SDAnimatedImageInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 324F61C5235E07EC003973B8 /* SDAnimatedImageInterface.h */; settings = {ATTRIBUTES = (Public, ); }; };
12+
324F61C9235E07EC003973B8 /* SDAnimatedImageInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 324F61C5235E07EC003973B8 /* SDAnimatedImageInterface.h */; settings = {ATTRIBUTES = (Public, ); }; };
13+
324F61CA235E07EC003973B8 /* SDAnimatedImageInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 324F61C5235E07EC003973B8 /* SDAnimatedImageInterface.h */; settings = {ATTRIBUTES = (Public, ); }; };
14+
324F61CB235E07EC003973B8 /* SDAnimatedImageInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = 324F61C6235E07EC003973B8 /* SDAnimatedImageInterface.m */; };
15+
324F61CC235E07EC003973B8 /* SDAnimatedImageInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = 324F61C6235E07EC003973B8 /* SDAnimatedImageInterface.m */; };
16+
324F61CD235E07EC003973B8 /* SDAnimatedImageInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = 324F61C6235E07EC003973B8 /* SDAnimatedImageInterface.m */; };
17+
324F61CE235E07EC003973B8 /* SDAnimatedImageInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = 324F61C6235E07EC003973B8 /* SDAnimatedImageInterface.m */; };
1018
326E480A23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326E480923431C0F00C633E9 /* ImageViewWrapper.swift */; };
1119
326E480B23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326E480923431C0F00C633E9 /* ImageViewWrapper.swift */; };
1220
326E480C23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326E480923431C0F00C633E9 /* ImageViewWrapper.swift */; };
@@ -39,14 +47,6 @@
3947
32C43E3322FD5DF400BE87F5 /* SDWebImageSwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C43E3122FD5DE100BE87F5 /* SDWebImageSwiftUI.swift */; };
4048
32C43E3422FD5DF400BE87F5 /* SDWebImageSwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C43E3122FD5DE100BE87F5 /* SDWebImageSwiftUI.swift */; };
4149
32C43E3522FD5DF400BE87F5 /* SDWebImageSwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C43E3122FD5DE100BE87F5 /* SDWebImageSwiftUI.swift */; };
42-
32D9204E2349DBFC00C9CBE9 /* SDAnimatedImageInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D9204C2349DBFC00C9CBE9 /* SDAnimatedImageInterface.h */; settings = {ATTRIBUTES = (Public, ); }; };
43-
32D9204F2349DBFC00C9CBE9 /* SDAnimatedImageInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D9204C2349DBFC00C9CBE9 /* SDAnimatedImageInterface.h */; settings = {ATTRIBUTES = (Public, ); }; };
44-
32D920502349DBFC00C9CBE9 /* SDAnimatedImageInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D9204C2349DBFC00C9CBE9 /* SDAnimatedImageInterface.h */; settings = {ATTRIBUTES = (Public, ); }; };
45-
32D920512349DBFC00C9CBE9 /* SDAnimatedImageInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D9204C2349DBFC00C9CBE9 /* SDAnimatedImageInterface.h */; settings = {ATTRIBUTES = (Public, ); }; };
46-
32D920522349DBFC00C9CBE9 /* SDAnimatedImageInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D9204D2349DBFC00C9CBE9 /* SDAnimatedImageInterface.m */; };
47-
32D920532349DBFC00C9CBE9 /* SDAnimatedImageInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D9204D2349DBFC00C9CBE9 /* SDAnimatedImageInterface.m */; };
48-
32D920542349DBFC00C9CBE9 /* SDAnimatedImageInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D9204D2349DBFC00C9CBE9 /* SDAnimatedImageInterface.m */; };
49-
32D920552349DBFC00C9CBE9 /* SDAnimatedImageInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D9204D2349DBFC00C9CBE9 /* SDAnimatedImageInterface.m */; };
5050
/* End PBXBuildFile section */
5151

5252
/* Begin PBXCopyFilesBuildPhase section */
@@ -97,6 +97,8 @@
9797
/* End PBXCopyFilesBuildPhase section */
9898

9999
/* Begin PBXFileReference section */
100+
324F61C5235E07EC003973B8 /* SDAnimatedImageInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDAnimatedImageInterface.h; sourceTree = "<group>"; };
101+
324F61C6235E07EC003973B8 /* SDAnimatedImageInterface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDAnimatedImageInterface.m; sourceTree = "<group>"; };
100102
326E480923431C0F00C633E9 /* ImageViewWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewWrapper.swift; sourceTree = "<group>"; };
101103
32C43DCC22FD540D00BE87F5 /* SDWebImageSwiftUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDWebImageSwiftUI.framework; sourceTree = BUILT_PRODUCTS_DIR; };
102104
32C43DDC22FD54C600BE87F5 /* ImageManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageManager.swift; sourceTree = "<group>"; };
@@ -112,8 +114,6 @@
112114
32C43E2922FD586200BE87F5 /* SDWebImage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDWebImage.framework; path = Carthage/Build/tvOS/SDWebImage.framework; sourceTree = "<group>"; };
113115
32C43E2D22FD586E00BE87F5 /* SDWebImage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDWebImage.framework; path = Carthage/Build/watchOS/SDWebImage.framework; sourceTree = "<group>"; };
114116
32C43E3122FD5DE100BE87F5 /* SDWebImageSwiftUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDWebImageSwiftUI.swift; sourceTree = "<group>"; };
115-
32D9204C2349DBFC00C9CBE9 /* SDAnimatedImageInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDAnimatedImageInterface.h; sourceTree = "<group>"; };
116-
32D9204D2349DBFC00C9CBE9 /* SDAnimatedImageInterface.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDAnimatedImageInterface.m; sourceTree = "<group>"; };
117117
/* End PBXFileReference section */
118118

119119
/* Begin PBXFrameworksBuildPhase section */
@@ -152,6 +152,15 @@
152152
/* End PBXFrameworksBuildPhase section */
153153

154154
/* Begin PBXGroup section */
155+
324F61C4235E07EC003973B8 /* ObjC */ = {
156+
isa = PBXGroup;
157+
children = (
158+
324F61C5235E07EC003973B8 /* SDAnimatedImageInterface.h */,
159+
324F61C6235E07EC003973B8 /* SDAnimatedImageInterface.m */,
160+
);
161+
path = ObjC;
162+
sourceTree = "<group>";
163+
};
155164
32C43DC222FD540D00BE87F5 = {
156165
isa = PBXGroup;
157166
children = (
@@ -185,13 +194,12 @@
185194
32C43DDB22FD54C600BE87F5 /* Classes */ = {
186195
isa = PBXGroup;
187196
children = (
197+
324F61C4235E07EC003973B8 /* ObjC */,
188198
32C43DDC22FD54C600BE87F5 /* ImageManager.swift */,
189199
32C43DDE22FD54C600BE87F5 /* WebImage.swift */,
190200
32C43DDF22FD54C600BE87F5 /* AnimatedImage.swift */,
191201
32C43E3122FD5DE100BE87F5 /* SDWebImageSwiftUI.swift */,
192202
326E480923431C0F00C633E9 /* ImageViewWrapper.swift */,
193-
32D9204C2349DBFC00C9CBE9 /* SDAnimatedImageInterface.h */,
194-
32D9204D2349DBFC00C9CBE9 /* SDAnimatedImageInterface.m */,
195203
);
196204
path = Classes;
197205
sourceTree = "<group>";
@@ -214,7 +222,7 @@
214222
isa = PBXHeadersBuildPhase;
215223
buildActionMask = 2147483647;
216224
files = (
217-
32D9204E2349DBFC00C9CBE9 /* SDAnimatedImageInterface.h in Headers */,
225+
324F61C7235E07EC003973B8 /* SDAnimatedImageInterface.h in Headers */,
218226
32C43DE622FD54CD00BE87F5 /* SDWebImageSwiftUI.h in Headers */,
219227
);
220228
runOnlyForDeploymentPostprocessing = 0;
@@ -223,7 +231,7 @@
223231
isa = PBXHeadersBuildPhase;
224232
buildActionMask = 2147483647;
225233
files = (
226-
32D9204F2349DBFC00C9CBE9 /* SDAnimatedImageInterface.h in Headers */,
234+
324F61C8235E07EC003973B8 /* SDAnimatedImageInterface.h in Headers */,
227235
32C43E2222FD583A00BE87F5 /* SDWebImageSwiftUI.h in Headers */,
228236
);
229237
runOnlyForDeploymentPostprocessing = 0;
@@ -232,7 +240,7 @@
232240
isa = PBXHeadersBuildPhase;
233241
buildActionMask = 2147483647;
234242
files = (
235-
32D920502349DBFC00C9CBE9 /* SDAnimatedImageInterface.h in Headers */,
243+
324F61C9235E07EC003973B8 /* SDAnimatedImageInterface.h in Headers */,
236244
32C43E2322FD583B00BE87F5 /* SDWebImageSwiftUI.h in Headers */,
237245
);
238246
runOnlyForDeploymentPostprocessing = 0;
@@ -241,7 +249,7 @@
241249
isa = PBXHeadersBuildPhase;
242250
buildActionMask = 2147483647;
243251
files = (
244-
32D920512349DBFC00C9CBE9 /* SDAnimatedImageInterface.h in Headers */,
252+
324F61CA235E07EC003973B8 /* SDAnimatedImageInterface.h in Headers */,
245253
32C43E2422FD583C00BE87F5 /* SDWebImageSwiftUI.h in Headers */,
246254
);
247255
runOnlyForDeploymentPostprocessing = 0;
@@ -414,7 +422,7 @@
414422
326E480A23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */,
415423
32C43E1622FD583700BE87F5 /* ImageManager.swift in Sources */,
416424
32C43E1822FD583700BE87F5 /* AnimatedImage.swift in Sources */,
417-
32D920522349DBFC00C9CBE9 /* SDAnimatedImageInterface.m in Sources */,
425+
324F61CB235E07EC003973B8 /* SDAnimatedImageInterface.m in Sources */,
418426
);
419427
runOnlyForDeploymentPostprocessing = 0;
420428
};
@@ -427,7 +435,7 @@
427435
326E480B23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */,
428436
32C43E1922FD583700BE87F5 /* ImageManager.swift in Sources */,
429437
32C43E1B22FD583700BE87F5 /* AnimatedImage.swift in Sources */,
430-
32D920532349DBFC00C9CBE9 /* SDAnimatedImageInterface.m in Sources */,
438+
324F61CC235E07EC003973B8 /* SDAnimatedImageInterface.m in Sources */,
431439
);
432440
runOnlyForDeploymentPostprocessing = 0;
433441
};
@@ -440,7 +448,7 @@
440448
326E480C23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */,
441449
32C43E1C22FD583800BE87F5 /* ImageManager.swift in Sources */,
442450
32C43E1E22FD583800BE87F5 /* AnimatedImage.swift in Sources */,
443-
32D920542349DBFC00C9CBE9 /* SDAnimatedImageInterface.m in Sources */,
451+
324F61CD235E07EC003973B8 /* SDAnimatedImageInterface.m in Sources */,
444452
);
445453
runOnlyForDeploymentPostprocessing = 0;
446454
};
@@ -453,7 +461,7 @@
453461
326E480D23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */,
454462
32C43E1F22FD583800BE87F5 /* ImageManager.swift in Sources */,
455463
32C43E2122FD583800BE87F5 /* AnimatedImage.swift in Sources */,
456-
32D920552349DBFC00C9CBE9 /* SDAnimatedImageInterface.m in Sources */,
464+
324F61CE235E07EC003973B8 /* SDAnimatedImageInterface.m in Sources */,
457465
);
458466
runOnlyForDeploymentPostprocessing = 0;
459467
};

SDWebImageSwiftUI/Classes/AnimatedImage.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
import SwiftUI
1010
import SDWebImage
11+
#if canImport(SDWebImageSwiftUIObjC)
12+
import SDWebImageSwiftUIObjC
13+
#endif
1114

1215
// Data Binding Object
1316
final class AnimatedImageModel : ObservableObject {

SDWebImageSwiftUI/Classes/SDAnimatedImageInterface.h renamed to SDWebImageSwiftUI/Classes/ObjC/SDAnimatedImageInterface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* file that was distributed with this source code.
77
*/
88

9-
#import <SDWebImage/SDWebImage.h>
9+
@import SDWebImage;
10+
1011
#if SD_WATCH
1112
NS_ASSUME_NONNULL_BEGIN
1213

SDWebImageSwiftUI/Classes/SDAnimatedImageInterface.m renamed to SDWebImageSwiftUI/Classes/ObjC/SDAnimatedImageInterface.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#import "SDAnimatedImageInterface.h"
1010
#if SD_WATCH
11-
#import <SDWebImage/SDWebImage.h>
1211
// ImageIO.modulemap does not contains this public header
1312
#pragma clang diagnostic push
1413
#pragma clang diagnostic ignored "-Wincomplete-umbrella"

0 commit comments

Comments
 (0)