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

Add Support for Development Cocoapods #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/cocoapods/bazel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ def self.post_install(installer:)
workspace = installer.config.installation_root
sandbox = installer.sandbox

# Delete previously created symlinks for Development Pods
system("find #{workspace}/Pods -maxdepth 1 -type l -delete", exception: true)

# Ensure we declare the sandbox (Pods/) as a package so each Pod (as a package) belongs to sandbox root package instead
FileUtils.touch(File.join(installer.config.sandbox_root, 'BUILD.bazel'))

build_files = Hash.new { |h, k| h[k] = StarlarkCompiler::BuildFile.new(workspace: workspace, package: k) }
installer.pod_targets.each do |pod_target|
package = sandbox.pod_dir(pod_target.pod_name).relative_path_from(workspace).to_s
if package.start_with?('..')
raise Informative, <<~MSG
Bazel does not support Pod located outside of current workspace: \"#{package}\".
To fix this, you can move the Pod into workspace,
or you can symlink the Pod inside the workspace by running `ln -s <path_to_pod> .` at workspace root
Then change path declared in Podfile to `./<pod_name>`
Current workspace: #{workspace}
MSG
## Symlink Development Pods into the workspace to build with Bazel.
UI.warn"Created symlink for Development Pod - #{pod_target.pod_name} to support building with Bazel"

system("ln -s #{workspace}/#{package} #{workspace}/Pods", exception: true)
File.rename "#{workspace}/Pods/#{File.basename(package)}", "#{workspace}/Pods/#{pod_target.pod_name}"
end

build_file = build_files[package]
Expand Down