Fix copy resources script for iOS < 6 and OS X < 10.8 #1030

Merged
merged 5 commits into from May 17, 2013

Conversation

Projects
None yet
4 participants
Contributor

rivera-ernesto commented May 7, 2013

Remove the following flag from the script to avoid crashes

man ibtool:

--reference-external-strings-file
              When combined with the --compile option, this flag indicates that the files in the Base.lproj locale  folder  should  be
              compiled  to reference the matching external strings files found in the other locales when loaded. Available on 10.8 and
              later.

New to cocoa pods (and Ruby!) so I need some help to evaluate greaterorquealto_osx10_8_or_ios6:

# target_installer.rb

      ENABLE_EXTERNAL_STRINGS_FILE_FLAG = {
        :ios => Version.new('6'),
        :osx => Version.new('10.8')
      }

      def create_copy_resources_script
        path = library.copy_resources_script_path
        UI.message "- Generating copy resources script at #{UI.path(path)}" do
          resources = library.file_accessors.map { |accessor| accessor.resources.flatten.map {|res| project.relativize(res)} }.flatten
          resources << bridge_support_file if bridge_support_file
          platform_name = library.platform.name
          reference_external_strings_file = library.platform.deployment_target >= ENABLE_EXTERNAL_STRINGS_FILE_FLAG[platform_name]
          generator = Generator::CopyResourcesScript.new(resources, reference_external_strings_file)
          generator.save_as(path)
          add_file_to_support_group(path)
        end
      end

Which in turn will remove the offending --reference-external-strings-file flag:

# copy_resources_script.rb

      def save_as(pathname)
        pathname.open('w') do |script|
          script.puts @reference_external_strings_file ? CONTENT : CONTENT.gsub(' --reference-external-strings-file', '')
          @resources.each do |resource|
            script.puts "install_resource '#{resource}'"
          end
        end
        # @todo use File api
        system("chmod +x '#{pathname}'")
      end
@rivera-ernesto rivera-ernesto [In progress] Fix copy resources script for iOS < 6 and OS X < 10.8
Remove the following flag from the script to avoid crashes

ibtool:

--reference-external-strings-file
              When combined with the --compile option, this flag indicates that the files in the Base.lproj locale  folder  should  be
              compiled  to reference the matching external strings files found in the other locales when loaded. Available on 10.8 and
              later.
4fd4624

Coverage Status

Coverage remained the same when pulling 4fd4624 on rivera-ernesto:fix_copy_resources_flag into d931a75 on CocoaPods:master.

Owner

alloy commented May 7, 2013

You can ask the library instance for its platform and check the deployment targets on that. Here’s an example of such code: https://github.com/CocoaPods/CocoaPods/blob/master/lib/cocoapods/installer/target_installer.rb#L358.

Contributor

rivera-ernesto commented May 13, 2013

Yeah, that would help, yet should I do it myself? I'm an Obj-C developer so my Ruby dev environment is not too good.

Contributor

rivera-ernesto commented May 15, 2013

Ok, it works now!

Owner

fabiopelosin commented May 15, 2013

Can you add a note in the changelog?

Contributor

rivera-ernesto commented May 16, 2013

Ok

Coverage Status

Coverage remained the same when pulling 2385716 on rivera-ernesto:fix_copy_resources_flag into 8534296 on CocoaPods:master.

Coverage Status

Coverage remained the same when pulling 2385716 on rivera-ernesto:fix_copy_resources_flag into 8534296 on CocoaPods:master.

@fabiopelosin fabiopelosin merged commit 2385716 into CocoaPods:master May 17, 2013

1 check failed

default The Travis CI build failed
Details
Owner

fabiopelosin commented May 17, 2013

@rivera-ernesto Thanks. I've done some minor refactoring as shown in the above commit.

Contributor

rivera-ernesto commented May 20, 2013

Sure, cheers.

rivera-ernesto deleted the rivera-ernesto:fix_copy_resources_flag branch May 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment