[PR #369] [MERGED] Fix a crash when encoding credentials in a test target #611

Closed
opened 2026-03-03 16:49:42 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/OAuthSwift/OAuthSwift/pull/369
Author: @eunikolsky
Created: 5/3/2017
Status: Merged
Merged: 5/4/2017
Merged by: @phimage

Base: masterHead: bugfix/crash_nil_bundleid


📝 Commits (1)

  • 65cfa7f Fix a crash when encoding credentials in a test target

📊 Changes

3 files changed (+35 additions, -1 deletions)

View changed files

📝 OAuthSwift.xcodeproj/project.pbxproj (+4 -0)
OAuthSwiftTests/OAuthSwiftCredentialTests.swift (+27 -0)
📝 Sources/OAuthSwiftCredential.swift (+4 -1)

📄 Description

When NSCoding an OAuthSwiftCredential instance, the test would crash
on CodingKeys initialization because the bundleIdentifier of the
Bundle.main in the tests is nil (the main bundle is not app's
bundle). This patch fixes that by trying to get one of the bundle
identifiers: the main one, the bundle for the OAuthSwiftCredential
class, or an empty string otherwise; a test is added to verify the fix.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/OAuthSwift/OAuthSwift/pull/369 **Author:** [@eunikolsky](https://github.com/eunikolsky) **Created:** 5/3/2017 **Status:** ✅ Merged **Merged:** 5/4/2017 **Merged by:** [@phimage](https://github.com/phimage) **Base:** `master` ← **Head:** `bugfix/crash_nil_bundleid` --- ### 📝 Commits (1) - [`65cfa7f`](https://github.com/OAuthSwift/OAuthSwift/commit/65cfa7fee4aeee8aa9ec6a5ad9c95393aab37e1f) Fix a crash when encoding credentials in a test target ### 📊 Changes **3 files changed** (+35 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `OAuthSwift.xcodeproj/project.pbxproj` (+4 -0) ➕ `OAuthSwiftTests/OAuthSwiftCredentialTests.swift` (+27 -0) 📝 `Sources/OAuthSwiftCredential.swift` (+4 -1) </details> ### 📄 Description When `NSCoding` an `OAuthSwiftCredential` instance, the test would crash on `CodingKeys` initialization because the `bundleIdentifier` of the `Bundle.main` in the tests is `nil` (the main bundle is not app's bundle). This patch fixes that by trying to get one of the bundle identifiers: the `main` one, the bundle for the `OAuthSwiftCredential` class, or an empty string otherwise; a test is added to verify the fix. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 16:49:42 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#611
No description provided.