From 889248f4546003b150975774a4d496c70b0b2114 Mon Sep 17 00:00:00 2001 From: Claire Valliant Date: Tue, 21 May 2024 16:56:50 -0400 Subject: [PATCH 1/2] Rewrite Entitlements.plist to avoid newline issues. Git can be configured globally to mangle newlines to CRLF. Cookiecutter manages the git clone, so there's no easy way for us to set the configuration at the repository level during the templating process. The macOS utility `codesign` fails with obscure, hard to debug errors when presented with CRLF newlines in Entitlements.plist. --- hooks/post_gen_project.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 165f7cc..f0ca834 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -10,3 +10,12 @@ # Delete all remaining stubs for stub in BIN_PATH.glob("Stub-*"): os.unlink(stub) + +# The codesign utility in recent macOS fails with obscure errors when presented with +# CRLF line endings, but in some configurations (e.g. global `core.autocrlf=true`) +# git may have checked out this repo in a way that put CRLF line endings in Entitlements.plist. +# The following is thus a no-op most of the time, but it's a simple rewrite of a small file. +ENTITLEMENTS_PATH = Path("Entitlements.plist") +# This implicitly uses "universal" newlines mode. +xml_content = ENTITLEMENTS_PATH.read_text() +ENTITLEMENTS_PATH.open('w', newline='\n').write(xml_content) From 228fed080460f545f034ee4fcbbc4345ad645ac7 Mon Sep 17 00:00:00 2001 From: Claire Valliant Date: Wed, 22 May 2024 11:58:00 -0400 Subject: [PATCH 2/2] Rewrite Info.plist as well, in case other macOS tools care. --- hooks/post_gen_project.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index f0ca834..367bfc2 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -19,3 +19,7 @@ # This implicitly uses "universal" newlines mode. xml_content = ENTITLEMENTS_PATH.read_text() ENTITLEMENTS_PATH.open('w', newline='\n').write(xml_content) + +INFO_PATH = BIN_PATH.parent / 'Info.plist' +info_content = INFO_PATH.read_text() +INFO_PATH.open('w', newline='\n').write(info_content)