From e3e6ef2718d27cbd68bf76bbad1f82f853d367ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Tue, 23 Dec 2014 18:24:03 +0100 Subject: [PATCH] [iOS] Do not strip symbols from host that a framework requires. Fixes http://hipbyte.myjetbrains.com/youtrack/issue/RM-701. --- lib/motion/project/target/framework_target.rb | 13 +++++++++- lib/motion/project/xcode_config.rb | 24 ++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/motion/project/target/framework_target.rb b/lib/motion/project/target/framework_target.rb index bf6d44f6..898fc4a1 100644 --- a/lib/motion/project/target/framework_target.rb +++ b/lib/motion/project/target/framework_target.rb @@ -96,9 +96,20 @@ def framework_name File.basename(framework_path) end - # Indicates wether to load the framework at runtime or not + # Indicates whether to load the framework at runtime or not def load? @opts[:load] end + + # @return [Array] A list of symbols that the framework requires the + # host application or extension to provide and should not strip. + # + def required_symbols + executable_filename = File.basename(framework_path, '.framework') + executable = File.join(framework_path, executable_filename) + cmd = "/usr/bin/nm -ju '#{executable}' | /usr/bin/grep -E '^_(rb|vm)_'" + puts cmd if App::VERBOSE + `#{cmd}`.strip.split("\n") + end end end;end diff --git a/lib/motion/project/xcode_config.rb b/lib/motion/project/xcode_config.rb index 10b8ff47..309226ad 100644 --- a/lib/motion/project/xcode_config.rb +++ b/lib/motion/project/xcode_config.rb @@ -583,7 +583,6 @@ def clean_project attr_accessor :targets - # App Extensions are required to include a 64-bit slice for App Store # submission, so do not exclude `arm64` by default. # @@ -631,5 +630,28 @@ def target(path, type, opts={}) App.fail("Unsupported target type '#{type}'") end end + + # Creates a temporary file that lists all the symbols that the application + # (or extension) should not strip. + # + # At the moment these are only symbols that an iOS framework depends on. + # + # @return [String] Extra arguments for the `strip` command. + # + def strip_args + args = super + + frameworks = targets.select { |t| t.type == :framework } + required_symbols = frameworks.map(&:required_symbols).flatten.uniq.sort + unless required_symbols.empty? + require 'tempfile' + required_symbols_file = Tempfile.new('required-framework-symbols') + required_symbols.each { |symbol| required_symbols_file.puts(symbol) } + required_symbols_file.close + args << " -s '#{required_symbols_file.path}'" + end + + args + end end end; end