Skip to content

Commit

Permalink
Swiftlint: also set up SamplePlayer linting
Browse files Browse the repository at this point in the history
  • Loading branch information
sitomani committed Oct 7, 2023
1 parent 7db4233 commit 7e3e7a9
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ Cartfile.resolved
.DS_Store
fastlane/report.xml
xcuserdata
xcshareddata
*.ipa
*.dSYM.zip
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
included: # paths to include during linting. `--path` is ignored if present.
- 4champ
- SamplePlayer
excluded: # paths to ignore during linting. Takes precedence over `included`.
disabled_rules:
- type_body_length
Expand Down
3 changes: 2 additions & 1 deletion 4champ.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -635,6 +635,7 @@
/* Begin PBXShellScriptBuildPhase section */
73CD16E12AD16C3400987AD6 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down
29 changes: 26 additions & 3 deletions SamplePlayer/SamplePlayer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -169,6 +169,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 45C005C3208B7B1800126E78 /* Build configuration list for PBXNativeTarget "SamplePlayer" */;
buildPhases = (
73CD16E22AD170C800987AD6 /* ShellScript */,
45C005AD208B7B1800126E78 /* Sources */,
45C005AE208B7B1800126E78 /* Frameworks */,
45C005AF208B7B1800126E78 /* Resources */,
Expand All @@ -195,6 +196,7 @@
TargetAttributes = {
45C005B0208B7B1800126E78 = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = "";
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -231,6 +233,27 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
73CD16E22AD170C800987AD6 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\n\nif which swiftlint; then\n swiftlint —-fix --format\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
45C005AD208B7B1800126E78 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -402,7 +425,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "SamplePlayer/SamplePlayer-bridging-header.h";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -433,7 +456,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "SamplePlayer/SamplePlayer-bridging-header.h";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
13 changes: 2 additions & 11 deletions SamplePlayer/SamplePlayer/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

52 changes: 31 additions & 21 deletions SamplePlayer/SamplePlayer/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,37 @@
import UIKit

class ViewController: UIViewController {

@IBOutlet weak var modLabel: UILabel!
@IBOutlet weak var modStack: UIStackView!
@IBOutlet weak var viewTitle: UILabel!
private let modulesUrl: URL
private let modulePaths: [String]

private var modulesUrl: URL?
private var modulePaths: [String] = []

let replay = Replay()

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
modulesUrl = Bundle.main.url(forResource: "Modules", withExtension: "bundle")!
modulePaths = try! FileManager.default.contentsOfDirectory(atPath: modulesUrl.path)
if let url = Bundle.main.url(forResource: "Modules", withExtension: "bundle") {
modulesUrl = url
do {
modulePaths = try FileManager.default.contentsOfDirectory(atPath: url.path)
} catch {
print(error)
}
}
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}

required init?(coder: NSCoder) {
modulesUrl = Bundle.main.url(forResource: "Modules", withExtension: "bundle")!
modulePaths = try! FileManager.default.contentsOfDirectory(atPath: modulesUrl.path)
if let url = Bundle.main.url(forResource: "Modules", withExtension: "bundle") {
modulesUrl = url
do {
modulePaths = try FileManager.default.contentsOfDirectory(atPath: url.path)
} catch {
print(error)
}
}
super.init(coder: coder)
}

Expand All @@ -36,42 +48,41 @@ class ViewController: UIViewController {
viewTitle.textColor = .black

}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
replay.initAudio()

modStack.spacing = 8.0
modStack.distribution = .fillEqually

let bundle = Bundle.main //init(identifier: "lib.uade.ios")
let bundle = Bundle.main // init(identifier: "lib.uade.ios")
viewTitle.text = bundle.resourcePath ?? ""
// NSString *bd = [uadeBundle pathForResource:@"UADERes" ofType:@"bundle"];


// Add module buttons
modulePaths.forEach { path in
let btn = UIButton()
btn.backgroundColor = UIColor.init(red: 0, green: 0x42/255, blue: 0x47/255, alpha: 1)
let ext = path.split(separator: ".").last
btn.setTitle(String(ext ?? "n/a").uppercased() , for: .normal)
btn.setTitle(String(ext ?? "n/a").uppercased(), for: .normal)
btn.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
modStack.addArrangedSubview(btn)
}

}

@IBAction func buttonTapped(_ sender: UIButton) {
if let btn = sender.titleLabel?.text {
switch btn {
case "STOP":
modLabel.text = "no module selected"
replay.stop()
default:
if let mod = modulePaths.first(where: { path in
if let rootUrl = modulesUrl, let mod = modulePaths.first(where: { path in
path.uppercased().hasSuffix(btn)
}) {
let fullpath = "\(modulesUrl.path)/\(mod)"
let fullpath = "\(rootUrl.path)/\(mod)"
modLabel.text = String(mod.split(separator: "/").last ?? "")
replay.loadModule(fullpath, type: btn)
replay.play()
Expand All @@ -80,4 +91,3 @@ class ViewController: UIViewController {
}
}
}

0 comments on commit 7e3e7a9

Please sign in to comment.