Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
akiroz committed May 8, 2018
1 parent 8506354 commit e069e9d
Show file tree
Hide file tree
Showing 10 changed files with 385 additions and 51 deletions.
68 changes: 68 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: objective-c
osx_image: xcode9.3
env:
global:
- PROJECT=Excitation.xcodeproj
- SCHEME=Excitation
- SDK=iphonesimulator
- DEST="OS=11.3,name=iPhone 8"
- CONFIG=Release
script:
- set -o pipefail
- open -b com.apple.iphonesimulator # Workaround https://github.com/travis-ci/travis-ci/issues/3040
- xcodebuild test -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DEST" -configuration "$CONFIG" ENABLE_TESTABILITY=YES | xcpretty
24 changes: 16 additions & 8 deletions Excitation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* Begin PBXBuildFile section */
A13212AA20A2344B001AE0D1 /* Excitation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A13212A020A2344B001AE0D1 /* Excitation.framework */; };
A13212AF20A2344B001AE0D1 /* ExcitationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A13212AE20A2344B001AE0D1 /* ExcitationTests.swift */; };
A13212B120A2344B001AE0D1 /* Excitation.h in Headers */ = {isa = PBXBuildFile; fileRef = A13212A320A2344B001AE0D1 /* Excitation.h */; settings = {ATTRIBUTES = (Public, ); }; };
A13212BB20A23474001AE0D1 /* Excitation.swift in Sources */ = {isa = PBXBuildFile; fileRef = A13212BA20A23474001AE0D1 /* Excitation.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -24,11 +24,11 @@

/* Begin PBXFileReference section */
A13212A020A2344B001AE0D1 /* Excitation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Excitation.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A13212A320A2344B001AE0D1 /* Excitation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Excitation.h; sourceTree = "<group>"; };
A13212A420A2344B001AE0D1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A13212A920A2344B001AE0D1 /* ExcitationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExcitationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
A13212AE20A2344B001AE0D1 /* ExcitationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExcitationTests.swift; sourceTree = "<group>"; };
A13212B020A2344B001AE0D1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A13212BA20A23474001AE0D1 /* Excitation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Excitation.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -71,8 +71,8 @@
A13212A220A2344B001AE0D1 /* Excitation */ = {
isa = PBXGroup;
children = (
A13212A320A2344B001AE0D1 /* Excitation.h */,
A13212A420A2344B001AE0D1 /* Info.plist */,
A13212BA20A23474001AE0D1 /* Excitation.swift */,
);
path = Excitation;
sourceTree = "<group>";
Expand All @@ -93,7 +93,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
A13212B120A2344B001AE0D1 /* Excitation.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -148,6 +147,7 @@
TargetAttributes = {
A132129F20A2344B001AE0D1 = {
CreatedOnToolsVersion = 9.3;
LastSwiftMigration = 0930;
};
A13212A820A2344B001AE0D1 = {
CreatedOnToolsVersion = 9.3;
Expand Down Expand Up @@ -194,6 +194,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A13212BB20A23474001AE0D1 /* Excitation.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -339,10 +340,11 @@
A13212B520A2344B001AE0D1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 24DV2L94B2;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -355,7 +357,9 @@
);
PRODUCT_BUNDLE_IDENTIFIER = akiroz.Excitation;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -364,10 +368,11 @@
A13212B620A2344B001AE0D1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 24DV2L94B2;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -380,6 +385,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = akiroz.Excitation;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -389,6 +395,7 @@
A13212B820A2344B001AE0D1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 24DV2L94B2;
INFOPLIST_FILE = ExcitationTests/Info.plist;
Expand All @@ -407,6 +414,7 @@
A13212B920A2344B001AE0D1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 24DV2L94B2;
INFOPLIST_FILE = ExcitationTests/Info.plist;
Expand Down
99 changes: 99 additions & 0 deletions Excitation.xcodeproj/xcshareddata/xcschemes/Excitation.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A132129F20A2344B001AE0D1"
BuildableName = "Excitation.framework"
BlueprintName = "Excitation"
ReferencedContainer = "container:Excitation.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A13212A820A2344B001AE0D1"
BuildableName = "ExcitationTests.xctest"
BlueprintName = "ExcitationTests"
ReferencedContainer = "container:Excitation.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A132129F20A2344B001AE0D1"
BuildableName = "Excitation.framework"
BlueprintName = "Excitation"
ReferencedContainer = "container:Excitation.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A132129F20A2344B001AE0D1"
BuildableName = "Excitation.framework"
BlueprintName = "Excitation"
ReferencedContainer = "container:Excitation.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A132129F20A2344B001AE0D1"
BuildableName = "Excitation.framework"
BlueprintName = "Excitation"
ReferencedContainer = "container:Excitation.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>Excitation.xcscheme</key>
<key>Excitation.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
Expand Down
19 changes: 0 additions & 19 deletions Excitation/Excitation.h

This file was deleted.

61 changes: 61 additions & 0 deletions Excitation/Excitation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import Foundation

// Swift type inference bug workaround
// ====================================================
// As of Swift 4.1 the compiler cannot differenciate between:
// (T) -> Void where T is Void and Void -> Void.
//
// In the case where we need to create an Event that does not
// carry data, use Emitter<None>()
//
public enum None {
case None
}

public class Observer<T> {
var f: ((T)->Void)?
init(_ f: @escaping (T)->Void) {
self.f = f
}

@objc func invoke(n: Notification) {
if let payload = n.userInfo {
f!(payload[0]! as! T)
} else if self is Observer<None> {
f!(None.None as! T)
} else {
let t = type(of: T.self)
print("Excitation: Unexpected event from Emitter<\(t)> with no data.")
}
}
}

public class Emitter<T> {
let nc = NotificationCenter()
let nn = Notification.Name("ExcitationEvent")
var obRef = [ObjectIdentifier: Observer<T>]()

public func emit() {
nc.post(name: nn, object: nil)
}
public func emit(_ data: T) {
nc.post(name: nn, object: nil, userInfo: [0: data])
}

public func observe(_ f: @escaping ()->Void) -> Observer<T> {
return self.observe({ (_: T) in f() })
}
public func observe(_ f: @escaping (T)->Void) -> Observer<T> {
let ob = Observer<T>(f)
nc.addObserver(
ob, selector: #selector(ob.invoke(n:)),
name: nn, object: nil)
obRef[ObjectIdentifier(ob)] = ob
return ob
}

public func remove(_ ob: Observer<T>) {
nc.removeObserver(ob, name: nn, object: nil)
obRef.removeValue(forKey: ObjectIdentifier(ob))
}
}
Loading

0 comments on commit e069e9d

Please sign in to comment.