Skip to content

Commit

Permalink
Read app name at runtime rather than hardcoding it
Browse files Browse the repository at this point in the history
  • Loading branch information
saagarjha committed Jan 26, 2024
1 parent ad8d90b commit d779014
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
6 changes: 6 additions & 0 deletions MacCast.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
49226A332AE45D710044CFC9 /* RootWindowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49226A322AE45D710044CFC9 /* RootWindowView.swift */; };
494DFBD12B29111C00205CAC /* Keys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 494DFBD02B29111C00205CAC /* Keys.swift */; };
494DFBD22B29111C00205CAC /* Keys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 494DFBD02B29111C00205CAC /* Keys.swift */; };
495A8AB22B6478AE00520461 /* Bundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 495A8AB12B6478AE00520461 /* Bundle.swift */; };
495A8AB32B6478AE00520461 /* Bundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 495A8AB12B6478AE00520461 /* Bundle.swift */; };
495E8E3B2AD5CE2400946419 /* ImageBufferView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 495E8E3A2AD5CE2400946419 /* ImageBufferView.swift */; };
495E8E3D2AD5E6C500946419 /* SerializableConformances.swift in Sources */ = {isa = PBXBuildFile; fileRef = 495E8E3C2AD5E6C500946419 /* SerializableConformances.swift */; };
495E8E3E2AD5E6C500946419 /* SerializableConformances.swift in Sources */ = {isa = PBXBuildFile; fileRef = 495E8E3C2AD5E6C500946419 /* SerializableConformances.swift */; };
Expand Down Expand Up @@ -61,6 +63,7 @@
49226A302AE447C10044CFC9 /* ScreenRecorder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenRecorder.swift; sourceTree = "<group>"; };
49226A322AE45D710044CFC9 /* RootWindowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootWindowView.swift; sourceTree = "<group>"; };
494DFBD02B29111C00205CAC /* Keys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Keys.swift; sourceTree = "<group>"; };
495A8AB12B6478AE00520461 /* Bundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bundle.swift; sourceTree = "<group>"; };
495E8E3A2AD5CE2400946419 /* ImageBufferView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageBufferView.swift; sourceTree = "<group>"; };
495E8E3C2AD5E6C500946419 /* SerializableConformances.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SerializableConformances.swift; sourceTree = "<group>"; };
4977168F2B29260A0048ED18 /* EventView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -217,6 +220,7 @@
isa = PBXGroup;
children = (
4989D33F2B0B9393005E2E7A /* shut_up_logging.c */,
495A8AB12B6478AE00520461 /* Bundle.swift */,
49B352C62AE53A9300BCE03D /* Frame.swift */,
494DFBD02B29111C00205CAC /* Keys.swift */,
49E09BC12AD52C7800B56CD3 /* macOSInterface.swift */,
Expand Down Expand Up @@ -358,6 +362,7 @@
49E09B592AD2EE5000B56CD3 /* ContentView.swift in Sources */,
49B352C72AE53A9300BCE03D /* Frame.swift in Sources */,
49E09B572AD2EE5000B56CD3 /* MacCastApp.swift in Sources */,
495A8AB22B6478AE00520461 /* Bundle.swift in Sources */,
49E09BC52AD52CC900B56CD3 /* Remote.swift in Sources */,
495E8E3D2AD5E6C500946419 /* SerializableConformances.swift in Sources */,
49E09BB62AD4F84500B56CD3 /* Serializable.swift in Sources */,
Expand All @@ -381,6 +386,7 @@
49E09BD12AD52D9F00B56CD3 /* visionOSInterface.swift in Sources */,
494DFBD22B29111C00205CAC /* Keys.swift in Sources */,
4989D3412B0B9393005E2E7A /* shut_up_logging.c in Sources */,
495A8AB32B6478AE00520461 /* Bundle.swift in Sources */,
495E8E3B2AD5CE2400946419 /* ImageBufferView.swift in Sources */,
49E09B9B2AD3237D00B56CD3 /* ContentView.swift in Sources */,
49E09BB12AD3FDCC00B56CD3 /* ConnectionView.swift in Sources */,
Expand Down
18 changes: 18 additions & 0 deletions Shared/Bundle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Bundle.swift
// MacCast
//
// Created by Saagar Jha on 1/26/24.
//

import Foundation

extension Bundle {
var name: String {
Bundle.main.infoDictionary![kCFBundleNameKey as String] as! String
}

var version: Int {
Int(Bundle.main.infoDictionary![kCFBundleVersionKey as String] as! String)!
}
}
2 changes: 1 addition & 1 deletion Shared/Messages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

enum Messages: UInt8, CaseIterable {
static let version = Int(Bundle.main.infoDictionary![kCFBundleVersionKey as String] as! String)!
static let version = Bundle.main.version
case visionOSHandshake
case macOSHandshake
case windows
Expand Down
2 changes: 1 addition & 1 deletion macOS/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct ContentView: View {
VStack(alignment: .leading, spacing: 8) {
Text("Waiting to connect…")
.font(.title)
Text("Launch MacCast on your Apple Vision Pro and enter this pairing code when prompted.")
Text("Launch \(Bundle.main.infoDictionary![kCFBundleNameKey as String] as! String) on your Apple Vision Pro and enter this pairing code when prompted.")
}
let characters = Array(pairingCode)
HStack(spacing: 20) {
Expand Down
2 changes: 1 addition & 1 deletion visionOS/ConnectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct ConnectionView: View {
fatalError()
}
}
Text("To get started, open MacCast on your Mac and select it from the list.")
Text("To get started, open \(Bundle.main.name) on your Mac and select it from the list.")
.padding()
}
.navigationTitle("Available Macs")
Expand Down

0 comments on commit d779014

Please sign in to comment.