Skip to content

Swift Package Manager: tools-5.3 manifest, badge xib resources, Bundle.module nib lookup - #157

Open
younatics wants to merge 1 commit into
Yalantis:masterfrom
younatics:spm-tools-5
Open

younatics wants to merge 1 commit into
Yalantis:masterfrom
younatics:spm-tools-5

Conversation

@younatics

Copy link
Copy Markdown

Problem

The Package.swift is a tools-4.0 manifest. On current toolchains that means two things:

  • the sources are compiled in Swift 4 language mode, which no longer builds on Xcode 26/27, and
  • the package declares no resources, so a BadgeWithCounterView created from a SwiftPM build cannot find BadgeWithCounterViewBigSized.xib / BadgeWithCounterViewStandardSized.xib (the lookup goes through the CocoaPods resource bundle, which does not exist under SwiftPM).

The README already advertises swiftpm-compatible, so this closes the gap between the badge and the manifest.

Solution

  • Package.swift: swift-tools-version:5.3, platforms: [.iOS(.v10)], and the two badge xibs declared as .process resources.
  • BadgeWithCounterView.swift: under #if SWIFT_PACKAGE the nib is loaded from Bundle.module; otherwise the existing CocoaPods resource-bundle lookup is kept. The view also falls back to the programmatic BadgeWithCounterView(frame: .zero) when the nib is not in the bundle instead of trapping.
  • README: a Swift Package Manager installation section.

The podspec, the Carthage project and the Example app are untouched.

Verification

Built a throw-away consumer package that depends on this branch with Xcode 27.1 for the iOS simulator (xcodebuild -scheme <consumer> -destination 'generic/platform=iOS Simulator'): the build succeeds and Segmentio_Segmentio.bundle contains both compiled nibs. The same manifest and lookup are running in MotionBook (App Store), where the Segmentio demo shows the badge counters.

…d a Bundle.module nib lookup

The tools-4.0 manifest compiles the sources in Swift 4 mode and ships no
resources, so a SwiftPM build of Segmentio either fails on current toolchains
or produces a BadgeWithCounterView that cannot find its nibs.

- Package.swift: swift-tools-version 5.3, platforms iOS 10, the two badge xibs
  declared as processed resources.
- BadgeWithCounterView: look the nib up in Bundle.module under SWIFT_PACKAGE,
  keep the CocoaPods resource-bundle lookup otherwise, and fall back to the
  programmatic view when the nib is missing instead of trapping.
- README: Swift Package Manager installation section.

Verified by building a consumer package against this manifest with Xcode 27.1
for the iOS simulator: Segmentio_Segmentio.bundle contains both compiled nibs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant