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

Created on 12 Dec 2019  Â·  11Comments  Â·  Source: Instagram/IGListKit

New issue checklist

  • [x] I have reviewed the README and documentation
  • [x] I have searched existing issues and this is not a duplicate
  • [x] I have attempted to reproduce the issue and include an example project.

General information

  • IGListKit version: 4.0.0
  • iOS version(s): Any
  • CocoaPods/Carthage version: None
  • Xcode version: Xcode 11.2.1
  • Devices/Simulators affected: Any
  • Reproducible in the demo project? (Yes/No): Yes
  • Related issues:

Debug information

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

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

image

image

bug

Most helpful comment

Some work in progress #1465

All 11 comments

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

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

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

  • Objective-C developer used to use Object.h/Object.m in the same directory, not a standalone include directory for public headers. Tha's a suck for treating Objective-C the same as C.

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)

@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?

@Bruce-pac Use both

  • Objective-C
@import IGListKit;
  • Swift
import IGListKit

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

@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.

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>

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

spm sucks, i stick with cocoapods

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 h> format here.

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

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:

  • CocoaPods (including static library/framework, use modular headers, 3 types)
  • Carthage (prebuilt binary framework)
  • SwiftPM

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.

Some work in progress #1465

Was this page helpful?
0 / 5 - 0 ratings