Skip to content

Instantly share code, notes, and snippets.

@tyronet-sportsbet
Created March 16, 2017 03:52
Show Gist options
  • Save tyronet-sportsbet/41225225425eed0d3a3aff5b6a06d6d9 to your computer and use it in GitHub Desktop.
Save tyronet-sportsbet/41225225425eed0d3a3aff5b6a06d6d9 to your computer and use it in GitHub Desktop.
Searches through a provided Objective-C header and removes any imports to other headers that are not present in any folder under the current working folder tree
#!/usr/bin/env ruby
module_headers = Dir.glob("**/*.h").map {|f| File.basename(f) }
bridging_header = File.read(ARGV[0])
output_header = ""
bridging_header.lines.each do |l|
if match = l.match(/#import\s*"(.*)"/)
header = match.captures[0]
if module_headers.include?(header)
output_header << l
end
else
output_header << l
end
end
File.write(ARGV[0], output_header)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment