Last active
May 20, 2016 22:22
-
-
Save brovador/10002598 to your computer and use it in GitHub Desktop.
An extension of Xcodeproj::Project to add frameworks directly to a project
This file contains 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
require 'xcodeproj' | |
# Based on: http://blog.seiji.me/2012/02/10/create-xcodeproj-using-xcode-project/ | |
# example usage | |
# project.add_system_framework("Foundation.framework") | |
# project.add_system_framework("libxml2.dylib") | |
module Xcodeproj | |
class Project | |
def add_system_framework(fname) | |
name, path = nil, nil | |
if (fname =~ /^lib/) | |
name, path = fname, "usr/lib/#{fname}" | |
else | |
name, path = "#{fname}", "System/Library/Frameworks/#{fname}" | |
end | |
frameworks_group = self.frameworks_group | |
frameworks_group.children.each do |framework| | |
if framework.name == name | |
return | |
end | |
end | |
framework = self.new_file(path, :sdk_root) | |
framework.move(self.frameworks_group) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment