Skip to content

Instantly share code, notes, and snippets.

@ryanmeisters
Last active March 10, 2025 21:31
Show Gist options
  • Save ryanmeisters/972cd61933ab1a07b804f197bc98a5fc to your computer and use it in GitHub Desktop.
Save ryanmeisters/972cd61933ab1a07b804f197bc98a5fc to your computer and use it in GitHub Desktop.
Fastlane lane to add empty TargetAttributes to pbxproj.
# Adds empty TargetAttributes to pbxproj
lane :fix_target_attributes do |opts|
require 'xcodeproj'
xcodeproj_path = opts[:xcodeproj] || File.join(File.dirname(__FILE__), '..', XCODEPROJ_FILE)
UI.important("Fixing TargetAttributes in #{xcodeproj_path}")
project = Xcodeproj::Project.open(xcodeproj_path)
root_object = project.root_object
attributes = root_object.attributes
if attributes['TargetAttributes'].nil?
UI.important("TargetAttributes dictionary is missing, adding an empty one")
attributes['TargetAttributes'] = {}
project.save
UI.success("Successfully added empty TargetAttributes dictionary to project")
else
UI.message("TargetAttributes dictionary already exists in project")
end
end
@ryanmeisters
Copy link
Author

This is a workaround for the tuist/fastlane issue here

You can put this in your Fastfile and call it before calling update_project_codesigning_settings. I didn't even need to add xcodeproj to the gemfile since fastlane already uses it.

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