Skip to content

Commit dbc2b08

Browse files
committed
[OS X] Add codesign_frameworks to configuration. Use it to specify which
frameworks to codesign.
1 parent e247650 commit dbc2b08

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

lib/motion/project/app.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ def codesign(platform)
8686
builder.codesign(config, platform)
8787
end
8888

89+
def codesign_framework(framework)
90+
builder.codesign_framework(framework, config)
91+
end
92+
8993
def profile(platform, config_plist)
9094
builder.profile(config, platform, config_plist)
9195
end

lib/motion/project/template/osx.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,24 @@
3939
desc "Build the project for development"
4040
task :development do
4141
App.build('MacOSX')
42-
App.codesign('MacOSX') if App.config_without_setup.codesign_for_development
42+
if App.config_without_setup.codesign_for_development
43+
App.config.codesign_frameworks.each do |e|
44+
App.codesign_framework(e)
45+
end
46+
App.codesign('MacOSX')
47+
end
4348
end
4449

4550
desc "Build the project for release"
4651
task :release do
4752
App.config_without_setup.build_mode = :release
4853
App.build('MacOSX')
49-
App.codesign('MacOSX') if App.config_without_setup.codesign_for_release
54+
if App.config_without_setup.codesign_for_release
55+
App.config.codesign_frameworks.each do |e|
56+
App.codesign_framework(e)
57+
end
58+
App.codesign('MacOSX')
59+
end
5060
end
5161
end
5262

lib/motion/project/template/osx/builder.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,15 @@ def codesign(config, platform)
5252
sh "/usr/bin/codesign --force --sign \"#{config.codesign_certificate}\" --entitlements \"#{entitlements}\" \"#{app_bundle}\""
5353
end
5454
end
55+
56+
def codesign_framework(framework, config)
57+
app_bundle = config.app_bundle_raw('MacOSX')
58+
path = "#{app_bundle}/Contents/Frameworks/#{framework}/Versions/A"
59+
if File.mtime(config.project_file) > File.mtime(path) \
60+
or !system("/usr/bin/codesign --verify \"#{path}\" >& /dev/null")
61+
App.info 'Codesign', path
62+
sh "/usr/bin/codesign --force --sign \"#{config.codesign_certificate}\" \"#{path}\""
63+
end
64+
end
5565
end
5666
end; end

lib/motion/project/template/osx/config.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class OSXConfig < XcodeConfig
3333
variable :icon, :copyright, :category,
3434
:embedded_frameworks, :external_frameworks,
3535
:codesign_for_development, :codesign_for_release,
36-
:eval_support
36+
:eval_support, :codesign_frameworks
3737

3838
def initialize(project_dir, build_mode)
3939
super
@@ -43,6 +43,7 @@ def initialize(project_dir, build_mode)
4343
@frameworks = ['AppKit', 'Foundation', 'CoreGraphics', 'CoreServices']
4444
@codesign_for_development = false
4545
@codesign_for_release = true
46+
@codesign_frameworks = []
4647
@eval_support = false
4748
end
4849

0 commit comments

Comments
 (0)