From a7f430a5ef391f830f7828c01002c0c42a5c9c97 Mon Sep 17 00:00:00 2001 From: Marc Terns Date: Thu, 12 Jul 2018 07:26:17 -0700 Subject: [PATCH] Feature podspec modules (#793) Summary: This PR adds support for using Yoga Swift dependents when Yoga is pulled as a static library. Currently swift projects trying to pull static libraries are unable to import the module. The reason for that is because the `DEFINES_MODULES` build setting is set to`NO`. If a Swift Framework is trying to `pod spec lint --use-libraries` with `Yoga` as a dependency, the validation will fail. With the `DEFINES_MODULE` enabled, the product will be treated as defining its own module. This enables automatic production of LLVM module map files when appropriate, and allows the product to be imported as a module. A workaround to this issue would be passing the `:modular_headers` flag to the `Podfile`, but that would not fix the `pod spec lint` validation for framework/library dependencies, it would just allow consuming applications to build and run. An example of this issue would be [SonarKit](https://github.com/facebook/Sonar/blob/master/iOS/SonarKit.podspec). `SonarKit` wasn't able to validate its podspec due to `YogaKit` (Swift Framework) depending on `Yoga` and SonarKit validating with the `--use-libraries` flag due to the c++ dependencies. We had to create a new version of [Yoga 1.9 podspec](https://github.com/facebook/Sonar/blob/master/Specs/Yoga/1.9/Yoga.podspec.json) and make sure to set the `DEFINES_MODULE` flag of the pod target. After that, we were able to `pod spec lint` `SonarKit.podspec` successfully. After merging a new `tag` should be created and the new podspec should be pushed to cocoapods master repository. Pull Request resolved: https://github.com/facebook/yoga/pull/793 Reviewed By: passy Differential Revision: D8820126 Pulled By: priteshrnandgaonkar fbshipit-source-id: 98eae3c31ec67a03c0fe97e05ab9e79446fa9f78 --- Yoga.podspec | 7 +++++-- YogaKit.podspec | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Yoga.podspec b/Yoga.podspec index 7d4553e8..a13fb02f 100644 --- a/Yoga.podspec +++ b/Yoga.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'Yoga' - spec.version = '1.8.1' + spec.version = '1.9.0' spec.license = { :type => 'MIT', :file => "LICENSE" } spec.homepage = 'https://yogalayout.com/' spec.documentation_url = 'https://yogalayout.com/docs' @@ -11,11 +11,14 @@ Pod::Spec.new do |spec| spec.authors = 'Facebook' spec.source = { :git => 'https://github.com/facebook/yoga.git', - :tag => '1.8.0', + :tag => spec.version.to_s, } spec.platforms = { :ios => "8.0", :tvos => "10.0" } spec.module_name = 'yoga' spec.requires_arc = false + spec.pod_target_xcconfig = { + 'DEFINES_MODULE' => 'YES' + } spec.compiler_flags = [ '-fno-omit-frame-pointer', '-fexceptions', diff --git a/YogaKit.podspec b/YogaKit.podspec index e21f6808..59af6974 100644 --- a/YogaKit.podspec +++ b/YogaKit.podspec @@ -1,6 +1,6 @@ podspec = Pod::Spec.new do |spec| spec.name = 'YogaKit' - spec.version = '1.8.1' + spec.version = '1.9.0' spec.license = { :type => 'MIT', :file => "LICENSE" } spec.homepage = 'https://facebook.github.io/yoga/' spec.documentation_url = 'https://facebook.github.io/yoga/docs/api/yogakit/' @@ -11,14 +11,14 @@ podspec = Pod::Spec.new do |spec| spec.authors = 'Facebook' spec.source = { :git => 'https://github.com/facebook/yoga.git', - :tag => '1.7.0', + :tag => spec.version.to_s, } spec.platform = :ios spec.ios.deployment_target = '8.0' spec.ios.frameworks = 'UIKit' - spec.dependency 'Yoga', '~> 1.8.1' + spec.dependency 'Yoga', '~> 1.9' spec.source_files = 'YogaKit/Source/*.{h,m,swift}' spec.public_header_files = 'YogaKit/Source/{YGLayout,UIView+Yoga}.h' spec.private_header_files = 'YogaKit/Source/YGLayout+Private.h'