Some Cocoapods, e.g. YLTableView, don't set 'DEFINES_MODULE' => 'YES'
as part of their pod_target_xcconfig
. This means that, for example, import YLTableView
doesn't work in Swift unless you set :modular_headers => true
in your Podfile like so:
pod 'YLTableView', '~> 2.2.0', :modular_headers => true
If I'm writing a podspec, is there any reason I shouldn't include DEFINES_MODULE in my config like so?
ss.pod_target_xcconfig = { "DEFINES_MODULE" => "YES" }
It seems to me that this doesn't have any negative effect, and it enables Swift users to consume my library more easily.
A Podspec file, or Spec, describes a version of a Pod library. It includes details about where the source files are located, which files to use, the build settings to apply, dependencies, frameworks used and other general metadata such as the name, version and description for the Pod.
To create a Podspec, navigate to your project file in the Terminal. Run the following command to create the file: touch FantasticView. podspec . Now open the file using an editor.
A Podspec, or Spec, describes a version of a Pod library. One Pod, over the course of time, will have many Specs. It includes details about where the source should be fetched from, what files to use, the build settings to apply, and other general metadata such as its name, version, and description.
use_frameworks! in the Podfile means that we want the listed frameworks to be dynamically installed instead as static frameworks.
There is one known issue (with workarounds): https://github.com/CocoaPods/CocoaPods/issues/7584. It may cause issues for users importing your Objective-C lib headers directly in their Precompiled Headers (*.pch). You may workaround it by including an empty swift file in your lib source files. Chances are there will be a clean fix in a future version of CocoaPods.
Otherwise, there is no real downside. It enables stricter search paths for imports at build time, which means:
@import
in ObjC or import
in Swift)From the blog post regarding CocoaPods 1.5.0 release:
[...] CocoaPods allowed any pod to import any other pod with un-namespaced quote imports.
For example, pod B could have code that had a #import "A.h" statement, and CocoaPods will create build settings that will allow such an import to succeed. Imports such as these, however, will not work if you try to add module maps to these pods. We tried to automatically generate module maps for static libraries many years ago, and it broke some pods, so we had to revert.
In this release, you will be able to opt into stricter header search paths (and module map generation for Objective-C pods). As a pod author, you can add 'DEFINES_MODULE' => 'YES' to your pod_target_xcconfig. [...]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With