-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add common headers for Platform, SDK version, Source app (#455)
- Loading branch information
Showing
8 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Foundation | ||
|
||
#if !SWIFT_PACKAGE | ||
private class BundleFinder: NSObject {} | ||
extension Bundle { | ||
static var module: Bundle { | ||
let defaultBundle = Bundle(for: BundleFinder.self) | ||
// If installed with CocoaPods, resources will be in Gravatar.bundle | ||
// The name of the bundle "Gravatar.bundle" (without the .bundle file extension) | ||
// needs to match the key in the respective Gravatar.podspec: | ||
// `s.resource_bundles = { 'Gravatar' => ['Sources/Gravatar/Resources/*.plist'] }` | ||
if let bundleURL = defaultBundle.resourceURL, | ||
let resourceBundle = Bundle(url: bundleURL.appendingPathComponent("Gravatar.bundle")) | ||
{ | ||
return resourceBundle | ||
} | ||
// Otherwise, the default bundle is used for resources | ||
return defaultBundle | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Foundation | ||
|
||
enum BundleInfo { | ||
public static var sdkVersion: String? { | ||
getInfoValue(forKey: "CFBundleShortVersionString") as? String | ||
} | ||
|
||
public static var appName: String? { | ||
Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String | ||
} | ||
|
||
private static func getInfoValue(forKey key: String) -> Any? { | ||
// Access the SDKInfo.plist using Bundle.module | ||
guard let url = Bundle.module.url(forResource: "SDKInfo", withExtension: "plist"), | ||
let data = try? Data(contentsOf: url), | ||
let plist = try? PropertyListSerialization.propertyList(from: data, options: [], format: nil) as? [String: Any] | ||
else { | ||
return nil | ||
} | ||
return plist[key] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleShortVersionString</key> | ||
<string>2.1.1</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters