Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented detection of Cocoapods installed via Homebrew #15

Merged
merged 4 commits into from
Mar 25, 2022

Conversation

amatsegor
Copy link
Contributor

@amatsegor amatsegor commented Feb 20, 2022

val cocoapodsFromHomebrew = cocoapodsFormulae?.let { lines ->
lines.find { it.contains("/bin/pod") }
?.split("/")
?.find { it.matches(Regex(COCOAPODS_VERSION_PATTERN)) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally don't like using a separate version pattern for cocoapods found via brew. Probably we can just execute
<path_homebrew_pod_binary> --version to get version in the same format?

val cocoapodsFormulae = System.execute("brew", "list", "cocoapods").output
?.lines()

val cocoapodsFromHomebrew = cocoapodsFormulae?.let { lines ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If cocoapods are installed via brew and but not linked to /usr/local/bin then KDoctor will report cocoapods are found but they will be unusable for cocoapods gradle plugin. So we need to check pod command is available
When tried to install cocoapods via brew for the first time I had to execute brew link cocoapods manually to make pod command available.

?.lines()

val cocoapodsFromHomebrew = cocoapodsFormulae?.let { lines ->
lines.find { it.contains("/bin/pod") }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also an option to install cocoapods via brew install --cask cocoapods. In that case cocoapods app will be installed. The output of brew list cocoapods will be different, so KDoctor will report that cocoapods are not found but pod command will be available for the user which may confuse.

Also if cocoapods are installed as a cask pod gen command will not be available even if gem list cocoapods reports cocoapods-generate plugin is installed. Probably this is because of older version of cocoapods via cask.

}

if (cocoapodsFromHomebrew != null) {
messages.addSuccess("Found cocoapods in Homebrew: ${cocoapodsFromHomebrew.name} (${cocoapodsFromHomebrew.version})")
Copy link
Contributor

@vkormushkin vkormushkin Feb 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better if we keep existing format and add separate info message that cocoapods are installed via brew

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 , will do

val cocoapodsFromGem = cocoapodsGems?.firstOrNull { it.name == "cocoapods" }

if (cocoapodsFromGem != null) {
messages.addSuccess("Found cocoapods in Gem: ${cocoapodsFromGem.name} (${cocoapodsFromGem.version})")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand there is an assumption that cocoapods may be installed via gems and brew simultaneously. From cocoapods plugin perspective there is no difference how cocoapods are installed unless pod command is available in PATH. So probably we should not spam user with different cocoapods installations but just find the default one and report that everything is fine.

Probably we can consider utilising pod env for getting all required information for this diagnostic, such as cocoapods version, executable path, installed plugins (check for cocoapods generate) etc

@vkormushkin vkormushkin merged commit d2a4d1e into Kotlin:master Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cocoapods not found
4 participants