Skip to content

Instantly share code, notes, and snippets.

View pepicrft's full-sized avatar
🌱
Open-sourcing

Pedro Piñera Buendía pepicrft

🌱
Open-sourcing
View GitHub Profile
// Home.swift in uHome
import UIKit
import uCore
public class Home {
let client: Client
public init(client: Client) {
self.client = client
}
public func makeViewController(delegate: HomeDelegate) -> UIViewController {
// AppDelegate.swift
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationDidBecomeActive(_ application: UIApplication) {
Services.playback.restoreState()
}
}
// Services.swift in the main application
import uCore
import uPlayback
class Services {
static let playback = PlaybackService() // From uPlayback
static let client = Client(baseUrl: "https://api.shakira.io") // From uCore
static let analytics = Analytics(firebaseKey: "xxx") // From uCore
}
xctools build-settings export --project MyProject.xcodeproj --output MyProject.xcconfig
xctools build-settings export --project MyProject.xcodeproj --target --output Target.xcconfig
// It can merge the project and target settings into a single .xcconfig file
xctools build-settings export --project MyProject.xcodeproj --target --output Target.xcconfig --merge
xctools build-settings clean --project MyProject.xcodeproj
xctools build-settings clean --project MyProject.xcodeproj --target MyTarget
// Read a project
let project = try! XcodeProj(path: "myproject.xcodeproj")
let buildFiles = project.pbxproj.objects.buildFiles
let buildConfigurations = project.pbxproj.objects.buildConfigurations
// Read a workspace
let workspace = try! XCWorkspace(path: "myworkspace.workspace")
let projects = workspace.data.references.map { $0.project }
// Read a config file
https://github.com/carambalabs/xcodeproj.git
let package = Package(
name: "myproject",
dependencies: [
.Package(url: "https://github.com/carambalabs/xcodeproj.git", majorVersion: 0, minor: 0)
]
)
#!/usr/bin/swift
import Foundation
print("Ensuring Swift-Package-Manager compatibility")
let fileManager = FileManager.default
let currentPath = fileManager.currentDirectoryPath
let podURL = URL(fileURLWithPath: currentPath).appendingPathComponent("${POD_NAME}/Classes")
print("Pod path: \(podURL.path)")
let provider = SoundCloudProvider(clientId: "xxx", clientSecret: "yyy", redirectUri: "test://test")
let webview = OAuth2WebView(frame: self.view.frame, provider: provider) { (session, error)
if let session = session {
print("User access token: \(session.accessToken)")
} else if let error = error {
print("Something went wrong during the authentication: \(error)")
}
}