-
Notifications
You must be signed in to change notification settings - Fork 29
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
Conversation
kdoctor/src/commonMain/kotlin/org/jetbrains/kotlin/doctor/diagnostics/CocoapodsDiagnostic.kt
Outdated
Show resolved
Hide resolved
val cocoapodsFromHomebrew = cocoapodsFormulae?.let { lines -> | ||
lines.find { it.contains("/bin/pod") } | ||
?.split("/") | ||
?.find { it.matches(Regex(COCOAPODS_VERSION_PATTERN)) } |
There was a problem hiding this comment.
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 -> |
There was a problem hiding this comment.
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") } |
There was a problem hiding this comment.
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})") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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})") |
There was a problem hiding this comment.
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
Fixed https://github.com/Kotlin/kdoctor/issues/11