Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/launchpad/size/analyzers/apple.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,23 @@ def analyze(self, artifact: AppleArtifact) -> AppleAnalysisResults:

return results

def parse_plist_date(self, date_value: str | datetime | None) -> str | None:
if date_value is None:
return None

if isinstance(date_value, str):
try:
dt = datetime.fromisoformat(date_value)
return dt.isoformat()
except (ValueError, AttributeError):
# If parsing fails, return the original string
# This is defensive - we don't want to break on unexpected formats
logger.debug(f"Could not parse date string: {date_value}")
return date_value

# isinstance(date_value, datetime)
return date_value.isoformat()

@sentry_sdk.trace
def _extract_app_info(self, xcarchive: ZippedXCArchive) -> AppleAppInfo:
"""Extract basic app information.
Expand All @@ -278,16 +295,12 @@ def _extract_app_info(self, xcarchive: ZippedXCArchive) -> AppleAppInfo:
if provisioning_profile:
codesigning_type, profile_name = self._get_profile_type(provisioning_profile)
expiration_date = provisioning_profile.get("ExpirationDate")
if expiration_date:
# Convert datetime to ISO format string
profile_expiration_date = expiration_date.isoformat()
profile_expiration_date = self.parse_plist_date(expiration_date)
certificate_expiration_date = self._extract_certificate_expiration_date(provisioning_profile)

build_date = None
archive_plist = xcarchive.get_archive_plist()
if archive_plist:
creation_date = archive_plist.get("CreationDate")
build_date = creation_date.isoformat() if creation_date else None
build_date = self.parse_plist_date(archive_plist.get("CreationDate"))

supported_platforms = plist.get("CFBundleSupportedPlatforms", [])
is_simulator = "iphonesimulator" in supported_platforms or plist.get("DTPlatformName") == "iphonesimulator"
Expand Down
Loading