Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS support #4

Merged
merged 4 commits into from
Jul 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
//
// ViewController.swift
// Client.swift
// OkLog
//
// Created by diegotl on 06/30/2018.
// Copyright (c) 2018 diegotl. All rights reserved.
// Created by Diego Trevisan Lara on 12/07/18.
// Copyright © 2018 CocoaPods. All rights reserved.
//

import UIKit
import OkLog
import Alamofire

class ViewController: UIViewController {
class Client {

let session = URLSession(configuration: .default)

Expand All @@ -27,7 +26,7 @@ class ViewController: UIViewController {
return request
}

@IBAction private func logGet() {
func logGet() {

let url = URL(string: "\(Constants.urlBase)\(Constants.urlGet)")!
let request = makeRequest(url: url, method: "GET", parameters: nil)
Expand All @@ -36,22 +35,22 @@ class ViewController: UIViewController {

session.dataTask(with: request) { (data, response, error) in
OkLog.log(request: request, response: response, data: data)
}.resume()
}.resume()

}

@IBAction private func logPost() {
func logPost() {

let url = URL(string: "\(Constants.urlBase)\(Constants.urlPost)")!
let request = makeRequest(url: url, method: "POST", parameters: ["id": 1, "name": "John Johnson"])

session.dataTask(with: request) { (data, response, error) in
OkLog.log(request: request, response: response, data: data, shortenUrl: false)
}.resume()
}.resume()

}

@IBAction private func logPut() {
func logPut() {

let request = Alamofire.request("\(Constants.urlBase)\(Constants.urlPut)",
method: .put,
Expand All @@ -67,7 +66,7 @@ class ViewController: UIViewController {

}

@IBAction private func logDelete() {
func logDelete() {

let request = Alamofire.request("\(Constants.urlBase)\(Constants.urlDelete)",
method: .delete,
Expand All @@ -80,6 +79,5 @@ class ViewController: UIViewController {
}

}

}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Constants.swift
// OkLog_Example
// OkLog
//
// Created by Diego Trevisan Lara on 30/06/2018.
// Copyright © 2018 CocoaPods. All rights reserved.
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModule="OkLog_Example" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModule="OkLog_iOS" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
Expand All @@ -21,7 +21,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="bL0-A7-Ie2">
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="bL0-A7-Ie2">
<rect key="frame" x="16" y="183.5" width="343" height="300"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Mir-Nb-rof">
Expand Down Expand Up @@ -54,10 +54,7 @@
</button>
</subviews>
<constraints>
<constraint firstItem="4tk-Tn-2H5" firstAttribute="height" secondItem="Mir-Nb-rof" secondAttribute="height" id="3u4-ip-0s8"/>
<constraint firstItem="etN-LH-Mw7" firstAttribute="height" secondItem="Mir-Nb-rof" secondAttribute="height" id="E0E-BK-hh1"/>
<constraint firstAttribute="height" constant="300" id="EHi-5q-lyj"/>
<constraint firstItem="qhh-VF-DfO" firstAttribute="height" secondItem="Mir-Nb-rof" secondAttribute="height" id="z6k-Yf-PWY"/>
</constraints>
</stackView>
</subviews>
Expand Down
30 changes: 30 additions & 0 deletions Example/OkLog-iOS/ViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// ViewController.swift
// OkLog
//
// Created by diegotl on 06/30/2018.
// Copyright (c) 2018 diegotl. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

@IBAction private func logGet() {
Client().logGet()
}

@IBAction private func logPost() {
Client().logPost()
}

@IBAction private func logPut() {
Client().logPut()
}

@IBAction private func logDelete() {
Client().logDelete()
}

}

26 changes: 26 additions & 0 deletions Example/OkLog-macOS/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// AppDelegate.swift
// OkLog-macOS
//
// Created by Diego Trevisan Lara on 11/07/18.
// Copyright © 2018 CocoaPods. All rights reserved.
//

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {



func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
}

func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}


}

32 changes: 32 additions & 0 deletions Example/OkLog-macOS/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 CocoaPods. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
169 changes: 169 additions & 0 deletions Example/OkLog-macOS/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14113"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
<capability name="stacking Non-gravity area distributions on NSStackView" minToolsVersion="7.0" minSystemVersion="10.11"/>
</dependencies>
<scenes>
<!--Application-->
<scene sceneID="JPo-4y-FX3">
<objects>
<application id="hnw-xV-0zn" sceneMemberID="viewController">
<menu key="mainMenu" title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="OkLog-macOS" id="1Xt-HY-uBw">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="OkLog-macOS" systemMenu="apple" id="uQy-DD-JDr">
<items>
<menuItem title="About OkLog-macOS" id="5kV-Vb-QxS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="Ady-hI-5gd" id="Exp-CZ-Vem"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
<menuItem title="Services" id="NMo-om-nkz">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
<menuItem title="Hide OkLog-macOS" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="Ady-hI-5gd" id="PnN-Uc-m68"/>
</connections>
</menuItem>
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="hideOtherApplications:" target="Ady-hI-5gd" id="VT4-aY-XCT"/>
</connections>
</menuItem>
<menuItem title="Show All" id="Kd2-mp-pUS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="unhideAllApplications:" target="Ady-hI-5gd" id="Dhg-Le-xox"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
<menuItem title="Quit OkLog-macOS" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="Ady-hI-5gd" id="Te7-pn-YzF"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
</connections>
</application>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="OkLog_macOS" customModuleProvider="target"/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="75" y="0.0"/>
</scene>
<!--Window Controller-->
<scene sceneID="R2V-B0-nI4">
<objects>
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<connections>
<outlet property="delegate" destination="B8D-0N-5wS" id="98r-iN-zZc"/>
</connections>
</window>
<connections>
<segue destination="XfG-lQ-9wD" kind="relationship" relationship="window.shadowedContentViewController" id="cq2-FE-JQM"/>
</connections>
</windowController>
<customObject id="Oky-zY-oP4" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="75" y="250"/>
</scene>
<!--View Controller-->
<scene sceneID="hIz-AP-VOD">
<objects>
<viewController id="XfG-lQ-9wD" customClass="ViewController" customModule="OkLog_macOS" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" wantsLayer="YES" id="m2S-Jp-Qdl">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView distribution="fillEqually" orientation="vertical" alignment="centerX" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="64U-bE-dIF">
<rect key="frame" x="202" y="81" width="76" height="108"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ADj-00-TJq">
<rect key="frame" x="5" y="80" width="66" height="32"/>
<buttonCell key="cell" type="push" title="GET" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="IXv-LO-h8N">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="logGetWithSender:" target="XfG-lQ-9wD" id="MPH-XV-lq4"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="gvp-nD-sMn">
<rect key="frame" x="1" y="51" width="75" height="32"/>
<buttonCell key="cell" type="push" title="POST" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="WtO-wj-oH0">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="logPostWithSender:" target="XfG-lQ-9wD" id="eNQ-b5-e0W"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wp3-4j-47u">
<rect key="frame" x="5" y="22" width="66" height="32"/>
<buttonCell key="cell" type="push" title="PUT" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="XZJ-Yf-cKd">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="logPutWithSender:" target="XfG-lQ-9wD" id="EQE-bv-rcX"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="T2L-QA-mdr">
<rect key="frame" x="-6" y="-7" width="88" height="32"/>
<buttonCell key="cell" type="push" title="DELETE" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="C9B-bO-mfl">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="logDeleteWithSender:" target="XfG-lQ-9wD" id="97X-TA-oY2"/>
</connections>
</button>
</subviews>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
<constraints>
<constraint firstItem="64U-bE-dIF" firstAttribute="centerX" secondItem="m2S-Jp-Qdl" secondAttribute="centerX" id="3Uq-qw-bMb"/>
<constraint firstItem="64U-bE-dIF" firstAttribute="centerY" secondItem="m2S-Jp-Qdl" secondAttribute="centerY" id="b4u-7O-zcH"/>
</constraints>
</view>
</viewController>
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="75" y="655"/>
</scene>
</scenes>
</document>
Loading