Skip to content

Commit d5efe8b

Browse files
committed
fixed SPM target and added example project
1 parent 7f4d35c commit d5efe8b

File tree

12 files changed

+171
-78
lines changed

12 files changed

+171
-78
lines changed

AsyncDisplayKitIGListKit/Source

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../Source

Package.swift

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ let sharedDefines: [CSetting] = [
2727
// always disabled
2828
.define("IG_LIST_COLLECTION_VIEW", to: "0"),]
2929

30+
func IGListKit(enabled: Bool) -> [CSetting] {
31+
let state: String = enabled ? "1" : "0"
32+
return [
33+
.define("AS_IG_LIST_KIT", to: state),
34+
.define("AS_IG_LIST_DIFF_KIT", to: state),
35+
]
36+
}
37+
38+
3039
let package = Package(
3140
name: "Texture",
3241
platforms: [
@@ -56,21 +65,14 @@ let package = Package(
5665
path: "Source",
5766
exclude: ["Info.plist", "AsyncDisplayKitIGListKit"],
5867
publicHeadersPath: "include",
59-
cSettings: headersSearchPath + sharedDefines + [
60-
// IGListKit unavailable by default
61-
.define("AS_IG_LIST_KIT", to: "0"),
62-
.define("AS_IG_LIST_DIFF_KIT", to: "0"),
63-
]
68+
cSettings: headersSearchPath + sharedDefines + IGListKit(enabled: false)
6469
),
6570
.target(
6671
name: "AsyncDisplayKitIGListKit",
67-
dependencies: ["AsyncDisplayKit", "IGListKit"],
68-
path: "Source/AsyncDisplayKitIGListKit",
69-
cSettings: headersSearchPath + sharedDefines + [
70-
// opt-in IGListKit
71-
.define("AS_IG_LIST_KIT", to: "1"),
72-
.define("AS_IG_LIST_DIFF_KIT", to: "1"),
73-
]
72+
dependencies: ["IGListKit", "PINRemoteImage"],
73+
path: "AsyncDisplayKitIGListKit/Source",
74+
exclude: ["Info.plist"],
75+
cSettings: headersSearchPath + sharedDefines + IGListKit(enabled: true)
7476
),
7577
],
7678
cLanguageStandard: .c11,

Source/AsyncDisplayKitIGListKit/AsyncDisplayKitIGListKit.swift

Lines changed: 0 additions & 9 deletions
This file was deleted.

Source/Base/ASAvailability.h

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,22 @@
8484
#error "ASTEXTNODE_EXPERIMENT_GLOBAL_ENABLE is unavailable. See ASConfiguration.h."
8585
#endif
8686

87-
#if !SWIFT_PACKAGE
88-
#define AS_PIN_REMOTE_IMAGE __has_include(<PINRemoteImage/PINRemoteImage.h>)
89-
#define AS_IG_LIST_KIT __has_include(<IGListKit/IGListKit.h>)
90-
#define AS_IG_LIST_DIFF_KIT __has_include(<IGListDiffKit/IGListDiffKit.h>)
91-
92-
/**
93-
* For IGListKit versions < 3.0, you have to use IGListCollectionView.
94-
* For 3.0 and later, that class is removed and you use UICollectionView.
95-
*/
96-
#define IG_LIST_COLLECTION_VIEW __has_include(<IGListKit/IGListCollectionView.h>)
97-
#else
98-
#ifndef AS_PIN_REMOTE_IMAGE
99-
#define AS_PIN_REMOTE_IMAGE 1
100-
#endif
10187

102-
#ifndef AS_IG_LIST_KIT
103-
#define AS_PIN_REMOTE_IMAGE 0
104-
#endif
88+
#ifndef AS_PIN_REMOTE_IMAGE
89+
#define AS_PIN_REMOTE_IMAGE __has_include(<PINRemoteImage/PINRemoteImage.h>) || __has_include("PINRemoteImage.h")
90+
#endif
91+
92+
#ifndef AS_IG_LIST_KIT
93+
#define AS_IG_LIST_KIT __has_include(<IGListKit/IGListKit.h>) || __has_include("IGListKit.h")
94+
#endif
10595

106-
#ifndef AS_IG_LIST_DIFF_KIT
107-
#define AS_IG_LIST_DIFF_KIT 0
108-
#endif
109-
110-
#define IG_LIST_COLLECTION_VIEW 0
96+
#ifndef AS_IG_LIST_DIFF_KIT
97+
#define AS_IG_LIST_DIFF_KIT __has_include(<IGListDiffKit/IGListDiffKit.h>) || __has_include("IGListDiffKit.h")
11198
#endif
99+
100+
/**
101+
* For IGListKit versions < 3.0, you have to use IGListCollectionView.
102+
* For 3.0 and later, that class is removed and you use UICollectionView.
103+
*/
104+
#define IG_LIST_COLLECTION_VIEW 0
105+

Texture.podspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ Pod::Spec.new do |spec|
2020
core.exclude_files = [
2121
'Source/Classes/include/*',
2222
# Required only for SPM support.
23-
'Source/include/*',
24-
'Source/AsyncDisplayKitIGListKit/*'
23+
'Source/include/*'
2524
]
2625
core.public_header_files = [
2726
'Source/*.h',

examples/ASIGListKitSPM/ASIGListKitSPM.xcodeproj/project.pbxproj

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
FB32E78625768F45000C4F42 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FB32E78425768F45000C4F42 /* Main.storyboard */; };
1414
FB32E78825768F48000C4F42 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FB32E78725768F48000C4F42 /* Assets.xcassets */; };
1515
FB32E78B25768F48000C4F42 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FB32E78925768F48000C4F42 /* LaunchScreen.storyboard */; };
16-
FB32E79725768FC6000C4F42 /* AsyncDisplayKitIGListKit in Frameworks */ = {isa = PBXBuildFile; productRef = FB32E79625768FC6000C4F42 /* AsyncDisplayKitIGListKit */; };
1716
FB32E79B2576A451000C4F42 /* MainListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB32E79A2576A451000C4F42 /* MainListViewController.swift */; };
17+
FB3894A62576FC5F0025252E /* AsyncDisplayKitIGListKit in Frameworks */ = {isa = PBXBuildFile; productRef = FB3894A52576FC5F0025252E /* AsyncDisplayKitIGListKit */; };
18+
FB3894AB257705190025252E /* ItemSectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB3894AA257705190025252E /* ItemSectionController.swift */; };
19+
FB3894B2257705A80025252E /* NSObject+ListDiffable.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB3894B1257705A80025252E /* NSObject+ListDiffable.swift */; };
20+
FB3894B5257705EF0025252E /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB3894B4257705EF0025252E /* Item.swift */; };
1821
/* End PBXBuildFile section */
1922

2023
/* Begin PBXFileReference section */
@@ -26,16 +29,19 @@
2629
FB32E78725768F48000C4F42 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2730
FB32E78A25768F48000C4F42 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
2831
FB32E78C25768F48000C4F42 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
29-
FB32E79325768F8A000C4F42 /* Texture */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Texture; path = ../../..; sourceTree = "<group>"; };
3032
FB32E79A2576A451000C4F42 /* MainListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainListViewController.swift; sourceTree = "<group>"; };
33+
FB38949E2576FB5C0025252E /* Texture */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Texture; path = ../../..; sourceTree = "<group>"; };
34+
FB3894AA257705190025252E /* ItemSectionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemSectionController.swift; sourceTree = "<group>"; };
35+
FB3894B1257705A80025252E /* NSObject+ListDiffable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSObject+ListDiffable.swift"; sourceTree = "<group>"; };
36+
FB3894B4257705EF0025252E /* Item.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Item.swift; sourceTree = "<group>"; };
3137
/* End PBXFileReference section */
3238

3339
/* Begin PBXFrameworksBuildPhase section */
3440
FB32E77825768F45000C4F42 /* Frameworks */ = {
3541
isa = PBXFrameworksBuildPhase;
3642
buildActionMask = 2147483647;
3743
files = (
38-
FB32E79725768FC6000C4F42 /* AsyncDisplayKitIGListKit in Frameworks */,
44+
FB3894A62576FC5F0025252E /* AsyncDisplayKitIGListKit in Frameworks */,
3945
);
4046
runOnlyForDeploymentPostprocessing = 0;
4147
};
@@ -47,7 +53,7 @@
4753
children = (
4854
FB32E77D25768F45000C4F42 /* ASIGListKitSPM */,
4955
FB32E77C25768F45000C4F42 /* Products */,
50-
FB32E79525768FC6000C4F42 /* Frameworks */,
56+
FB38949F2576FB670025252E /* Frameworks */,
5157
);
5258
sourceTree = "<group>";
5359
};
@@ -62,7 +68,10 @@
6268
FB32E77D25768F45000C4F42 /* ASIGListKitSPM */ = {
6369
isa = PBXGroup;
6470
children = (
65-
FB32E79325768F8A000C4F42 /* Texture */,
71+
FB3894AE2577054F0025252E /* Extensions */,
72+
FB3894AD2577053C0025252E /* Models */,
73+
FB3894A9257704EF0025252E /* Section Controllers */,
74+
FB38949E2576FB5C0025252E /* Texture */,
6675
FB32E77E25768F45000C4F42 /* AppDelegate.swift */,
6776
FB32E78025768F45000C4F42 /* SceneDelegate.swift */,
6877
FB32E78225768F45000C4F42 /* ViewController.swift */,
@@ -75,13 +84,37 @@
7584
path = ASIGListKitSPM;
7685
sourceTree = "<group>";
7786
};
78-
FB32E79525768FC6000C4F42 /* Frameworks */ = {
87+
FB38949F2576FB670025252E /* Frameworks */ = {
7988
isa = PBXGroup;
8089
children = (
8190
);
8291
name = Frameworks;
8392
sourceTree = "<group>";
8493
};
94+
FB3894A9257704EF0025252E /* Section Controllers */ = {
95+
isa = PBXGroup;
96+
children = (
97+
FB3894AA257705190025252E /* ItemSectionController.swift */,
98+
);
99+
path = "Section Controllers";
100+
sourceTree = "<group>";
101+
};
102+
FB3894AD2577053C0025252E /* Models */ = {
103+
isa = PBXGroup;
104+
children = (
105+
FB3894B4257705EF0025252E /* Item.swift */,
106+
);
107+
path = Models;
108+
sourceTree = "<group>";
109+
};
110+
FB3894AE2577054F0025252E /* Extensions */ = {
111+
isa = PBXGroup;
112+
children = (
113+
FB3894B1257705A80025252E /* NSObject+ListDiffable.swift */,
114+
);
115+
path = Extensions;
116+
sourceTree = "<group>";
117+
};
85118
/* End PBXGroup section */
86119

87120
/* Begin PBXNativeTarget section */
@@ -99,7 +132,7 @@
99132
);
100133
name = ASIGListKitSPM;
101134
packageProductDependencies = (
102-
FB32E79625768FC6000C4F42 /* AsyncDisplayKitIGListKit */,
135+
FB3894A52576FC5F0025252E /* AsyncDisplayKitIGListKit */,
103136
);
104137
productName = ASIGListKitSPM;
105138
productReference = FB32E77B25768F45000C4F42 /* ASIGListKitSPM.app */;
@@ -157,6 +190,9 @@
157190
files = (
158191
FB32E78325768F45000C4F42 /* ViewController.swift in Sources */,
159192
FB32E77F25768F45000C4F42 /* AppDelegate.swift in Sources */,
193+
FB3894B2257705A80025252E /* NSObject+ListDiffable.swift in Sources */,
194+
FB3894AB257705190025252E /* ItemSectionController.swift in Sources */,
195+
FB3894B5257705EF0025252E /* Item.swift in Sources */,
160196
FB32E78125768F45000C4F42 /* SceneDelegate.swift in Sources */,
161197
FB32E79B2576A451000C4F42 /* MainListViewController.swift in Sources */,
162198
);
@@ -360,7 +396,7 @@
360396
/* End XCConfigurationList section */
361397

362398
/* Begin XCSwiftPackageProductDependency section */
363-
FB32E79625768FC6000C4F42 /* AsyncDisplayKitIGListKit */ = {
399+
FB3894A52576FC5F0025252E /* AsyncDisplayKitIGListKit */ = {
364400
isa = XCSwiftPackageProductDependency;
365401
productName = AsyncDisplayKitIGListKit;
366402
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// NSObject+ListDiffable.swift
3+
// ASIGListKitSPM
4+
//
5+
// Created by Petro Rovenskyy on 02.12.2020.
6+
//
7+
8+
import Foundation
9+
import IGListDiffKit
10+
11+
extension NSObject: ListDiffable {
12+
open func diffIdentifier() -> NSObjectProtocol {
13+
return self
14+
}
15+
open func isEqual(toDiffableObject object: ListDiffable?) -> Bool {
16+
return isEqual(object)
17+
}
18+
}

examples/ASIGListKitSPM/ASIGListKitSPM/MainListViewController.swift

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,6 @@
88
import UIKit
99
import AsyncDisplayKitIGListKit
1010

11-
extension NSObject: ListDiffable {
12-
open func diffIdentifier() -> NSObjectProtocol {
13-
return self
14-
}
15-
open func isEqual(toDiffableObject object: ListDiffable?) -> Bool {
16-
return isEqual(object)
17-
}
18-
}
19-
20-
final class Item: NSObject {
21-
let name: String
22-
init(name: String) {
23-
self.name = name
24-
super.init()
25-
}
26-
}
27-
28-
final class ItemSectionController: ListSectionController {
29-
30-
}
31-
3211
// MARK: ListAdapterDataSource
3312

3413
extension MainListViewController: ListAdapterDataSource {
@@ -67,6 +46,7 @@ final class MainListViewController: ASDKViewController<ASCollectionNode> {
6746
}
6847
override func viewDidLoad() {
6948
super.viewDidLoad()
49+
self.title = "AS+IG+SPM=💘"
7050
// Do any additional setup after loading the view.
7151
}
7252
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// Item.swift
3+
// ASIGListKitSPM
4+
//
5+
// Created by Petro Rovenskyy on 02.12.2020.
6+
//
7+
8+
import Foundation
9+
10+
final class Item: NSObject {
11+
let name: String
12+
init(name: String) {
13+
self.name = name
14+
super.init()
15+
}
16+
}

examples/ASIGListKitSPM/ASIGListKitSPM/SceneDelegate.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
1616
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
1717
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
1818
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
19-
guard let _ = (scene as? UIWindowScene) else { return }
19+
guard let windowScene = (scene as? UIWindowScene) else { return }
20+
self.window = UIWindow(windowScene: windowScene)
21+
22+
let rootVC = MainListViewController(flowLayout: UICollectionViewFlowLayout())
23+
let rootNC = UINavigationController(rootViewController: rootVC)
24+
self.window?.rootViewController = rootNC
25+
self.window?.makeKeyAndVisible()
2026
}
2127

2228
func sceneDidDisconnect(_ scene: UIScene) {

0 commit comments

Comments
 (0)