Skip to content

Commit

Permalink
Merge pull request #70 from orchetect/dev
Browse files Browse the repository at this point in the history
Cleanup and MIDIEventLogger example project update
  • Loading branch information
orchetect authored Jan 25, 2022
2 parents b0943bf + 3a875a5 commit 92b8d16
Show file tree
Hide file tree
Showing 7 changed files with 759 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
E26A25C926C5875A00FFCF40 /* OTCore in Frameworks */ = {isa = PBXBuildFile; productRef = E26A25C826C5875A00FFCF40 /* OTCore */; };
E26A25CD26C5876400FFCF40 /* MIDIKit in Frameworks */ = {isa = PBXBuildFile; productRef = E26A25CC26C5876400FFCF40 /* MIDIKit */; };
E26A25CF26C5AD4700FFCF40 /* ContentView SubViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = E26A25CE26C5AD4700FFCF40 /* ContentView SubViews.swift */; };
E2E8BD89279F8DF4007A1AF0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2E8BD88279F8DF3007A1AF0 /* Main.storyboard */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -24,6 +25,7 @@
E26A25CA26C5875F00FFCF40 /* MIDIKit */ = {isa = PBXFileReference; lastKnownFileType = folder; name = MIDIKit; path = ../..; sourceTree = "<group>"; };
E26A25CE26C5AD4700FFCF40 /* ContentView SubViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ContentView SubViews.swift"; sourceTree = "<group>"; };
E2B38F2026C63918008770A6 /* MIDIEventLogger.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MIDIEventLogger.entitlements; sourceTree = "<group>"; };
E2E8BD88279F8DF3007A1AF0 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -64,6 +66,7 @@
E26A25CE26C5AD4700FFCF40 /* ContentView SubViews.swift */,
E26A25BF26C5873B00FFCF40 /* Log.swift */,
E216886026C5E5A400BF7959 /* Info.plist */,
E2E8BD88279F8DF3007A1AF0 /* Main.storyboard */,
E2B38F2026C63918008770A6 /* MIDIEventLogger.entitlements */,
);
path = MIDIEventLogger;
Expand Down Expand Up @@ -135,6 +138,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E2E8BD89279F8DF4007A1AF0 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -206,7 +210,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -261,7 +265,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand All @@ -287,7 +291,6 @@
INFOPLIST_FILE = MIDIEventLogger/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INFOPLIST_KEY_NSMainStoryboardFile = MIDIEventLogger;
INFOPLIST_KEY_NSPrincipalClass = NSApplication;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -319,7 +322,6 @@
INFOPLIST_FILE = MIDIEventLogger/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INFOPLIST_KEY_NSMainStoryboardFile = MIDIEventLogger;
INFOPLIST_KEY_NSPrincipalClass = NSApplication;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
28 changes: 21 additions & 7 deletions Examples/MIDIEventLogger/MIDIEventLogger/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import OTCore
import MIDIKit

@main
struct MIDIEventLogger: App {
class AppDelegate: NSObject, NSApplicationDelegate {

var midiManager: MIDI.IO.Manager = {
let newManager =
Expand All @@ -23,16 +23,30 @@ struct MIDIEventLogger: App {
logger.default(error)
}

// #warning("> TODO: remove this")
// newManager.preferredAPI = .legacyCoreMIDI

return newManager
}()

var body: some Scene {

WindowGroup {
ContentView()
.environmentObject(midiManager)
}
var window: NSWindow!


func applicationDidFinishLaunching(_ aNotification: Notification) {
// Create the SwiftUI view that provides the window contents.
let contentView = ContentView()
.environmentObject(midiManager)

// Create the window and set the content view.
window = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
backing: .buffered, defer: false)
window.isReleasedWhenClosed = false
window.center()
window.setFrameAutosaveName("Main Window")
window.contentView = NSHostingView(rootView: contentView)
window.makeKeyAndOrderFront(nil)
}

}
16 changes: 12 additions & 4 deletions Examples/MIDIEventLogger/MIDIEventLogger/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,18 @@ struct ContentView: View {
}
}

.onChange(of: midiInputConnectionEndpoint) { _ in
updateInputConnection()
}

// MARK: TODO: this works but only on macOS 11 and later
//.onChange(of: midiInputConnectionEndpoint) { _ in
// updateInputConnection()
//}
// MARK: TODO: instead, we need a hack to update when the @State var changes:
ZStack {
Text({
let dummy = midiInputConnectionEndpoint?.name ?? ""
updateInputConnection()
return "\(dummy)"
}())
}.frame(width: 0, height: 0)
}

// MARK: - Helper Methods
Expand Down
20 changes: 20 additions & 0 deletions Examples/MIDIEventLogger/MIDIEventLogger/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,29 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
Loading

0 comments on commit 92b8d16

Please sign in to comment.