Currently, the project.pbxproj files will always display the same error message if Podfile.lock is out of sync, namely:
The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
It would be great if pod install would take an optional argument to update the error message or parts of the error message, as we use a more elaborate bash script to update all sorts of dependencies. It would be nice if the error message would be able to point to the bash script as well so developers would not run the wrong command. Perhaps something like:
pod -customCommand ./my-special-script.sh install
Which would then cause the error message to be:
The sandbox is not in sync with the Podfile.lock. Run './my-special-script.sh' or update your CocoaPods installation.
You can of course sed the messages in the pbxproj files, but then Xcode will complain that the files were updated outside of Xcode and it needs to reload from disk. It is probably cleaner if pod install could handle it.
find . -type f -name project.pbxproj -exec sed -i '' -e 's/pod install/\.\/my-special-script.sh/' {} \;
Yeap could expand this via perhaps an env variable or some other means.
Hey @4np , check out this issue and my comment here https://github.com/CocoaPods/CocoaPods/issues/9891#issuecomment-699731571, it will help you achieve the solution you want 馃檹
@dnkoutso as the issue I mentioned above was closed, I believe this one can be closed as well, since they're the equivalent 馃槉
Sounds good. post_install should be fine here, can easily append to the text CocoaPods sets to prevent breakage.
Also does not affect anything with respect to installation as it all happens before save is called.
FYI, I am updating the message like so:
In Podfile:
post_integrate do |installer|
...
updateSandboxSyncMessagesIfNeeded()
end
def updateSandboxSyncMessagesIfNeeded
updateSandboxSyncMessageIfNeeded('MyApplication.xcodeproj')
projects = [
'MyApplication.xcodeproj',
'SomeFramework/SomeFramework.xcodeproj',
...
]
projects.each { |project|
updateSandboxSyncMessageIfNeeded(project)
}
end
def updateSandboxSyncMessageIfNeeded(projectFile)
project = Xcodeproj::Project.open(projectFile)
changed = false
project.targets.each do |target|
target.build_phases.each do |build_phase|
if defined?(build_phase.shell_script) && build_phase.shell_script.include?("pod install")
script = build_phase.shell_script.gsub("The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.",
"The sandbox is not in sync, please run './my-fancy-script.sh' to fix.")
build_phase.shell_script = script
changed = true
end
end
end
if changed
project.save()
puts "Updating out of sync sandbox message for #{projectFile}"
end
end
Note: I ran into an issue where the shell script change randomly got reverted (using CocoaPods 1.8.4). I was able to solve it by
1.10.0.rc.1 and moving it into the new post_integrate hook (rather than the post_install hook).Awesome - thanks for sharing your setup @4np ! 馃檶
Most helpful comment
FYI, I am updating the message like so:
In
Podfile:Note: I ran into an issue where the shell script change randomly got reverted (using CocoaPods
1.8.4). I was able to solve it by1.10.0.rc.1and moving it into the newpost_integratehook (rather than thepost_installhook).