question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refactor Sonar Podspec to include all of its dependencies

See original GitHub issue

We 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:19 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
noahsark769commented, Jun 25, 2018

Dope, nice work!! It sounds like in order to be able to do this without a private repo, the following things need to happen:

  • PR for ComponentKit (already submitted and approved)
  • PR for Folly podspec (looks like there’s no podspec currently in the master repo, so I guess we should create a PR to add one)
  • PR for PeerTalk edits
  • PR for Yoga and YogaKit podspecs (this could be done in one since they’re in the same repo)

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 💃

2reactions
pkrmfcommented, Jun 25, 2018

@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:

  • Modify SonarKit.podspec. Along with several small fixes, I had to create a Core subspec that all the other subspaces depend on.
  • Create a CocoaPods private repository to host the pod specs that are not available in cocoapods master repo. The main reason I did this is to ensure I could eventually lint the podspec since I knew I was gonna be modifying existing dependencies(only podspecs).
  • Update ComponentKit.podspec and push it to the private repo. I also took care of submitting a pull request in ComponentKit repo to fix it. Will try to ask masters to push it to cocoapods master repo.
  • Update Folly.podspec. Applications would not be able to compile unless the ONLY_ACTIVE_ARCH for Folly and the app itself was set to YES. Ideally, we should be pushing the podspec to cocoapods master repo.
  • Update PeerTalk.podspec and source. Unfortunately I wasn’t able to compile without making some small code changes in PeerTalk source. I will revisit this later, but we also would want to get the latest PeerTalk updated podspec pushed to cocoapods master.
  • Modified YogaKit to not depend on a patch version(same as ComponentKit) and publish a new version to my cocoapods private repo. This one should be an easy change, since all we need to do is submit a PR in YogaKit to set the dependency on Yoga 1.8 instead of 1.8.1
  • Modified Sonar podspec.
  • Publish a new version of Yoga podspec with a few small changes and then I uploaded it to the private repo. The version changes was basically to avoid conflicts with Yoga in the cocoapods master repo. The Yoga.podspec includes "pod_target_xcconfig": { "DEFINES_MODULE": "YES" }, which allows swift to consume static libraries.
  • Publish some of the other dependencies like RSocket to the cocoapods private repository.

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found