Skip to content

Conversation

@mrousavy
Copy link

@mrousavy mrousavy commented Sep 1, 2025

New Pull Request Checklist

  • I have read and understood the CONTRIBUTING guide
  • I have read the Documentation
  • I have searched for a similar pull request in the project and found none
  • I have updated this branch with the latest master to avoid conflicts (via merge from master or rebase)
  • I have added the required tests to prove the fix/feature I am adding
  • I have updated the documentation (if necessary)
  • I have run the tests and they pass
  • I have run the lint and it passes (pod lib lint)

Pull Request Description

If SDWebImage is imported in a Swift library with frameworks enabled (use_frameworks!), the pod install process fails because it does not define a module. I need modules in my nitro libraries, such as react-native-nitro-image - which uses SDWebImage.

To fix this, you need to set DEFINES_MODULE to YES in your pod config.

This was already done 7 years ago by @zhongwuzw in #2549, then reverted just two months later by @dreampiggy in #2604 because it broke the build in some projects:

Those issue reports are 6 years old and have been closed since many years, hinting that the issue has already been fixed. I have not had any issues with modules in Swift for at least 4 years too, so I think this is safe to add now. Let's test this enough before shipping though.

Summary by CodeRabbit

  • Chores
    • Updated build configuration to define the module when integrating via CocoaPods, improving Swift interoperability and enabling clean import usage.
    • Enhances compatibility with Catalyst and other modular build environments.
    • No changes to public APIs or runtime behavior.

If SDWebImage is imported in a Swift library with frameworks enabled (`use_frameworks!`), the pod install process fails because it does not define a module.
I need modules in my [nitro](https://github.com/mrousavy/nitro) libraries, such as [react-native-nitro-image](https://github.com/mrousavy/react-native-nitro-image) - which uses SDWebImage.

To fix this, you need to set `DEFINES_MODULE` to `YES` in your pod config.

This was already done 7 years ago by @zhongwuzw in SDWebImage#2549, then reverted just two months later by @dreampiggy in SDWebImage#2604 because it broke the build in some projects:

- SDWebImage#2601
- CocoaPods/CocoaPods#7584

Those issue reports are 6 years old and have been closed since many years, hinting that the issue has already been fixed. I have not had any issues with modules in Swift for at least 4 years too, so I think this is safe to add now.
Let's test this enough before shipping though.
@coderabbitai
Copy link

coderabbitai bot commented Sep 1, 2025

Walkthrough

Added DEFINES_MODULE => 'YES' to s.pod_target_xcconfig in SDWebImage.podspec, placed after DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER => 'NO'. No other podspec fields or public APIs were modified.

Changes

Cohort / File(s) Summary of changes
Podspec xcconfig update
SDWebImage.podspec
Inserted xcconfig key DEFINES_MODULE => 'YES' after DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER => 'NO'; rest of xcconfig unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

I twitch my whiskers, nod with glee,
A module defined—so clean to see.
One tiny flag in podspec’s scroll,
Click! The build now knows its role.
Hippity-hop through CI’s light,
Carrots compiled, all green and bright.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mrousavy
Copy link
Author

mrousavy commented Sep 1, 2025

@mrousavy
Copy link
Author

mrousavy commented Sep 1, 2025

The CI fails to build because;

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
		{ platform:iOS Simulator, OS:latest, name:iPhone 16 Pro Max }

	Available destinations for the "Tests iOS" scheme:
		{ platform:macOS, arch:arm64, variant:Mac Catalyst, id:0000FE00-C648B17BC1592925, name:My Mac }
		{ platform:macOS, arch:x86_64, variant:Mac Catalyst, id:0000FE00-C648B17BC1592925, name:My Mac }
		{ platform:macOS, variant:Mac Catalyst, name:Any Mac }

	Ineligible destinations for the "Tests iOS" scheme:
		{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device, error:iOS 18.0 is not installed. To use with Xcode, first download and install the platform }
Error: Process completed with exit code 70.

Seems to be unrelated. I had this issue before and re-running failed tests made it work.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
SDWebImage.podspec (2)

30-34: Optionally also flip CLANG_ENABLE_MODULES to explicit YES.
Some setups rely on this being explicit when modules are defined via xcconfig.

Apply this small addition:

   s.pod_target_xcconfig = {
     'SUPPORTS_MACCATALYST' => 'YES',
     'DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER' => 'NO',
-    'DEFINES_MODULE' => 'YES'
+    'DEFINES_MODULE' => 'YES',
+    'CLANG_ENABLE_MODULES' => 'YES'
   }

30-34: Add a tiny Swift import test_spec to lock this in (nice-to-have).
A Swift test that just import SDWebImage prevents future regressions.

Example (outside this hunk):

  • podspec:
s.test_spec 'SwiftImport' do |ts|
  ts.requires_app_host = false
  ts.source_files = 'Tests/SwiftImport/Sanity.swift'
  ts.frameworks = 'UIKit'
end
  • Tests/SwiftImport/Sanity.swift:
import SDWebImage
import UIKit
final class Sanity {
  func ping(_ v: UIImageView) { _ = v.sd_imageIndicator }
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 34cf242 and a0bc2e2.

📒 Files selected for processing (1)
  • SDWebImage.podspec (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Unit Test (iOS)
  • GitHub Check: Build Library
  • GitHub Check: Unit Test (macOS)
  • GitHub Check: Cocoapods Lint
  • GitHub Check: Cocoapods Demo
🔇 Additional comments (2)
SDWebImage.podspec (2)

33-33: LGTM: Re‑enabling module definition unblocks Swift import SDWebImage with use_frameworks!.
This aligns with the PR intent and should help Nitro-based Swift libraries.


30-34: Validate Podspec across CocoaPods integration modes: CocoaPods CLI isn’t available here; locally run the lint matrix (dynamic frameworks, static frameworks, static libraries with modular headers) across iOS, macOS, tvOS, and watchOS to ensure no regressions.

@dreampiggy
Copy link
Contributor

CocoaPods supports this by Podfile syntax use_modular_headers! or linkage: static

You don't need each Pod (podspec) to do this.

@dreampiggy dreampiggy closed this Sep 2, 2025
@mrousavy
Copy link
Author

mrousavy commented Sep 2, 2025

Adding it in a Podfile is not a solution for me.

My Pod requires it only for it's pod (and it's dependencies), and other pods in the project (React Native) cannot build with that enabled.

@mrousavy
Copy link
Author

bump @dreampiggy - what do you think about it? I don't think it has any negative side-effect, but not having it blocks me from shipping it in my library (like https://github.com/mrousavy/react-native-nitro-image)

@mrousavy
Copy link
Author

Hey @dreampiggy - sorry for tagging again, but I really think this PR should be merged.

As far as I am aware, it is non-breaking, and this is the only way to avoid the user having to manually edit his Podfile when using Swift Modules.

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.

2 participants