class AppleFrameworks::Framework
Creates an Apple (iOS or macOS) Framework
from an existing library (‘.a` file).
The Framework
is built up with a directory structure:
“‘ LibraryName.Framework
Info.plist library_name (the actual static lib) Headers (all the headers)
“‘
Public Class Methods
new(framework_name, parent_directory, library, headers_directory)
click to toggle source
-
parameter framework_name: The name of the resulting framework.
-
parameter parent_directory: The directory in which to create the framework.
-
parameter library: The library itself; the ‘.a` file.
-
parameter headers_directory: The directory which includes the headers. Normally located in the ‘include/` directory.
# File lib/apple_frameworks/framework.rb, line 23 def initialize(framework_name, parent_directory, library, headers_directory) @framework_name = framework_name @parent_directory = parent_directory @library = library @headers_directory = headers_directory @framework_directory = File.join( @parent_directory, "#{@framework_name}.framework" ) end
Public Instance Methods
build()
click to toggle source
Generates the ‘.framework` bundle.
# File lib/apple_frameworks/framework.rb, line 37 def build create_directories copy_lib copy_headers generate_plist end
Private Instance Methods
copy_headers()
click to toggle source
# File lib/apple_frameworks/framework.rb, line 62 def copy_headers FileUtils.cp_r(File.join(@headers_directory), File.join(@framework_directory, "Headers")) end
copy_lib()
click to toggle source
# File lib/apple_frameworks/framework.rb, line 58 def copy_lib FileUtils.cp(@library, File.join(@framework_directory, @framework_name)) end
create_directories()
click to toggle source
# File lib/apple_frameworks/framework.rb, line 46 def create_directories if File.directory?(@framework_directory) raise "Framework already exists" end if File.file?(@framework_directory) raise "File already exists at Framework destination" end FileUtils.mkdir_p(File.join(@framework_directory)) end
generate_plist()
click to toggle source
# File lib/apple_frameworks/framework.rb, line 66 def generate_plist filepath = File.join(@framework_directory, "Info.plist") plist_contents = <<~XML <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleName</key> <string>#{@framework_name}</string> <key>CFBundleDevelopmentRegion</key> <string>en</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundlePackageType</key> <string>FMWK</string> <key>CFBundleIdentifier</key> <string>#{@framework_name}.#{@framework_name}</string> <key>CFBundleExecutable</key> <string>#{@framework_name}</string> <key>CFBundleVersion</key> <string>1</string> </dict> </plist> XML File.open(filepath, "w") { |file| file.puts(plist_contents) } end