Skip to content

Instantly share code, notes, and snippets.

View artemnovichkov's full-sized avatar
👨‍💻
Write code. Blow minds.

Artem Novichkov artemnovichkov

👨‍💻
Write code. Blow minds.
View GitHub Profile
@artemnovichkov
artemnovichkov / test.yml
Created August 27, 2019 12:14
Github Actions configuration for Texstyle https://github.com/rosberry/texstyle
on: pull_request
name: Test
jobs:
test:
name: Test
runs-on: macOS-latest
strategy:
matrix:
destination: ['platform=iOS Simulator,OS=12.2,name=iPhone X', 'platform=tvOS Simulator,OS=12.2,name=Apple TV 4K']
steps:
@artemnovichkov
artemnovichkov / travis.yml
Last active August 27, 2019 07:13
Travis CI configuration from Texstyle https://github.com/rosberry/texstyle
language: swift
osx_image: xcode10.2
env:
matrix:
- DESTINATION="platform=iOS Simulator,OS=12.2,name=iPhone X"
- DESTINATION="platform=tvOS Simulator,OS=12.2,name=Apple TV 4K"
before_script: cd Texstyle
// Create an interator class
class ElementIterator<T>: IteratorProtocol {
typealias Element = T
let element: T
init(element: T) {
self.element = element
}
import Foundation
extension URL {
/// Returns an url for App Store app.
///
/// Example: [itms-apps://itunes.apple.com/app/id1434568484?action=write-review]()
///
/// - Parameters:
/// - id: The id of the app.
struct User {
let username: String
}
final class user Service {
static let shared = Service()
var user: User?
}
@artemnovichkov
artemnovichkov / file_sharing.swift
Last active September 13, 2022 14:20
Explore Documents folder in Files.app. Inspired by Ole's tweet https://twitter.com/olebegemann/status/987346188591681536
#!/usr/bin/env xcrun --sdk macosx swift
import Foundation
enum Configuration: String {
case debug = "Debug"
case release = "Release"
}
// Get Info.plist path
import Foundation
// Get project URL
guard let projectDirRawValue = getenv("PROJECT_DIR"),
let projectDirectoryPath = String(utf8String: projectDirRawValue) else {
exit(1)
}
let projectURL = URL(fileURLWithPath: projectDirectoryPath)
// Get Info.plist path
guard let productSettingsPathRawValue = getenv("PRODUCT_SETTINGS_PATH"),
guard let productSettings = NSDictionary(contentsOfFile: productSettingsPath) else {
exit(1)
}
for key in keys {
guard let value = productSettings[key] as? String else {
// Missing key
exit(1)
}
if value.isEmpty {
// Empty description
var keys: [String] = []
for url in swiftFileURLs {
let contents = try String(contentsOf: url, encoding: .utf8)
for (pattern, key) in patterns {
if contents.contains(pattern) {
keys.append(key)
}
}
}
guard let enumerator = FileManager.default.enumerator(at: projectURL, includingPropertiesForKeys: nil) else {
exit(1)
}
var swiftFileURLs = enumerator.allObjects
.compactMap { $0 as? URL }
.filter { $0.pathExtension == "swift" }