Created
July 28, 2022 09:54
-
-
Save 4np/db0e0154f011848054eb7103c487fd21 to your computer and use it in GitHub Desktop.
Podfile with customized Xcode sandbox sync messages if the sandbox is not in sync with Podfile.lock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://cdn.cocoapods.org/' | |
platform :ios, '15.0' | |
inhibit_all_warnings! | |
use_frameworks! | |
target 'MyApp' do | |
pod 'SomePod', '~> 1.0' | |
end | |
target 'MyEmbeddedFramework' do | |
pod 'SomeOtherPod', '~> 1.0' | |
end | |
post_integrate do |installer| | |
updateSandboxSyncMessagesIfNeeded() | |
end | |
# Update the Xcode warning to execute `./myscript.sh` if the sandbox is not in sync with Podfile.lock. | |
def updateSandboxSyncMessagesIfNeeded | |
updateSandboxSyncMessageIfNeeded('MyProject.xcodeproj') | |
updateSandboxSyncMessageIfNeeded('Frameworks/MyEmbeddedFramework/MyEmbeddedFramework.xcodeproj') | |
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 './myscript.sh' to fix.") | |
build_phase.shell_script = script | |
changed = true | |
end | |
end | |
end | |
if changed | |
project.save() | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment