I am exploring the usage of Swift Macro in my CocoaPods-integrated project. I have successfully created a custom macro by following the instructions, and it functions properly in the host project. However, in the Pods
project, I am unable to import CustomMacro
for all the frameworks and development pods.
At this point, I am curious if there is a workaround that supports both CocoaPods and Swift Package Macro.
And also I found a Github thread discussing about a similiar topic: https://github.com/CocoaPods/CocoaPods/issues/11942 , but there's no further conclusion.
So please help to give some advises about how to use Swift Macro in CocoaPods project if you have any experience.
Inspired by @Soumuya Mahunt and some other post and discussion, I successfully integrate the Swift Macro to a CocoaPods managed project and its all pods. All the details and steps can be found in this blog or the demo project.
The macro pod can be easily used by a project target or a development pod target.
import MyMacro
let desc = #stringify(1 + 1)
For a development pod target or remote pod target, there would be some tricks to make it possible, add the following post_install
script in the Podfile
will be fine.
installer_representation.pods_project.build_configurations.each do |config|
config.build_settings['OTHER_SWIFT_FLAGS'] = "$(inherited) -load-plugin-executable #{macro_product_folder}/release/SwiftyArchitectureMacros#SwiftyArchitectureMacros"
end
Please see the blog for detail.