Refactor Sonar Podspec to include all of its dependencies
See original GitHub issueWe should make sure to declare all the Sonar dependencies within Sonar’s podspec, and make sure they point to the versions they depend on(we could also use the ~> for floating versions).
It is very hard to maintain an application consuming Sonar since its Podfile has to manually define all Sonar’s dependencies and the paths to the each one of the podspecs. What happens if we update Sonar? Then we also might have to manually update the dependencies Sonar is depending on.
There are two ways to prevent this from happening:
- Upload all the Sonar’s dependencies podspecs to the cocoapods public master repo along with Sonar podspec and make sure we define those dependencies in the Sonar’s podspec.
- Create a private repo and push the Sonar’s podspec and its podspec dependencies to it. Then communicate to consumers of Sonar that they have to include the source of the private repo within the Podfile.
Sonar’s consumers would go from this:
platform :ios, '8.0'
swift_version = '4.1'
target 'MyApp' do
pod 'RSocket', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/RSocket.podspec'
pod 'DoubleConversion', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/Folly.podspec'
pod 'PeerTalk', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/PeerTalk.podspec'
pod 'Yoga','~>1.8.1', :modular_headers => true
pod 'Sonar', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/xplat/Sonar/Sonar.podspec'
pod 'SonarKit', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/SonarKit.podspec'
pod 'SonarKit/SonarKitLayoutComponentKitSupport', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/SonarKit.podspec'
pod 'SonarKit/SKIOSNetworkPlugin', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/SonarKit.podspec'
pod 'ComponentKit', :podspec => 'https://raw.githubusercontent.com/facebook/Sonar/master/iOS/third-party-podspecs/ComponentKit.podspec'
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['YogaKit'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = swift_version
end
end
end
end
end
To this:
platform :ios, '8.0'
swift_version = '4.1'
# The path to the private repo source if we decide pod specs need to be hosted in a private repo.
source 'https://path/to/private/repo'
target 'MyApp' do
pod 'Sonar', '~>x.y'
end
If you guys are OK with this approach I can make the changes, create the private repo and submit the merge request.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:19 (17 by maintainers)
Top Results From Across the Web
'No such module' when I use CocoaPods - Stack Overflow
We have an application with multiple internal libraries, and those libraries also have dependencies on each other - which we accounted for the...
Read more >How to Manage Dependencies in iOS Development with Swift ...
Open the pod file in the project folder in any text editor. Add any pod name in the Pod file. Example: pod 'Alamofire',...
Read more >Podspec Syntax Reference v1.11.2 - CocoaPods Guides
A specification describes a version of Pod library. It includes details about where the source should be fetched from, what files to use,...
Read more >Specs and the Specs Repo - CocoaPods Guides
<How does the Specs Repo work? · Run pod spec lint . · Update your library to use Semantic Versioning, if it already...
Read more >Testing with CocoaPods
xcodeproj . Test spec sources and dependencies will not be included in the CoconutLib sources. You may choose to have multiple test specs...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Dope, nice work!! It sounds like in order to be able to do this without a private repo, the following things need to happen:
That makes sense right? Yoga/folly/componentkit look to be pretty active so PeerTalk might be the only one we have trouble with - hopefully we can get in contact with the maintainer and they can push a new version to Cocoapods master. If so, we can probably move forward with the Cocoapods master repo approach 💃
@emilsjolander and @priteshrnandgaonkar I made very good progress. So far, I am able to lint SonarKit.podspec. Here is what I have done so far to be able to lint it:
ONLY_ACTIVE_ARCH
for Folly and the app itself was set toYES
. Ideally, we should be pushing the podspec to cocoapods master repo."pod_target_xcconfig": { "DEFINES_MODULE": "YES" },
which allows swift to consume static libraries.I used the
--use-libraries
flag to lint the podspec. The reason for that is because we have dependencies that depend on other static libraries, and cocoapods wouldn’t allow the podspec to lint.This is the command I end up running:
pod spec lint SonarKit.podspec --sources=https://github.com/pkrmf/cocoapods-private-repo,master --allow-warnings --use-libraries
In the previous command, I basically tell cocoapods to lint the podspec using both master and my private repository, allow warnings and make sure to use static libraries, otherwise we will get the error I previously mentioned.
I tried other solutions, like making pods with static libraries dependencies as static_frameworks, so I could avoid passing the
--use-libraries
flag. By using static_frameworks in folly, or Sonar, for example, its consuming libraries/applications wouldn’t be able to import them. The header mapping directory (#include <Sonar/someFile.h>
, or modular imports(@import
) wouldn’t work at all.If someone wants to take a look at the work, bring some new ideas or maybe solutions to the other workarounds, feel free to contribute. If this is the way to go, then we need to get started and upload the new modified podspecs to cocoapods master repo. For that, I believe we will need to get with the owners of those libraries. We could otherwise leave the work as is, but we would have to require consumers of SonarKit to define my private repo as a source in their
Podfile
.