Instagram / IGListKit

A data-driven UICollectionView framework for building fast and flexible lists.
https://instagram.github.io/IGListKit/
MIT License
12.86k stars 1.54k forks source link

Swift Package Manager integration already broken (4.0.0), though it's not a pain #1406

Open dreampiggy opened 4 years ago

dreampiggy commented 4 years ago

New issue checklist

General information

Debug information

# Please include debug logs using the following lldb command:
po [IGListDebugger dump]

Just two screenshots, enough to say the issues...

image

image

danqing commented 4 years ago

SPM isn't supported (https://github.com/Instagram/IGListKit/issues/1368).

Any idea when it can be added? @lorixx :)

dreampiggy commented 4 years ago

@danqing For SwiftPM on Objective-C, it's a pain because SwiftPM design assume using the raw C style for include public headers, however:

If you want to supports SwiftPM, you can checkout what SDWebImage do, which have also two Target (one SDWebImage and another SDWebImageMapKit). Which use the custom header search path to achieve this, and also have to hide the Private Headers (I previouslly think facebook guys already solve this problem, but actually not)

Bruce-pac commented 4 years ago

@dreampiggy I note that SDWebImage use #import ".h" to import its file. And I try that way on IGListKit and write the Package.swift, it works. So Is that what you mean above you said?

dreampiggy commented 4 years ago

@Bruce-pac Use both

@import IGListKit;
import IGListKit

cause the compile error showed in the first screenshot. You can have a check again at 4.0.0 version via SwiftPM.

Bruce-pac commented 4 years ago

@dreampiggy yeah, a big reason of that is that the Package.swift manifest file is not right. I'm trying rewrite Package.swift file. I note that SDWebImage use #import ".h" to import its file in its other file. such as this:

#import "SDAnimatedImage.h"
#import "NSImage+Compatibility.h"
#import "SDImageCoder.h"
#import "SDImageCodersManager.h"
#import "SDImageFrame.h"
#import "UIImage+MemoryCacheCost.h"
#import "SDImageAssetManager.h"

However, IGListKit use #import <A/B.h> to import its file in its other file. The modified file like:

// swift-tools-version:5.1
import PackageDescription

let package = Package(name: "IGListKit",
                      platforms: [
                          .macOS(.v10_11),
                          .iOS(.v9),
                          .tvOS(.v9)
                      ],
                     products: [
//                          .library(name: "IGListKit", targets: ["IGListKit"]),
                          .library(name: "IGListDiffKit", targets: ["IGListDiffKit"])
                      ],
                     dependencies: [],
                     targets: [.target(name: "IGListDiffKit",
                               dependencies: [],
                               path: nil,
                               sources: nil,
                               publicHeadersPath: "Source/IGListDiffKit/Public",
                               cSettings: [
                               .headerSearchPath("Public"),
                               .headerSearchPath("Internal"),
                             ],
                               linkerSettings: [
                             .linkedLibrary("libc++"),
                             ]
                     ),
//                          .target(name: "IGListKit",
//                                  dependencies: ["IGListDiffKit"],
//                                  path: ".",
//                                  sources: ["Source/IGListKit"],
//                                  publicHeadersPath: "include/IGListKit",
//                                  cSettings: [
//                                    .headerSearchPath("Source/IGListKit"),
//                                    .headerSearchPath("Source/IGListKit/Internal"),
//                                    .headerSearchPath(".")
//                                ],
//                                  linkerSettings: [
//                                  .linkedLibrary("libc++"),
//                                  ]
//                                )
    ],
                     cxxLanguageStandard: .cxx11)

If I modify the import style to #import ".h" , IGListDiffKit can compile success, but the original import style #import <A/B.h> cause the compile error showed in the first screenshot.

So I guess this issue maybe has two solutions, one is like SDWebImage, other is like CocoaLumberjack.

dreampiggy commented 4 years ago

If you use #import <A/B.h>. You must have public header search path, pointer to A's parent directory. SwiftPM for C/ObjC, only support one public header directory, and does not have module umbrella header like CocoaPods/Carthage (it use a Umbrella Directory, see: https://clang.llvm.org/docs/Modules.html#umbrella-directory-declaration)

For example, move the source code's header, as this strcture

- Source <---- Public Header Directory
-- IGListKit
--- IGListAdapter.h

So the SwiftPM can search this with <IGListKit/IGListAdapter.h>

claudiogomezGL commented 4 years ago

Do you have an ETA on when this is gonna be released? @Bruce-pac @dreampiggy

jafara commented 4 years ago

spm sucks, i stick with cocoapods

lorixx commented 4 years ago

OMG I had exact issue that @Bruce-pac experienced before: https://github.com/Instagram/IGListKit/issues/1368#issuecomment-696529398 this is what I am trying, maybe we cannot go around the Apple's setting to require "XXX.h" format instead of <Library/XXX>h> format here.

@dreampiggy interesting, I actually tried it out but I am not able to successfully build the project still.

dreampiggy commented 4 years ago

I'm not the maintainer of IGListKit. I'm the maintainer of SDWebImge.

You can try to see how we use symbol link the header to keep the same import syntax of #import <SDWebImage/SDWebImage.h> across all these Package Managers:

https://github.com/SDWebImage/SDWebImage/pull/2987

Though I think these massive crazy Package Managers (first Carthage) may disappear after some years of adopting SwiftPM.

3a4oT commented 3 years ago

Some work in progress #1465

BrentMifsud commented 3 years ago

any updates on this?