Skip to content

Instantly share code, notes, and snippets.

@4np
Created July 28, 2022 09:54
Show Gist options
  • Select an option

  • Save 4np/db0e0154f011848054eb7103c487fd21 to your computer and use it in GitHub Desktop.

Select an option

Save 4np/db0e0154f011848054eb7103c487fd21 to your computer and use it in GitHub Desktop.

Revisions

  1. 4np created this gist Jul 28, 2022.
    43 changes: 43 additions & 0 deletions Podfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    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