CocoaPods / Xcodeproj

Create and modify Xcode projects from Ruby.

Home Page:http://rubygems.org/gems/xcodeproj

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

predictabilize_uuids doesn't work with target dependencies

OneSadCookie opened this issue · comments

predictabilize_uuids doesn't work with target dependencies, for example, if you want to generate a project with targets for both an iOS app and its share extension, the app target needs to depend on the extension target. When "predictabilizing" UUIDs for such a project, the UUIDs for some of the share extension objects will not be stable.

The reason for this is that the original random UUIDs are included in the values of UUIDGenerator's paths_by_object property, which must contain only stable data, since it's hashed to to produce the stable UUID.

For my use case, I was able to work around the issue by adding this line:

      def tree_hash_to_path(object, depth = 4)
        return '|' if depth.zero?
        case object
        when Hash
          object.sort.each_with_object('') do |(key, value), string|
+           next if key == 'remoteGlobalIDString' || key == 'containerPortal'
            string << key << ':' << tree_hash_to_path(value, depth - 1) << ','
          end
        when Array
          object.map do |value|
            tree_hash_to_path(value, depth - 1)
          end.join(',')
        else
          object.to_s
        end
      end

However, I don't believe this is a real solution for the problem, since this effectively ignores the target relationships when generating stable IDs.

That definitely looks like a bug! We will be happy for a PR.

In the meantime, I suggest you take a look at https://github.com/igor-makarov/censorius which takes a different approach. Keep in mind that it's extremely experimental at this point.

Thanks, I did find your project, however it simply crashes on my project file.

I would love to know more about the crash, I'm actively developing it. Please consider reporting an issue there!