Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 5 commits into from

4 participants

@rivera-ernesto

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
@coveralls

Coverage Status

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

@alloy
Owner

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.

@rivera-ernesto

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.

@rivera-ernesto

Ok, it works now!

@fabiopelosin

Can you add a note in the changelog?

@coveralls

Coverage Status

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

@coveralls

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 from
@fabiopelosin

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

@rivera-ernesto

Sure, cheers.

@rivera-ernesto rivera-ernesto deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 7, 2013
  1. @rivera-ernesto

    [In progress] Fix copy resources script for iOS < 6 and OS X < 10.8

    rivera-ernesto authored
    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.
Commits on May 15, 2013
  1. @rivera-ernesto
Commits on May 16, 2013
  1. @rivera-ernesto
  2. @rivera-ernesto

    Update CHANGELOG

    rivera-ernesto authored
  3. @rivera-ernesto

    Update CHANGELOG.md

    rivera-ernesto authored
This page is out of date. Refresh to see the latest.
View
2  CHANGELOG.md
@@ -20,6 +20,8 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
* Inheriting `inhibit_warnings` per pod is now working
[#1032](https://github.com/CocoaPods/CocoaPods/issues/1032)
+* Fix copy resources script for iOS < 6 and OS X < 10.8 by removing the `--reference-external-strings-file`
+ flag. [#1030](https://github.com/CocoaPods/CocoaPods/pull/1030)
## 0.19.1
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.19.0...0.19.1)
View
5 lib/cocoapods/generator/copy_resources_script.rb
@@ -34,13 +34,14 @@ class CopyResourcesScript
attr_reader :resources
# A list of files relative to the project pods root.
- def initialize(resources = [])
+ def initialize(resources = [], reference_external_strings_file = false)
@resources = resources
+ @reference_external_strings_file = reference_external_strings_file
end
def save_as(pathname)
pathname.open('w') do |script|
- script.puts CONTENT
+ script.puts @reference_external_strings_file ? CONTENT : CONTENT.gsub(' --reference-external-strings-file', '')
@resources.each do |resource|
script.puts "install_resource '#{resource}'"
end
View
8 lib/cocoapods/installer/target_installer.rb
@@ -204,6 +204,10 @@ def create_bridge_support_file
end
end
+ ENABLE_EXTERNAL_STRINGS_FILE_FLAG = {
+ :ios => Version.new('6'),
+ :osx => Version.new('10.8')
+ }
# Creates a script that copies the resources to the bundle of the client
# target.
#
@@ -217,7 +221,9 @@ def create_copy_resources_script
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
- generator = Generator::CopyResourcesScript.new(resources)
+ 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
Something went wrong with that request. Please try again.