get Users up

This commit is contained in:
Gerrit Linnemann 2015-09-13 23:37:18 +02:00
parent baba7de448
commit 79628c8824
56 changed files with 4513 additions and 36 deletions

6
ipbc-Client/Podfile Normal file
View File

@ -0,0 +1,6 @@
platform :osx, '10.9'
workspace 'ipbc-Client'
use_frameworks!
pod 'SwiftHTTP', '~> 0.9.4'
pod 'ReachabilitySwift', git: 'https://github.com/ashleymills/Reachability.swift'

22
ipbc-Client/Podfile.lock Normal file
View File

@ -0,0 +1,22 @@
PODS:
- ReachabilitySwift (1.1)
- SwiftHTTP (0.9.5)
DEPENDENCIES:
- ReachabilitySwift (from `https://github.com/ashleymills/Reachability.swift`)
- SwiftHTTP (~> 0.9.4)
EXTERNAL SOURCES:
ReachabilitySwift:
:git: https://github.com/ashleymills/Reachability.swift
CHECKOUT OPTIONS:
ReachabilitySwift:
:commit: eca2517c69b321e9c4ce464be45c33f3a8dfe14e
:git: https://github.com/ashleymills/Reachability.swift
SPEC CHECKSUMS:
ReachabilitySwift: 1e53abddb01111deac0d229dabdb8bb043567b18
SwiftHTTP: cd7b248bc07db02926ff54cf19b580b78f7abfa1
COCOAPODS: 0.38.2

View File

@ -0,0 +1,23 @@
{
"name": "ReachabilitySwift",
"version": "1.1",
"homepage": "https://github.com/ashleymills/Reachability.swift",
"authors": {
"Ashley Mills": "ashleymills@mac.com"
},
"summary": "Replacement for Apple's Reachability re-written in Swift with callbacks.",
"license": {
"type": "MIT"
},
"platforms": {
"ios": "8.0",
"osx": "10.9"
},
"source": {
"git": "https://github.com/ashleymills/Reachability.swift.git",
"tag": "v1.1"
},
"source_files": "Reachability.swift",
"frameworks": "SystemConfiguration",
"requires_arc": true
}

22
ipbc-Client/Pods/Manifest.lock generated Normal file
View File

@ -0,0 +1,22 @@
PODS:
- ReachabilitySwift (1.1)
- SwiftHTTP (0.9.5)
DEPENDENCIES:
- ReachabilitySwift (from `https://github.com/ashleymills/Reachability.swift`)
- SwiftHTTP (~> 0.9.4)
EXTERNAL SOURCES:
ReachabilitySwift:
:git: https://github.com/ashleymills/Reachability.swift
CHECKOUT OPTIONS:
ReachabilitySwift:
:commit: eca2517c69b321e9c4ce464be45c33f3a8dfe14e
:git: https://github.com/ashleymills/Reachability.swift
SPEC CHECKSUMS:
ReachabilitySwift: 1e53abddb01111deac0d229dabdb8bb043567b18
SwiftHTTP: cd7b248bc07db02926ff54cf19b580b78f7abfa1
COCOAPODS: 0.38.2

View File

@ -0,0 +1,685 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
01259B29E7B75268A2E4639449AE759B /* HTTPRequestSerializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F691D8FF9BB3BC94F769A03D7BF6E9 /* HTTPRequestSerializer.swift */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
0349D3641FA40BDE258EBB89DAB0CE56 /* Pods-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 32E45C833AF7E16855BBB75F3725A934 /* Pods-dummy.m */; };
0FBBF858C750BD72A6B9D05357699EAE /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F92D703483EAB54823ABF39B5C024CEC /* Cocoa.framework */; };
2EADFA6A6D8F80BF28466A3207F1880F /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DB25E462135DFC183C89E6E66E596FD /* SystemConfiguration.framework */; };
4CB56104486E20F3D1A8F0F048473FD5 /* HTTPSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57F10E5E0800AB435D50B75E004F0E5E /* HTTPSecurity.swift */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
50CB3873CE44B09068C6650F7BC1B62E /* ReachabilitySwift-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 40BA696D0257C0C38DB22F4F7C0B3024 /* ReachabilitySwift-dummy.m */; };
588B0C8E4C2F7849023F60069A7AF094 /* HTTPTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = D15F651F060B286D433A13109B37091C /* HTTPTask.swift */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
5C601DFC35BD0AA393A1C6B29E45B133 /* HTTPUpload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EF017F3903CAB51D4BF613B96370A46 /* HTTPUpload.swift */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
69079EC9A7A8AB065AD21904666AACEC /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F92D703483EAB54823ABF39B5C024CEC /* Cocoa.framework */; };
6E0B32BB9D7E10891D49EF9D239B20D8 /* ReachabilitySwift-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 42443BE4CFDB3686DCE7BD49A7251FBD /* ReachabilitySwift-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
719D747C7DAF00843C07D2368BD9BB8F /* Pods-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B4DE76AFBBDE97856185D579F920FFA /* Pods-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
723C10D67F21BFB2AE43FCE47E18A921 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F92D703483EAB54823ABF39B5C024CEC /* Cocoa.framework */; };
7EACDBE6B531B186A1ECDF5838A92549 /* SwiftHTTP-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = F67503E72BAEAD05D13DF670F7D88CCD /* SwiftHTTP-dummy.m */; };
82FEFB5F8E2CE9FF43EDE67D41F774D6 /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C1C786CCECAB03DBBA6174C79837A10 /* Reachability.swift */; };
C9D551E664541B6D44F0DDDBC094DE22 /* SwiftHTTP-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E80ACD8021743B20121DDA0D7F457 /* SwiftHTTP-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
F556360A6CF9AD4B39927790324A61AA /* HTTPResponseSerializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C533A7E04B2700CB774CD9B10CC75014 /* HTTPResponseSerializer.swift */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
039A210DD9F51E9946D160F7EEDCCA0B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
proxyType = 1;
remoteGlobalIDString = 0C66C30381F86C3D642FC983CCADEBB6;
remoteInfo = ReachabilitySwift;
};
EC3ED57D07B7D0FB9BC30494E35FFDB9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
proxyType = 1;
remoteGlobalIDString = AB33B84630B10DE253DA6B29E233F61D;
remoteInfo = SwiftHTTP;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
095D927AF11FDF42492621C1C67329C0 /* SwiftHTTP.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = SwiftHTTP.xcconfig; sourceTree = "<group>"; };
097C0D457717655774F1C6B4482469C1 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; };
0EF017F3903CAB51D4BF613B96370A46 /* HTTPUpload.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = HTTPUpload.swift; sourceTree = "<group>"; };
0FF578386D2320C3DA2C2060D0EBD622 /* ReachabilitySwift.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = ReachabilitySwift.modulemap; sourceTree = "<group>"; };
15348E9E02C583262BCE9E2DF83BB390 /* SwiftHTTP-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SwiftHTTP-prefix.pch"; sourceTree = "<group>"; };
1AFB0CBFBAAD243441BFBACC7D2D8DFE /* SwiftHTTP.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftHTTP.framework; sourceTree = BUILT_PRODUCTS_DIR; };
32E45C833AF7E16855BBB75F3725A934 /* Pods-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-dummy.m"; sourceTree = "<group>"; };
3E9E80ACD8021743B20121DDA0D7F457 /* SwiftHTTP-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SwiftHTTP-umbrella.h"; sourceTree = "<group>"; };
4057D82490BD357705895A1E889818DC /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Pods.debug.xcconfig; sourceTree = "<group>"; };
40BA696D0257C0C38DB22F4F7C0B3024 /* ReachabilitySwift-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "ReachabilitySwift-dummy.m"; sourceTree = "<group>"; };
42443BE4CFDB3686DCE7BD49A7251FBD /* ReachabilitySwift-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "ReachabilitySwift-umbrella.h"; sourceTree = "<group>"; };
4C1C786CCECAB03DBBA6174C79837A10 /* Reachability.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Reachability.swift; sourceTree = "<group>"; };
4DB25E462135DFC183C89E6E66E596FD /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; };
57F10E5E0800AB435D50B75E004F0E5E /* HTTPSecurity.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = HTTPSecurity.swift; sourceTree = "<group>"; };
62384151EBD793096A1AAF3E92D94B8D /* ReachabilitySwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ReachabilitySwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
649885E5C778C58AB64D51F0C20CED29 /* SwiftHTTP-Private.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "SwiftHTTP-Private.xcconfig"; sourceTree = "<group>"; };
79A9DEDC89FE8336BF5FEDAAF75BF7FC /* Pods.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = Pods.modulemap; sourceTree = "<group>"; };
7B4DE76AFBBDE97856185D579F920FFA /* Pods-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-umbrella.h"; sourceTree = "<group>"; };
801610C316E9613869C090D4FB50D508 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
87B213035BAC5F75386F62D3C75D2342 /* Pods-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-acknowledgements.plist"; sourceTree = "<group>"; };
A951EEB50E667EEF07D87DD479DA9433 /* ReachabilitySwift-Private.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "ReachabilitySwift-Private.xcconfig"; sourceTree = "<group>"; };
AD3DFA8DA99A0DD784441E8ACE3379F9 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Pods.release.xcconfig; sourceTree = "<group>"; };
B278AD891AF3B8F6DC8F36A5A6C29417 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B8F691D8FF9BB3BC94F769A03D7BF6E9 /* HTTPRequestSerializer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = HTTPRequestSerializer.swift; sourceTree = "<group>"; };
BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
C533A7E04B2700CB774CD9B10CC75014 /* HTTPResponseSerializer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = HTTPResponseSerializer.swift; sourceTree = "<group>"; };
CBC0F7C552B739C909B650A0F42F7F38 /* Pods-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-resources.sh"; sourceTree = "<group>"; };
CDDCD49DDDF6C0B9F82260F1AF13A942 /* ReachabilitySwift.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = ReachabilitySwift.xcconfig; sourceTree = "<group>"; };
D0405803033A2A777B8E4DFA0C1800ED /* Pods-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-acknowledgements.markdown"; sourceTree = "<group>"; };
D15F651F060B286D433A13109B37091C /* HTTPTask.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = HTTPTask.swift; sourceTree = "<group>"; };
D9B9FD9DAD14DAAC21B5423D800BBD0C /* SwiftHTTP.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = SwiftHTTP.modulemap; sourceTree = "<group>"; };
E7F21354943D9F42A70697D5A5EF72E9 /* Pods-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-frameworks.sh"; sourceTree = "<group>"; };
E8446514FBAD26C0E18F24A5715AEF67 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
EB4AF5086CB3AC13E75C2E1F7D39F72E /* ReachabilitySwift-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "ReachabilitySwift-prefix.pch"; sourceTree = "<group>"; };
F67503E72BAEAD05D13DF670F7D88CCD /* SwiftHTTP-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SwiftHTTP-dummy.m"; sourceTree = "<group>"; };
F92D703483EAB54823ABF39B5C024CEC /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
10CE6206C906127554A7B0BF49A457CC /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
0FBBF858C750BD72A6B9D05357699EAE /* Cocoa.framework in Frameworks */,
2EADFA6A6D8F80BF28466A3207F1880F /* SystemConfiguration.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
3B6CEF09D80635B1C1A67720265E1C26 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
723C10D67F21BFB2AE43FCE47E18A921 /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
E7AF66B94C382A3D9361923B020E023F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
69079EC9A7A8AB065AD21904666AACEC /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
4D8D4937101166A85BFF2FBAF40F5516 /* ReachabilitySwift */ = {
isa = PBXGroup;
children = (
4C1C786CCECAB03DBBA6174C79837A10 /* Reachability.swift */,
D8FEE5B31C6CE8B956341F5F06BC1F02 /* Support Files */,
);
path = ReachabilitySwift;
sourceTree = "<group>";
};
75D98FF52E597A11900E131B6C4E1ADA /* Pods */ = {
isa = PBXGroup;
children = (
E8446514FBAD26C0E18F24A5715AEF67 /* Info.plist */,
79A9DEDC89FE8336BF5FEDAAF75BF7FC /* Pods.modulemap */,
D0405803033A2A777B8E4DFA0C1800ED /* Pods-acknowledgements.markdown */,
87B213035BAC5F75386F62D3C75D2342 /* Pods-acknowledgements.plist */,
32E45C833AF7E16855BBB75F3725A934 /* Pods-dummy.m */,
E7F21354943D9F42A70697D5A5EF72E9 /* Pods-frameworks.sh */,
CBC0F7C552B739C909B650A0F42F7F38 /* Pods-resources.sh */,
7B4DE76AFBBDE97856185D579F920FFA /* Pods-umbrella.h */,
4057D82490BD357705895A1E889818DC /* Pods.debug.xcconfig */,
AD3DFA8DA99A0DD784441E8ACE3379F9 /* Pods.release.xcconfig */,
);
name = Pods;
path = "Target Support Files/Pods";
sourceTree = "<group>";
};
7DB346D0F39D3F0E887471402A8071AB = {
isa = PBXGroup;
children = (
BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */,
D648CE86F139C7CCFD55D5B8A03BE74B /* Frameworks */,
F0DC4F36A15704389A9297F3020BED99 /* Pods */,
CCA510CFBEA2D207524CDA0D73C3B561 /* Products */,
B7B80995527643776607AFFA75B91E24 /* Targets Support Files */,
);
sourceTree = "<group>";
};
8480DBE9F2782F5C8217930EA726C666 /* SwiftHTTP */ = {
isa = PBXGroup;
children = (
B8F691D8FF9BB3BC94F769A03D7BF6E9 /* HTTPRequestSerializer.swift */,
C533A7E04B2700CB774CD9B10CC75014 /* HTTPResponseSerializer.swift */,
57F10E5E0800AB435D50B75E004F0E5E /* HTTPSecurity.swift */,
D15F651F060B286D433A13109B37091C /* HTTPTask.swift */,
0EF017F3903CAB51D4BF613B96370A46 /* HTTPUpload.swift */,
E5F5A69C46B7C6FB4C778FE647A05890 /* Support Files */,
);
path = SwiftHTTP;
sourceTree = "<group>";
};
B7B80995527643776607AFFA75B91E24 /* Targets Support Files */ = {
isa = PBXGroup;
children = (
75D98FF52E597A11900E131B6C4E1ADA /* Pods */,
);
name = "Targets Support Files";
sourceTree = "<group>";
};
CCA510CFBEA2D207524CDA0D73C3B561 /* Products */ = {
isa = PBXGroup;
children = (
097C0D457717655774F1C6B4482469C1 /* Pods.framework */,
62384151EBD793096A1AAF3E92D94B8D /* ReachabilitySwift.framework */,
1AFB0CBFBAAD243441BFBACC7D2D8DFE /* SwiftHTTP.framework */,
);
name = Products;
sourceTree = "<group>";
};
D344DDEA45FAAA6C5B5B81CB2C028D16 /* OS X */ = {
isa = PBXGroup;
children = (
F92D703483EAB54823ABF39B5C024CEC /* Cocoa.framework */,
4DB25E462135DFC183C89E6E66E596FD /* SystemConfiguration.framework */,
);
name = "OS X";
sourceTree = "<group>";
};
D648CE86F139C7CCFD55D5B8A03BE74B /* Frameworks */ = {
isa = PBXGroup;
children = (
D344DDEA45FAAA6C5B5B81CB2C028D16 /* OS X */,
);
name = Frameworks;
sourceTree = "<group>";
};
D8FEE5B31C6CE8B956341F5F06BC1F02 /* Support Files */ = {
isa = PBXGroup;
children = (
801610C316E9613869C090D4FB50D508 /* Info.plist */,
0FF578386D2320C3DA2C2060D0EBD622 /* ReachabilitySwift.modulemap */,
CDDCD49DDDF6C0B9F82260F1AF13A942 /* ReachabilitySwift.xcconfig */,
A951EEB50E667EEF07D87DD479DA9433 /* ReachabilitySwift-Private.xcconfig */,
40BA696D0257C0C38DB22F4F7C0B3024 /* ReachabilitySwift-dummy.m */,
EB4AF5086CB3AC13E75C2E1F7D39F72E /* ReachabilitySwift-prefix.pch */,
42443BE4CFDB3686DCE7BD49A7251FBD /* ReachabilitySwift-umbrella.h */,
);
name = "Support Files";
path = "../Target Support Files/ReachabilitySwift";
sourceTree = "<group>";
};
E5F5A69C46B7C6FB4C778FE647A05890 /* Support Files */ = {
isa = PBXGroup;
children = (
B278AD891AF3B8F6DC8F36A5A6C29417 /* Info.plist */,
D9B9FD9DAD14DAAC21B5423D800BBD0C /* SwiftHTTP.modulemap */,
095D927AF11FDF42492621C1C67329C0 /* SwiftHTTP.xcconfig */,
649885E5C778C58AB64D51F0C20CED29 /* SwiftHTTP-Private.xcconfig */,
F67503E72BAEAD05D13DF670F7D88CCD /* SwiftHTTP-dummy.m */,
15348E9E02C583262BCE9E2DF83BB390 /* SwiftHTTP-prefix.pch */,
3E9E80ACD8021743B20121DDA0D7F457 /* SwiftHTTP-umbrella.h */,
);
name = "Support Files";
path = "../Target Support Files/SwiftHTTP";
sourceTree = "<group>";
};
F0DC4F36A15704389A9297F3020BED99 /* Pods */ = {
isa = PBXGroup;
children = (
4D8D4937101166A85BFF2FBAF40F5516 /* ReachabilitySwift */,
8480DBE9F2782F5C8217930EA726C666 /* SwiftHTTP */,
);
name = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
0B22B6FADDDAE608553086624BF5AE09 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
719D747C7DAF00843C07D2368BD9BB8F /* Pods-umbrella.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
20FB5DF95D0E471FCD3431D047B883B8 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
C9D551E664541B6D44F0DDDBC094DE22 /* SwiftHTTP-umbrella.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
AD2F7189DE36DFBFFC16AD43D522D04D /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
6E0B32BB9D7E10891D49EF9D239B20D8 /* ReachabilitySwift-umbrella.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
0C66C30381F86C3D642FC983CCADEBB6 /* ReachabilitySwift */ = {
isa = PBXNativeTarget;
buildConfigurationList = 882C86C75819C78E7E8EB42E9274C2D2 /* Build configuration list for PBXNativeTarget "ReachabilitySwift" */;
buildPhases = (
8CC6D6A78FAF3FC63BD31EF4244EECF0 /* Sources */,
10CE6206C906127554A7B0BF49A457CC /* Frameworks */,
AD2F7189DE36DFBFFC16AD43D522D04D /* Headers */,
);
buildRules = (
);
dependencies = (
);
name = ReachabilitySwift;
productName = ReachabilitySwift;
productReference = 62384151EBD793096A1AAF3E92D94B8D /* ReachabilitySwift.framework */;
productType = "com.apple.product-type.framework";
};
8A1E0EE23F7DB25CAD85F10192E3946A /* Pods */ = {
isa = PBXNativeTarget;
buildConfigurationList = E336FAF9DDF77FD2D4B1D814E920DE06 /* Build configuration list for PBXNativeTarget "Pods" */;
buildPhases = (
68DE87CB2D7394E962BFFE8ED2A9F383 /* Sources */,
3B6CEF09D80635B1C1A67720265E1C26 /* Frameworks */,
0B22B6FADDDAE608553086624BF5AE09 /* Headers */,
);
buildRules = (
);
dependencies = (
FA94B6C4DD56FB750B8EB85AAD501F88 /* PBXTargetDependency */,
83625E2F06EBB2816D94100B60CA3F8C /* PBXTargetDependency */,
);
name = Pods;
productName = Pods;
productReference = 097C0D457717655774F1C6B4482469C1 /* Pods.framework */;
productType = "com.apple.product-type.framework";
};
AB33B84630B10DE253DA6B29E233F61D /* SwiftHTTP */ = {
isa = PBXNativeTarget;
buildConfigurationList = D842CE539573B27EEC42F919D3A8E7E9 /* Build configuration list for PBXNativeTarget "SwiftHTTP" */;
buildPhases = (
AFBA4EC0488F1C9A3F1766426F037C69 /* Sources */,
E7AF66B94C382A3D9361923B020E023F /* Frameworks */,
20FB5DF95D0E471FCD3431D047B883B8 /* Headers */,
);
buildRules = (
);
dependencies = (
);
name = SwiftHTTP;
productName = SwiftHTTP;
productReference = 1AFB0CBFBAAD243441BFBACC7D2D8DFE /* SwiftHTTP.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
D41D8CD98F00B204E9800998ECF8427E /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
};
buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 7DB346D0F39D3F0E887471402A8071AB;
productRefGroup = CCA510CFBEA2D207524CDA0D73C3B561 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
8A1E0EE23F7DB25CAD85F10192E3946A /* Pods */,
0C66C30381F86C3D642FC983CCADEBB6 /* ReachabilitySwift */,
AB33B84630B10DE253DA6B29E233F61D /* SwiftHTTP */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
68DE87CB2D7394E962BFFE8ED2A9F383 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0349D3641FA40BDE258EBB89DAB0CE56 /* Pods-dummy.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
8CC6D6A78FAF3FC63BD31EF4244EECF0 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
82FEFB5F8E2CE9FF43EDE67D41F774D6 /* Reachability.swift in Sources */,
50CB3873CE44B09068C6650F7BC1B62E /* ReachabilitySwift-dummy.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
AFBA4EC0488F1C9A3F1766426F037C69 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
01259B29E7B75268A2E4639449AE759B /* HTTPRequestSerializer.swift in Sources */,
F556360A6CF9AD4B39927790324A61AA /* HTTPResponseSerializer.swift in Sources */,
4CB56104486E20F3D1A8F0F048473FD5 /* HTTPSecurity.swift in Sources */,
588B0C8E4C2F7849023F60069A7AF094 /* HTTPTask.swift in Sources */,
5C601DFC35BD0AA393A1C6B29E45B133 /* HTTPUpload.swift in Sources */,
7EACDBE6B531B186A1ECDF5838A92549 /* SwiftHTTP-dummy.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
83625E2F06EBB2816D94100B60CA3F8C /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = SwiftHTTP;
target = AB33B84630B10DE253DA6B29E233F61D /* SwiftHTTP */;
targetProxy = EC3ED57D07B7D0FB9BC30494E35FFDB9 /* PBXContainerItemProxy */;
};
FA94B6C4DD56FB750B8EB85AAD501F88 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = ReachabilitySwift;
target = 0C66C30381F86C3D642FC983CCADEBB6 /* ReachabilitySwift */;
targetProxy = 039A210DD9F51E9946D160F7EEDCCA0B /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
1CEA97719C11C51D66E51817DB9E086F /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4057D82490BD357705895A1E889818DC /* Pods.debug.xcconfig */;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = "Target Support Files/Pods/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MODULEMAP_FILE = "Target Support Files/Pods/Pods.modulemap";
MTL_ENABLE_DEBUG_INFO = YES;
OTHER_LDFLAGS = "";
OTHER_LIBTOOLFLAGS = "";
PODS_ROOT = "$(SRCROOT)";
PRODUCT_NAME = Pods;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
21A6712541CD335AD75433A36DA862A1 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 649885E5C778C58AB64D51F0C20CED29 /* SwiftHTTP-Private.xcconfig */;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.9.5;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 0.9.5;
DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)";
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_VERSION = A;
GCC_PREFIX_HEADER = "Target Support Files/SwiftHTTP/SwiftHTTP-prefix.pch";
INFOPLIST_FILE = "Target Support Files/SwiftHTTP/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MODULEMAP_FILE = "Target Support Files/SwiftHTTP/SwiftHTTP.modulemap";
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_NAME = SwiftHTTP;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
52D4ECB745D1C035F94BD060EE7F6605 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
ONLY_ACTIVE_ARCH = YES;
STRIP_INSTALLED_PRODUCT = NO;
SYMROOT = "${SRCROOT}/../build";
};
name = Debug;
};
55EB40FAD13AC43FBC7870F72AECCA72 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = AD3DFA8DA99A0DD784441E8ACE3379F9 /* Pods.release.xcconfig */;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = "Target Support Files/Pods/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MODULEMAP_FILE = "Target Support Files/Pods/Pods.modulemap";
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_LDFLAGS = "";
OTHER_LIBTOOLFLAGS = "";
PODS_ROOT = "$(SRCROOT)";
PRODUCT_NAME = Pods;
SDKROOT = macosx;
SKIP_INSTALL = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
A070F153A04DD66F4E492261894B37FF /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_PREPROCESSOR_DEFINITIONS = "RELEASE=1";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
STRIP_INSTALLED_PRODUCT = NO;
SYMROOT = "${SRCROOT}/../build";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
A29CAFA0C4CE5C92DD44075B2C08F2C2 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = A951EEB50E667EEF07D87DD479DA9433 /* ReachabilitySwift-Private.xcconfig */;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.1.0;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)";
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_VERSION = A;
GCC_PREFIX_HEADER = "Target Support Files/ReachabilitySwift/ReachabilitySwift-prefix.pch";
INFOPLIST_FILE = "Target Support Files/ReachabilitySwift/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MODULEMAP_FILE = "Target Support Files/ReachabilitySwift/ReachabilitySwift.modulemap";
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_NAME = ReachabilitySwift;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
B28AC95D7FE099EAFD8FCA215D7488F2 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 649885E5C778C58AB64D51F0C20CED29 /* SwiftHTTP-Private.xcconfig */;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.9.5;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 0.9.5;
DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)";
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_VERSION = A;
GCC_PREFIX_HEADER = "Target Support Files/SwiftHTTP/SwiftHTTP-prefix.pch";
INFOPLIST_FILE = "Target Support Files/SwiftHTTP/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MODULEMAP_FILE = "Target Support Files/SwiftHTTP/SwiftHTTP.modulemap";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = SwiftHTTP;
SDKROOT = macosx;
SKIP_INSTALL = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
C2F533C4A579F0B9A436CC8C7E79ED91 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = A951EEB50E667EEF07D87DD479DA9433 /* ReachabilitySwift-Private.xcconfig */;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.1.0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)";
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_VERSION = A;
GCC_PREFIX_HEADER = "Target Support Files/ReachabilitySwift/ReachabilitySwift-prefix.pch";
INFOPLIST_FILE = "Target Support Files/ReachabilitySwift/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MODULEMAP_FILE = "Target Support Files/ReachabilitySwift/ReachabilitySwift.modulemap";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = ReachabilitySwift;
SDKROOT = macosx;
SKIP_INSTALL = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = {
isa = XCConfigurationList;
buildConfigurations = (
52D4ECB745D1C035F94BD060EE7F6605 /* Debug */,
A070F153A04DD66F4E492261894B37FF /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
882C86C75819C78E7E8EB42E9274C2D2 /* Build configuration list for PBXNativeTarget "ReachabilitySwift" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A29CAFA0C4CE5C92DD44075B2C08F2C2 /* Debug */,
C2F533C4A579F0B9A436CC8C7E79ED91 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D842CE539573B27EEC42F919D3A8E7E9 /* Build configuration list for PBXNativeTarget "SwiftHTTP" */ = {
isa = XCConfigurationList;
buildConfigurations = (
21A6712541CD335AD75433A36DA862A1 /* Debug */,
B28AC95D7FE099EAFD8FCA215D7488F2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
E336FAF9DDF77FD2D4B1D814E920DE06 /* Build configuration list for PBXNativeTarget "Pods" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1CEA97719C11C51D66E51817DB9E086F /* Debug */,
55EB40FAD13AC43FBC7870F72AECCA72 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
}

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "218207ACA7371A9334F2B7AE"
BuildableName = "Pods.framework"
BlueprintName = "Pods"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "139B83C851E589090F603794"
BuildableName = "ReachabilitySwift.framework"
BlueprintName = "ReachabilitySwift"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2514840DECCBE0D5C453F231"
BuildableName = "SwiftHTTP.framework"
BlueprintName = "SwiftHTTP"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,42 @@
<?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>SchemeUserState</key>
<dict>
<key>Pods.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
<key>ReachabilitySwift.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
<key>SwiftHTTP.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>0C66C30381F86C3D642FC983CCADEBB6</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>8A1E0EE23F7DB25CAD85F10192E3946A</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>AB33B84630B10DE253DA6B29E233F61D</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,21 @@
/*
Copyright (c) 2014, Ashley Mills
All rights reserved.
Redistribution and use in source, with or without modification, is permitted provided that the following condition is met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/

View File

@ -0,0 +1,86 @@
# Reachability.swift
Replacement for Apple's Reachability re-written in Swift with closures
Inspired by https://github.com/tonymillion/Reachability
**NOTES:**
- As of Swift 1.2, you cannot convert Swift closures into C-function pointers, meaning we can't set an `SCNetworkReachabilityCallBack`. To get around this, this reachability replacement uses a `dispatch_source` firing at 1/2 second intervals.
- If an application has the privacy option “Use cellular data” turned off, the Reachability class still reports isReachable() to be true. There is currently no (non-private) API to detect this. If you need this feature, please raise file a [bug report](https://bugreport.apple.com) with Apple to get this fixed. See devforums thread for details: https://devforums.apple.com/message/1059332#1059332
## Installation
### CocoaPods
[CocoaPods][] is a dependency manager for Cocoa projects. To install Reachability.swift with CocoaPods:
1. Make sure CocoaPods is [installed][CocoaPods Installation].
2. Update your Podfile to include the following:
``` ruby
use_frameworks!
pod 'ReachabilitySwift', git: 'https://github.com/ashleymills/Reachability.swift'
```
3. Run `pod install`.
[CocoaPods]: https://cocoapods.org
[CocoaPods Installation]: https://guides.cocoapods.org/using/getting-started.html#getting-started
### Manual
Just drop the **Reachability.swift** file into your project. That's it!
## Example - closures
let reachability = Reachability.reachabilityForInternetConnection()
reachability.whenReachable = { reachability in
if reachability.isReachableViaWiFi() {
println("Reachable via WiFi")
} else {
println("Reachable via Cellular")
}
}
reachability.whenUnreachable = { reachability in
println("Not reachable")
}
reachability.startNotifier()
## Example - notifications
let reachability = Reachability.reachabilityForInternetConnection()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "reachabilityChanged:", name: ReachabilityChangedNotification, object: reachability)
reachability.startNotifier()
and
func reachabilityChanged(note: NSNotification) {
let reachability = note.object as! Reachability
if reachability.isReachable() {
if reachability.isReachableViaWiFi() {
println("Reachable via WiFi")
} else {
println("Reachable via Cellular")
}
} else {
println("Not reachable")
}
}
## Want to help?
Got a bug fix, or a new feature? Create a pull request and go for it!
## Let me know!
If you use **Reachability.swift**, please let me know about your app and I'll put a link [here…](https://github.com/ashleymills/Reachability.swift/wiki/Apps-using-Reachability.swift) and tell your friends!
Cheers,
Ash

View File

@ -0,0 +1,373 @@
/*
Copyright (c) 2014, Ashley Mills
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
import SystemConfiguration
import Foundation
public let ReachabilityChangedNotification = "ReachabilityChangedNotification"
public class Reachability: NSObject, Printable {
public typealias NetworkReachable = (Reachability) -> ()
public typealias NetworkUnreachable = (Reachability) -> ()
public enum NetworkStatus: Printable {
case NotReachable, ReachableViaWiFi, ReachableViaWWAN
public var description: String {
switch self {
case .ReachableViaWWAN:
return "Cellular"
case .ReachableViaWiFi:
return "WiFi"
case .NotReachable:
return "No Connection"
}
}
}
// MARK: - *** Public properties ***
public var whenReachable: NetworkReachable?
public var whenUnreachable: NetworkUnreachable?
public var reachableOnWWAN: Bool
public var notificationCenter = NSNotificationCenter.defaultCenter()
public var currentReachabilityStatus: NetworkStatus {
if isReachable() {
if isReachableViaWiFi() {
return .ReachableViaWiFi
}
if isRunningOnDevice {
return .ReachableViaWWAN
}
}
return .NotReachable
}
public var currentReachabilityString: String {
return "\(currentReachabilityStatus)"
}
// MARK: - *** Initialisation methods ***
public required init(reachabilityRef: SCNetworkReachability) {
reachableOnWWAN = true
self.reachabilityRef = reachabilityRef
}
public convenience init(hostname: String) {
let ref = SCNetworkReachabilityCreateWithName(nil, (hostname as NSString).UTF8String).takeRetainedValue()
self.init(reachabilityRef: ref)
}
public class func reachabilityForInternetConnection() -> Reachability {
var zeroAddress = sockaddr_in(sin_len: __uint8_t(0), sin_family: sa_family_t(0), sin_port: in_port_t(0), sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress))
zeroAddress.sin_family = sa_family_t(AF_INET)
let ref = withUnsafePointer(&zeroAddress) {
SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, UnsafePointer($0)).takeRetainedValue()
}
return Reachability(reachabilityRef: ref)
}
public class func reachabilityForLocalWiFi() -> Reachability {
var localWifiAddress: sockaddr_in = sockaddr_in(sin_len: __uint8_t(0), sin_family: sa_family_t(0), sin_port: in_port_t(0), sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
localWifiAddress.sin_len = UInt8(sizeofValue(localWifiAddress))
localWifiAddress.sin_family = sa_family_t(AF_INET)
// IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
let address: Int64 = 0xA9FE0000
localWifiAddress.sin_addr.s_addr = in_addr_t(address.bigEndian)
let ref = withUnsafePointer(&localWifiAddress) {
SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, UnsafePointer($0)).takeRetainedValue()
}
return Reachability(reachabilityRef: ref)
}
// MARK: - *** Notifier methods ***
public func startNotifier() -> Bool {
reachabilityObject = self
let reachability = self.reachabilityRef!
previousReachabilityFlags = reachabilityFlags
if let timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, timer_queue) {
dispatch_source_set_timer(timer, dispatch_walltime(nil, 0), 500 * NSEC_PER_MSEC, 100 * NSEC_PER_MSEC)
dispatch_source_set_event_handler(timer, { [unowned self] in
self.timerFired()
})
dispatch_timer = timer
dispatch_resume(timer)
return true
} else {
return false
}
}
public func stopNotifier() {
reachabilityObject = nil
if let timer = dispatch_timer {
dispatch_source_cancel(timer)
dispatch_timer = nil
}
}
// MARK: - *** Connection test methods ***
public func isReachable() -> Bool {
return isReachableWithTest({ (flags: SCNetworkReachabilityFlags) -> (Bool) in
return self.isReachableWithFlags(flags)
})
}
public func isReachableViaWWAN() -> Bool {
if isRunningOnDevice {
return isReachableWithTest() { flags -> Bool in
// Check we're REACHABLE
if self.isReachable(flags) {
// Now, check we're on WWAN
if self.isOnWWAN(flags) {
return true
}
}
return false
}
}
return false
}
public func isReachableViaWiFi() -> Bool {
return isReachableWithTest() { flags -> Bool in
// Check we're reachable
if self.isReachable(flags) {
if self.isRunningOnDevice {
// Check we're NOT on WWAN
if self.isOnWWAN(flags) {
return false
}
}
return true
}
return false
}
}
// MARK: - *** Private methods ***
private var isRunningOnDevice: Bool = {
#if (arch(i386) || arch(x86_64)) && os(iOS)
return false
#else
return true
#endif
}()
private var reachabilityRef: SCNetworkReachability?
private var reachabilityObject: AnyObject?
private var dispatch_timer: dispatch_source_t?
private lazy var timer_queue: dispatch_queue_t = {
return dispatch_queue_create("uk.co.joylordsystems.reachability_timer_queue", nil)
}()
private var previousReachabilityFlags: SCNetworkReachabilityFlags?
func timerFired() {
let currentReachabilityFlags = reachabilityFlags
if let _previousReachabilityFlags = previousReachabilityFlags {
if currentReachabilityFlags != previousReachabilityFlags {
dispatch_async(dispatch_get_main_queue(), { [unowned self] in
self.reachabilityChanged(currentReachabilityFlags)
self.previousReachabilityFlags = currentReachabilityFlags
})
}
}
}
private func reachabilityChanged(flags: SCNetworkReachabilityFlags) {
if isReachableWithFlags(flags) {
if let block = whenReachable {
block(self)
}
} else {
if let block = whenUnreachable {
block(self)
}
}
notificationCenter.postNotificationName(ReachabilityChangedNotification, object:self)
}
private func isReachableWithFlags(flags: SCNetworkReachabilityFlags) -> Bool {
let reachable = isReachable(flags)
if !reachable {
return false
}
if isConnectionRequiredOrTransient(flags) {
return false
}
if isRunningOnDevice {
if isOnWWAN(flags) && !reachableOnWWAN {
// We don't want to connect when on 3G.
return false
}
}
return true
}
private func isReachableWithTest(test: (SCNetworkReachabilityFlags) -> (Bool)) -> Bool {
var flags: SCNetworkReachabilityFlags = 0
let gotFlags = SCNetworkReachabilityGetFlags(reachabilityRef, &flags) != 0
if gotFlags {
return test(flags)
}
return false
}
// WWAN may be available, but not active until a connection has been established.
// WiFi may require a connection for VPN on Demand.
private func isConnectionRequired() -> Bool {
return connectionRequired()
}
private func connectionRequired() -> Bool {
return isReachableWithTest({ (flags: SCNetworkReachabilityFlags) -> (Bool) in
return self.isConnectionRequired(flags)
})
}
// Dynamic, on demand connection?
private func isConnectionOnDemand() -> Bool {
return isReachableWithTest({ (flags: SCNetworkReachabilityFlags) -> (Bool) in
return self.isConnectionRequired(flags) && self.isConnectionOnTrafficOrDemand(flags)
})
}
// Is user intervention required?
private func isInterventionRequired() -> Bool {
return isReachableWithTest({ (flags: SCNetworkReachabilityFlags) -> (Bool) in
return self.isConnectionRequired(flags) && self.isInterventionRequired(flags)
})
}
private func isOnWWAN(flags: SCNetworkReachabilityFlags) -> Bool {
#if os(iOS)
return flags & SCNetworkReachabilityFlags(kSCNetworkReachabilityFlagsIsWWAN) != 0
#else
return false
#endif
}
private func isReachable(flags: SCNetworkReachabilityFlags) -> Bool {
return flags & SCNetworkReachabilityFlags(kSCNetworkReachabilityFlagsReachable) != 0
}
private func isConnectionRequired(flags: SCNetworkReachabilityFlags) -> Bool {
return flags & SCNetworkReachabilityFlags(kSCNetworkReachabilityFlagsConnectionRequired) != 0
}
private func isInterventionRequired(flags: SCNetworkReachabilityFlags) -> Bool {
return flags & SCNetworkReachabilityFlags(kSCNetworkReachabilityFlagsInterventionRequired) != 0
}
private func isConnectionOnTraffic(flags: SCNetworkReachabilityFlags) -> Bool {
return flags & SCNetworkReachabilityFlags(kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0
}
private func isConnectionOnDemand(flags: SCNetworkReachabilityFlags) -> Bool {
return flags & SCNetworkReachabilityFlags(kSCNetworkReachabilityFlagsConnectionOnDemand) != 0
}
func isConnectionOnTrafficOrDemand(flags: SCNetworkReachabilityFlags) -> Bool {
return flags & SCNetworkReachabilityFlags(kSCNetworkReachabilityFlagsConnectionOnTraffic | kSCNetworkReachabilityFlagsConnectionOnDemand) != 0
}
private func isTransientConnection(flags: SCNetworkReachabilityFlags) -> Bool {
return flags & SCNetworkReachabilityFlags(kSCNetworkReachabilityFlagsTransientConnection) != 0
}
private func isLocalAddress(flags: SCNetworkReachabilityFlags) -> Bool {
return flags & SCNetworkReachabilityFlags(kSCNetworkReachabilityFlagsIsLocalAddress) != 0
}
private func isDirect(flags: SCNetworkReachabilityFlags) -> Bool {
return flags & SCNetworkReachabilityFlags(kSCNetworkReachabilityFlagsIsDirect) != 0
}
private func isConnectionRequiredOrTransient(flags: SCNetworkReachabilityFlags) -> Bool {
let testcase = SCNetworkReachabilityFlags(kSCNetworkReachabilityFlagsConnectionRequired | kSCNetworkReachabilityFlagsTransientConnection)
return flags & testcase == testcase
}
private var reachabilityFlags: SCNetworkReachabilityFlags {
var flags: SCNetworkReachabilityFlags = 0
let gotFlags = SCNetworkReachabilityGetFlags(reachabilityRef, &flags) != 0
if gotFlags {
return flags
}
return 0
}
override public var description: String {
var W: String
if isRunningOnDevice {
W = isOnWWAN(reachabilityFlags) ? "W" : "-"
} else {
W = "X"
}
let R = isReachable(reachabilityFlags) ? "R" : "-"
let c = isConnectionRequired(reachabilityFlags) ? "c" : "-"
let t = isTransientConnection(reachabilityFlags) ? "t" : "-"
let i = isInterventionRequired(reachabilityFlags) ? "i" : "-"
let C = isConnectionOnTraffic(reachabilityFlags) ? "C" : "-"
let D = isConnectionOnDemand(reachabilityFlags) ? "D" : "-"
let l = isLocalAddress(reachabilityFlags) ? "l" : "-"
let d = isDirect(reachabilityFlags) ? "d" : "-"
return "\(W)\(R) \(c)\(t)\(i)\(C)\(D)\(l)\(d)"
}
deinit {
stopNotifier()
reachabilityRef = nil
whenReachable = nil
whenUnreachable = nil
}
}

View File

@ -0,0 +1,286 @@
//////////////////////////////////////////////////////////////////////////////////////////////////
//
// HTTPRequestSerializer.swift
//
// Created by Dalton Cherry on 6/3/14.
// Copyright (c) 2014 Vluxe. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////////////////////////
import Foundation
extension String {
/**
A simple extension to the String object to encode it for web request.
:returns: Encoded version of of string it was called as.
*/
var escaped: String {
return CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,self,"[].",":/?&=;+!@#$()',*",CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)) as! String
}
}
/// Default Serializer for serializing an object to an HTTP request. This applies to form serialization, parameter encoding, etc.
public class HTTPRequestSerializer: NSObject {
let contentTypeKey = "Content-Type"
/// headers for the request.
public var headers = Dictionary<String,String>()
/// encoding for the request.
public var stringEncoding: UInt = NSUTF8StringEncoding
/// Send request if using cellular network or not. Defaults to true.
public var allowsCellularAccess = true
/// If the request should handle cookies of not. Defaults to true.
public var HTTPShouldHandleCookies = true
/// If the request should use piplining or not. Defaults to false.
public var HTTPShouldUsePipelining = false
/// How long the timeout interval is. Defaults to 60 seconds.
public var timeoutInterval: NSTimeInterval = 60
/// Set the request cache policy. Defaults to UseProtocolCachePolicy.
public var cachePolicy: NSURLRequestCachePolicy = NSURLRequestCachePolicy.UseProtocolCachePolicy
/// Set the network service. Defaults to NetworkServiceTypeDefault.
public var networkServiceType = NSURLRequestNetworkServiceType.NetworkServiceTypeDefault
/// Initializes a new HTTPRequestSerializer Object.
public override init() {
super.init()
}
/**
Creates a new NSMutableURLRequest object with configured options.
:param: url The url you would like to make a request to.
:param: method The HTTP method/verb for the request.
:returns: A new NSMutableURLRequest with said options.
*/
public func newRequest(url: NSURL, method: HTTPMethod) -> NSMutableURLRequest {
var request = NSMutableURLRequest(URL: url, cachePolicy: cachePolicy, timeoutInterval: timeoutInterval)
request.HTTPMethod = method.rawValue
request.cachePolicy = self.cachePolicy
request.timeoutInterval = self.timeoutInterval
request.allowsCellularAccess = self.allowsCellularAccess
request.HTTPShouldHandleCookies = self.HTTPShouldHandleCookies
request.HTTPShouldUsePipelining = self.HTTPShouldUsePipelining
request.networkServiceType = self.networkServiceType
for (key,val) in self.headers {
request.addValue(val, forHTTPHeaderField: key)
}
return request
}
/**
Creates a new NSMutableURLRequest object with configured options.
:param: url The url you would like to make a request to.
:param: method The HTTP method/verb for the request.
:param: parameters The parameters are HTTP parameters you would like to send.
:returns: A new NSMutableURLRequest with said options or an error.
*/
public func createRequest(url: NSURL, method: HTTPMethod, parameters: Dictionary<String,AnyObject>?) -> (request: NSURLRequest, error: NSError?) {
var request = newRequest(url, method: method)
var isMulti = false
//do a check for upload objects to see if we are multi form
if let params = parameters {
isMulti = isMultiForm(params)
}
if isMulti {
if(method != .POST && method != .PUT && method != .PATCH) {
request.HTTPMethod = HTTPMethod.POST.rawValue // you probably wanted a post
}
var boundary = "Boundary+\(arc4random())\(arc4random())"
if parameters != nil {
request.HTTPBody = dataFromParameters(parameters!,boundary: boundary)
}
if request.valueForHTTPHeaderField(contentTypeKey) == nil {
request.setValue("multipart/form-data; boundary=\(boundary)",
forHTTPHeaderField:contentTypeKey)
}
return (request,nil)
}
var queryString = ""
if parameters != nil {
queryString = self.stringFromParameters(parameters!)
}
if isURIParam(method) {
var para = (request.URL!.query != nil) ? "&" : "?"
var newUrl = "\(request.URL!.absoluteString!)"
if count(queryString) > 0 {
newUrl += "\(para)\(queryString)"
}
request.URL = NSURL(string: newUrl)
} else {
var charset = CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(self.stringEncoding));
if request.valueForHTTPHeaderField(contentTypeKey) == nil {
request.setValue("application/x-www-form-urlencoded; charset=\(charset)",
forHTTPHeaderField:contentTypeKey)
}
request.HTTPBody = queryString.dataUsingEncoding(self.stringEncoding)
}
return (request,nil)
}
///check for multi form objects
public func isMultiForm(params: Dictionary<String,AnyObject>) -> Bool {
for (name,object: AnyObject) in params {
if object is HTTPUpload {
return true
} else if let subParams = object as? Dictionary<String,AnyObject> {
if isMultiForm(subParams) {
return true
}
}
}
return false
}
///check if enum is a HTTPMethod that requires the params in the URL
public func isURIParam(method: HTTPMethod) -> Bool {
if(method == .GET || method == .HEAD || method == .DELETE) {
return true
}
return false
}
///convert the parameter dict to its HTTP string representation
func stringFromParameters(parameters: Dictionary<String,AnyObject>) -> String {
return join("&", map(serializeObject(parameters, key: nil), {(pair) in
return pair.stringValue()
}))
}
///the method to serialized all the objects
func serializeObject(object: AnyObject,key: String?) -> Array<HTTPPair> {
var collect = Array<HTTPPair>()
if let array = object as? Array<AnyObject> {
for nestedValue : AnyObject in array {
collect.extend(self.serializeObject(nestedValue,key: "\(key!)[]"))
}
} else if let dict = object as? Dictionary<String,AnyObject> {
for (nestedKey, nestedObject: AnyObject) in dict {
var newKey = key != nil ? "\(key!)[\(nestedKey)]" : nestedKey
collect.extend(self.serializeObject(nestedObject,key: newKey))
}
} else {
collect.append(HTTPPair(value: object, key: key))
}
return collect
}
//create a multi form data object of the parameters
func dataFromParameters(parameters: Dictionary<String,AnyObject>,boundary: String) -> NSData {
var mutData = NSMutableData()
var multiCRLF = "\r\n"
var boundSplit = "\(multiCRLF)--\(boundary)\(multiCRLF)".dataUsingEncoding(self.stringEncoding)!
var lastBound = "\(multiCRLF)--\(boundary)--\(multiCRLF)".dataUsingEncoding(self.stringEncoding)!
mutData.appendData("--\(boundary)\(multiCRLF)".dataUsingEncoding(self.stringEncoding)!)
let pairs = serializeObject(parameters, key: nil)
let count = pairs.count-1
var i = 0
for pair in pairs {
var append = true
if let upload = pair.getUpload() {
if let data = upload.data {
mutData.appendData(multiFormHeader(pair.k, fileName: upload.fileName,
type: upload.mimeType, multiCRLF: multiCRLF).dataUsingEncoding(self.stringEncoding)!)
mutData.appendData(data)
} else {
append = false
}
} else {
let str = "\(multiFormHeader(pair.k, fileName: nil, type: nil, multiCRLF: multiCRLF))\(pair.getValue())"
mutData.appendData(str.dataUsingEncoding(self.stringEncoding)!)
}
if append {
if i == count {
mutData.appendData(lastBound)
} else {
mutData.appendData(boundSplit)
}
}
i++
}
return mutData
}
///helper method to create the multi form headers
func multiFormHeader(name: String, fileName: String?, type: String?, multiCRLF: String) -> String {
var str = "Content-Disposition: form-data; name=\"\(name.escaped)\""
if fileName != nil {
str += "; filename=\"\(fileName!)\""
}
str += multiCRLF
if type != nil {
str += "Content-Type: \(type!)\(multiCRLF)"
}
str += multiCRLF
return str
}
/// Creates key/pair of the parameters.
class HTTPPair: NSObject {
var val: AnyObject
var k: String!
init(value: AnyObject, key: String?) {
self.val = value
self.k = key
}
func getUpload() -> HTTPUpload? {
return self.val as? HTTPUpload
}
func getValue() -> String {
var val = ""
if let str = self.val as? String {
val = str
} else if self.val.description != nil {
val = self.val.description
}
return val
}
func stringValue() -> String {
var v = getValue()
if self.k == nil {
return v.escaped
}
return "\(self.k.escaped)=\(v.escaped)"
}
}
}
/// JSON Serializer for serializing an object to an HTTP request. Same as HTTPRequestSerializer, expect instead of HTTP form encoding it does JSON.
public class JSONRequestSerializer: HTTPRequestSerializer {
/**
Creates a new NSMutableURLRequest object with configured options.
:param: url The url you would like to make a request to.
:param: method The HTTP method/verb for the request.
:param: parameters The parameters are HTTP parameters you would like to send.
:returns: A new NSMutableURLRequest with said options or an error.
*/
public override func createRequest(url: NSURL, method: HTTPMethod, parameters: Dictionary<String,AnyObject>?) -> (request: NSURLRequest, error: NSError?) {
if self.isURIParam(method) {
return super.createRequest(url, method: method, parameters: parameters)
}
var request = newRequest(url, method: method)
var error: NSError?
if parameters != nil {
var charset = CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding));
request.setValue("application/json; charset=\(charset)", forHTTPHeaderField: self.contentTypeKey)
request.HTTPBody = NSJSONSerialization.dataWithJSONObject(parameters!, options: NSJSONWritingOptions(), error:&error)
}
return (request, error)
}
}

View File

@ -0,0 +1,36 @@
//////////////////////////////////////////////////////////////////////////////////////////////////
//
// HTTPResponseSerializer.swift
//
// Created by Dalton Cherry on 6/16/14.
// Copyright (c) 2014 Vluxe. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////////////////////////
import Foundation
/// This protocol provides a way to implement a custom serializer.
public protocol HTTPResponseSerializer {
/// This can be used if you want to have your data parsed/serialized into something instead of just a NSData blob.
func responseObjectFromResponse(response: NSURLResponse, data: NSData) -> (object: AnyObject?, error: NSError?)
}
/// Serialize the data into a JSON object.
public struct JSONResponseSerializer : HTTPResponseSerializer {
/// Initializes a new JSONResponseSerializer Object.
public init(){}
/**
Creates a HTTPOperation that can be scheduled on a NSOperationQueue. Called by convenience HTTP verb methods below.
:param: response The NSURLResponse.
:param: data The response data to be parsed into JSON.
:returns: Returns a object from JSON data and an NSError if an error occured while parsing the data.
*/
public func responseObjectFromResponse(response: NSURLResponse, data: NSData) -> (object: AnyObject?, error: NSError?) {
var error: NSError?
let response: AnyObject? = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions(), error: &error)
return (response,error)
}
}

View File

@ -0,0 +1,244 @@
//////////////////////////////////////////////////////////////////////////////////////////////////
//
// HTTPSecurity.swift
// SwiftHTTP
//
// Created by Dalton Cherry on 5/13/15.
// Copyright (c) 2015 Vluxe. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////////////////////////
import Foundation
import Security
public class HTTPSSLCert {
var certData: NSData?
var key: SecKeyRef?
/**
Designated init for certificates
:param: data is the binary data of the certificate
:returns: a representation security object to be used with
*/
public init(data: NSData) {
self.certData = data
}
/**
Designated init for public keys
:param: key is the public key to be used
:returns: a representation security object to be used with
*/
public init(key: SecKeyRef) {
self.key = key
}
}
public class HTTPSecurity {
public var validatedDN = true //should the domain name be validated?
var isReady = false //is the key processing done?
var certificates: [NSData]? //the certificates
var pubKeys: [SecKeyRef]? //the public keys
var usePublicKeys = false //use public keys or certificate validation?
/**
Use certs from main app bundle
:param: usePublicKeys is to specific if the publicKeys or certificates should be used for SSL pinning validation
:returns: a representation security object to be used with
*/
public convenience init(usePublicKeys: Bool = false) {
let paths = NSBundle.mainBundle().pathsForResourcesOfType("cer", inDirectory: ".")
var collect = Array<HTTPSSLCert>()
for path in paths {
if let d = NSData(contentsOfFile: path as! String) {
collect.append(HTTPSSLCert(data: d))
}
}
self.init(certs:collect, usePublicKeys: usePublicKeys)
}
/**
Designated init
:param: keys is the certificates or public keys to use
:param: usePublicKeys is to specific if the publicKeys or certificates should be used for SSL pinning validation
:returns: a representation security object to be used with
*/
public init(certs: [HTTPSSLCert], usePublicKeys: Bool) {
self.usePublicKeys = usePublicKeys
if self.usePublicKeys {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), {
var collect = Array<SecKeyRef>()
for cert in certs {
if let data = cert.certData where cert.key == nil {
cert.key = self.extractPublicKey(data)
}
if let k = cert.key {
collect.append(k)
}
}
self.pubKeys = collect
self.isReady = true
})
} else {
var collect = Array<NSData>()
for cert in certs {
if let d = cert.certData {
collect.append(d)
}
}
self.certificates = collect
self.isReady = true
}
}
/**
Valid the trust and domain name.
:param: trust is the serverTrust to validate
:param: domain is the CN domain to validate
:returns: if the key was successfully validated
*/
public func isValid(trust: SecTrustRef, domain: String?) -> Bool {
var tries = 0
while(!self.isReady) {
usleep(1000)
tries += 1
if tries > 5 {
return false //doesn't appear it is going to ever be ready...
}
}
var policy: SecPolicyRef
if self.validatedDN {
policy = SecPolicyCreateSSL(1, domain).takeRetainedValue()
} else {
policy = SecPolicyCreateBasicX509().takeRetainedValue()
}
SecTrustSetPolicies(trust,policy)
if self.usePublicKeys {
if let keys = self.pubKeys {
var trustedCount = 0
let serverPubKeys = publicKeyChainForTrust(trust)
for serverKey in serverPubKeys as [AnyObject] {
for key in keys as [AnyObject] {
if serverKey.isEqual(key) {
trustedCount++
break
}
}
}
if trustedCount == serverPubKeys.count {
return true
}
}
} else if let certs = self.certificates {
let serverCerts = certificateChainForTrust(trust)
var collect = Array<SecCertificate>()
for cert in certs {
collect.append(SecCertificateCreateWithData(nil,cert).takeRetainedValue())
}
SecTrustSetAnchorCertificates(trust,collect)
var result: SecTrustResultType = 0
SecTrustEvaluate(trust,&result)
let r = Int(result)
if r == kSecTrustResultUnspecified || r == kSecTrustResultProceed {
var trustedCount = 0
for serverCert in serverCerts {
for cert in certs {
if cert == serverCert {
trustedCount++
break
}
}
}
if trustedCount == serverCerts.count {
return true
}
}
}
return false
}
/**
Get the public key from a certificate data
:param: data is the certificate to pull the public key from
:returns: a public key
*/
func extractPublicKey(data: NSData) -> SecKeyRef? {
var publicKey: NSData?
let possibleCert = SecCertificateCreateWithData(nil,data)
if let cert = possibleCert {
return extractPublicKeyFromCert(cert.takeRetainedValue(),policy: SecPolicyCreateBasicX509().takeRetainedValue())
}
return nil
}
/**
Get the public key from a certificate
:param: data is the certificate to pull the public key from
:returns: a public key
*/
func extractPublicKeyFromCert(cert: SecCertificate, policy: SecPolicy) -> SecKeyRef? {
var possibleTrust: Unmanaged<SecTrust>?
SecTrustCreateWithCertificates(cert,policy, &possibleTrust)
if let trust = possibleTrust {
let t = trust.takeRetainedValue()
var result: SecTrustResultType = 0
SecTrustEvaluate(t,&result)
return SecTrustCopyPublicKey(t).takeRetainedValue()
}
return nil
}
/**
Get the certificate chain for the trust
:param: trust is the trust to lookup the certificate chain for
:returns: the certificate chain for the trust
*/
func certificateChainForTrust(trust: SecTrustRef) -> Array<NSData> {
var collect = Array<NSData>()
for var i = 0; i < SecTrustGetCertificateCount(trust); i++ {
let cert = SecTrustGetCertificateAtIndex(trust,i)
collect.append(SecCertificateCopyData(cert.takeRetainedValue()).takeRetainedValue())
}
return collect
}
/**
Get the public key chain for the trust
:param: trust is the trust to lookup the certificate chain and extract the public keys
:returns: the public keys from the certifcate chain for the trust
*/
func publicKeyChainForTrust(trust: SecTrustRef) -> Array<SecKeyRef> {
var collect = Array<SecKeyRef>()
let policy = SecPolicyCreateBasicX509().takeRetainedValue()
for var i = 0; i < SecTrustGetCertificateCount(trust); i++ {
let cert = SecTrustGetCertificateAtIndex(trust,i)
if let key = extractPublicKeyFromCert(cert.takeRetainedValue(), policy: policy) {
collect.append(key)
}
}
return collect
}
}

554
ipbc-Client/Pods/SwiftHTTP/HTTPTask.swift generated Normal file
View File

@ -0,0 +1,554 @@
//////////////////////////////////////////////////////////////////////////////////////////////////
//
// HTTPTask.swift
//
// Created by Dalton Cherry on 6/3/14.
// Copyright (c) 2014 Vluxe. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////////////////////////
import Foundation
/// HTTP Verbs.
///
/// - GET: For GET requests.
/// - POST: For POST requests.
/// - PUT: For PUT requests.
/// - HEAD: For HEAD requests.
/// - DELETE: For DELETE requests.
/// - PATCH: For PATCH requests.
public enum HTTPMethod: String {
case GET = "GET"
case POST = "POST"
case PUT = "PUT"
case HEAD = "HEAD"
case DELETE = "DELETE"
case PATCH = "PATCH"
}
/// Object representation of a HTTP Response.
public class HTTPResponse {
/// The header values in HTTP response.
public var headers: Dictionary<String,String>?
/// The mime type of the HTTP response.
public var mimeType: String?
/// The suggested filename for a downloaded file.
public var suggestedFilename: String?
/// The body or response data of the HTTP response.
public var responseObject: AnyObject?
/// The status code of the HTTP response.
public var statusCode: Int?
/// The URL of the HTTP response.
public var URL: NSURL?
/// The Error of the HTTP response (if there was one).
public var error: NSError?
///Returns the response as a string
public var text: String? {
if let d = self.responseObject as? NSData {
return NSString(data: d, encoding: NSUTF8StringEncoding) as? String
} else if let val: AnyObject = self.responseObject {
return "\(val)"
}
return nil
}
//get the description of the response
public var description: String {
var buffer = ""
if let u = self.URL {
buffer += "URL:\n\(u)\n\n"
}
if let code = self.statusCode {
buffer += "Status Code:\n\(code)\n\n"
}
if let heads = self.headers {
buffer += "Headers:\n"
for (key, value) in heads {
buffer += "\(key): \(value)\n"
}
buffer += "\n"
}
if let s = self.text {
buffer += "Payload:\n\(s)\n"
}
return buffer
}
}
/// Holds the blocks of the background task.
class BackgroundBlocks {
// these 2 only get used for background download/upload since they have to be delegate methods
var completionHandler:((HTTPResponse) -> Void)?
var progress:((Double) -> Void)?
/**
Initializes a new Background Block
:param: completionHandler The closure that is run when a HTTP Request finished.
:param: progress The closure that is run on the progress of a HTTP Upload or Download.
*/
init(_ completionHandler: ((HTTPResponse) -> Void)?,_ progress: ((Double) -> Void)?) {
self.completionHandler = completionHandler
self.progress = progress
}
}
/// Subclass of NSOperation for handling and scheduling HTTPTask on a NSOperationQueue.
public class HTTPOperation : NSOperation {
private var task: NSURLSessionDataTask!
private var running = false
/// Controls if the task is finished or not.
private var done = false
//MARK: Subclassed NSOperation Methods
/// Returns if the task is asynchronous or not. NSURLSessionTask requests are asynchronous.
override public var asynchronous: Bool {
return true
}
/// Returns if the task is current running.
override public var executing: Bool {
return running
}
/// Returns if the task is finished.
override public var finished: Bool {
return done
}
/// Starts the task.
override public func start() {
if cancelled {
self.willChangeValueForKey("isFinished")
done = true
self.didChangeValueForKey("isFinished")
return
}
self.willChangeValueForKey("isExecuting")
self.willChangeValueForKey("isFinished")
running = true
done = false
self.didChangeValueForKey("isExecuting")
self.didChangeValueForKey("isFinished")
task.resume()
}
/// Cancels the running task.
override public func cancel() {
super.cancel()
task.cancel()
}
/// Sets the task to finished.
public func finish() {
self.willChangeValueForKey("isExecuting")
self.willChangeValueForKey("isFinished")
running = false
done = true
self.didChangeValueForKey("isExecuting")
self.didChangeValueForKey("isFinished")
}
}
/// Configures NSURLSession Request for HTTPOperation. Also provides convenience methods for easily running HTTP Request.
public class HTTPTask : NSObject, NSURLSessionDelegate, NSURLSessionTaskDelegate {
var backgroundTaskMap = Dictionary<String,BackgroundBlocks>()
//var sess: NSURLSession?
public var baseURL: String?
public var requestSerializer = HTTPRequestSerializer()
public var responseSerializer: HTTPResponseSerializer?
//This gets called on auth challenges. If nil, default handling is use.
//Returning nil from this method will cause the request to be rejected and cancelled
public var auth:((NSURLAuthenticationChallenge) -> NSURLCredential?)?
//This is for doing SSL pinning
public var security: HTTPSecurity?
//MARK: Public Methods
/// A newly minted HTTPTask for your enjoyment.
public override init() {
super.init()
}
/**
Creates a HTTPOperation that can be scheduled on a NSOperationQueue. Called by convenience HTTP verb methods below.
:param: url The url you would like to make a request to.
:param: method The HTTP method/verb for the request.
:param: parameters The parameters are HTTP parameters you would like to send.
:param: completionHandler The closure that is run when a HTTP Request finished.
:returns: A freshly constructed HTTPOperation to add to your NSOperationQueue.
*/
public func create(url: String, method: HTTPMethod, parameters: Dictionary<String,AnyObject>!, completionHandler:((HTTPResponse) -> Void)!) -> HTTPOperation? {
var serialResponse = HTTPResponse()
let serialReq = createRequest(url, method: method, parameters: parameters)
if let err = serialReq.error {
if let handler = completionHandler {
serialResponse.error = err
handler(serialResponse)
}
return nil
}
let opt = HTTPOperation()
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: config, delegate: self, delegateQueue: nil)
let task = session.dataTaskWithRequest(serialReq.request,
completionHandler: {(data: NSData!, response: NSURLResponse!, error: NSError!) -> Void in
if let handler = completionHandler {
if let hresponse = response as? NSHTTPURLResponse {
serialResponse.headers = hresponse.allHeaderFields as? Dictionary<String,String>
serialResponse.mimeType = hresponse.MIMEType
serialResponse.suggestedFilename = hresponse.suggestedFilename
serialResponse.statusCode = hresponse.statusCode
serialResponse.URL = hresponse.URL
}
serialResponse.error = error
if let d = data {
serialResponse.responseObject = d
if let resSerializer = self.responseSerializer {
let resObj = resSerializer.responseObjectFromResponse(response, data: d)
serialResponse.responseObject = resObj.object
serialResponse.error = resObj.error
}
if let code = serialResponse.statusCode where serialResponse.statusCode > 299 {
serialResponse.error = self.createError(code)
}
}
handler(serialResponse)
}
opt.finish()
})
opt.task = task
return opt
}
/**
Creates a HTTPOperation as a HTTP GET request and starts it for you.
:param: url The url you would like to make a request to.
:param: parameters The parameters are HTTP parameters you would like to send.
:param: completionHandler The closure that is run when a HTTP Request finished.
*/
public func GET(url: String, parameters: Dictionary<String,AnyObject>?, completionHandler:((HTTPResponse) -> Void)!) {
if let opt = self.create(url, method:.GET, parameters: parameters,completionHandler: completionHandler) {
opt.start()
}
}
/**
Creates a HTTPOperation as a HTTP POST request and starts it for you.
:param: url The url you would like to make a request to.
:param: parameters The parameters are HTTP parameters you would like to send.
:param: completionHandler The closure that is run when a HTTP Request finished.
*/
public func POST(url: String, parameters: Dictionary<String,AnyObject>?, completionHandler:((HTTPResponse) -> Void)!) {
if let opt = self.create(url, method:.POST, parameters: parameters,completionHandler: completionHandler) {
opt.start()
}
}
/**
Creates a HTTPOperation as a HTTP PATCH request and starts it for you.
:param: url The url you would like to make a request to.
:param: parameters The parameters are HTTP parameters you would like to send.
:param: completionHandler The closure that is run when a HTTP Request finished.
*/
public func PATCH(url: String, parameters: Dictionary<String,AnyObject>?, completionHandler:((HTTPResponse) -> Void)!) {
if let opt = self.create(url, method:.PATCH, parameters: parameters,completionHandler: completionHandler) {
opt.start()
}
}
/**
Creates a HTTPOperation as a HTTP PUT request and starts it for you.
:param: url The url you would like to make a request to.
:param: parameters The parameters are HTTP parameters you would like to send.
:param: completionHandler The closure that is run when a HTTP Request finished.
*/
public func PUT(url: String, parameters: Dictionary<String,AnyObject>?, completionHandler:((HTTPResponse) -> Void)!) {
if let opt = self.create(url, method:.PUT, parameters: parameters,completionHandler: completionHandler) {
opt.start()
}
}
/**
Creates a HTTPOperation as a HTTP DELETE request and starts it for you.
:param: url The url you would like to make a request to.
:param: parameters The parameters are HTTP parameters you would like to send.
:param: completionHandler The closure that is run when a HTTP Request finished.
*/
public func DELETE(url: String, parameters: Dictionary<String,AnyObject>?, completionHandler:((HTTPResponse) -> Void)!) {
if let opt = self.create(url, method:.DELETE, parameters: parameters,completionHandler: completionHandler) {
opt.start()
}
}
/**
Creates a HTTPOperation as a HTTP HEAD request and starts it for you.
:param: url The url you would like to make a request to.
:param: parameters The parameters are HTTP parameters you would like to send.
:param: completionHandler The closure that is run when a HTTP Request finished.
*/
public func HEAD(url: String, parameters: Dictionary<String,AnyObject>?, completionHandler:((HTTPResponse) -> Void)!) {
if let opt = self.create(url, method:.HEAD, parameters: parameters,completionHandler: completionHandler) {
opt.start()
}
}
/**
Creates and starts a HTTPOperation to download a file in the background.
:param: url The url you would like to make a request to.
:param: method The HTTP method you want to use. Default is GET.
:param: parameters The parameters are HTTP parameters you would like to send.
:param: progress The progress returned in the progress closure is between 0 and 1.
:param: completionHandler The closure that is run when the HTTP Request finishes. The HTTPResponse responseObject object will be a fileURL. You MUST copy the fileURL return in HTTPResponse.responseObject to a new location before using it (e.g. your documents directory).
*/
public func download(url: String, method: HTTPMethod = .GET, parameters: Dictionary<String,AnyObject>?,progress:((Double) -> Void)!, completionHandler:((HTTPResponse) -> Void)!) -> NSURLSessionDownloadTask? {
let serialReq = createRequest(url,method: method, parameters: parameters)
if let err = serialReq.error {
if let handler = completionHandler {
var res = HTTPResponse()
res.error = err
handler(res)
}
return nil
}
let ident = createBackgroundIdent()
let config = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier(ident)
let session = NSURLSession(configuration: config, delegate: self, delegateQueue: nil)
let task = session.downloadTaskWithRequest(serialReq.request)
backgroundTaskMap[ident] = BackgroundBlocks(completionHandler,progress)
//this does not have to be queueable as Apple's background dameon *should* handle that.
task.resume()
return task
}
/**
Creates and starts a HTTPOperation to upload a file in the background.
:param: url The url you would like to make a request to.
:param: method The HTTP method you want to use. Default is POST.
:param: parameters The parameters are HTTP parameters you would like to send.
:param: progress The progress returned in the progress closure is between 0 and 1.
:param: completionHandler The closure that is run when a HTTP Request finished.
*/
public func upload(url: String, method: HTTPMethod = .POST, parameters: Dictionary<String,AnyObject>?,progress:((Double) -> Void)!, completionHandler:((HTTPResponse) -> Void)!) -> NSURLSessionTask? {
let serialReq = createRequest(url,method: method, parameters: parameters)
if let err = serialReq.error {
if let handler = completionHandler {
var res = HTTPResponse()
res.error = err
handler(res)
}
return nil
}
let ident = createBackgroundIdent()
let config = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier(ident)
let session = NSURLSession(configuration: config, delegate: self, delegateQueue: nil)
let task = session.uploadTaskWithStreamedRequest(serialReq.request)
backgroundTaskMap[ident] = BackgroundBlocks(completionHandler,progress)
task.resume()
return task
}
//MARK: Private Helper Methods
/**
Creates and starts a HTTPOperation to download a file in the background.
:param: url The url you would like to make a request to.
:param: method The HTTP method/verb for the request.
:param: parameters The parameters are HTTP parameters you would like to send.
:returns: A NSURLRequest from configured requestSerializer.
*/
private func createRequest(url: String, method: HTTPMethod, parameters: Dictionary<String,AnyObject>!) -> (request: NSURLRequest, error: NSError?) {
var urlVal = url
//probably should change the 'http' to something more generic
if !url.hasPrefix("http") && self.baseURL != nil {
var split = url.hasPrefix("/") ? "" : "/"
urlVal = "\(self.baseURL!)\(split)\(url)"
}
if let u = NSURL(string: urlVal) {
return self.requestSerializer.createRequest(u, method: method, parameters: parameters)
}
return (NSURLRequest(),createError(-1001))
}
/**
Creates a random string to use for the identifier of the background download/upload requests.
:returns: Identifier String.
*/
private func createBackgroundIdent() -> String {
let letters = "abcdefghijklmnopqurstuvwxyz"
var str = ""
for var i = 0; i < 14; i++ {
let start = Int(arc4random() % 14)
str.append(letters[advance(letters.startIndex,start)])
}
return "com.vluxe.swifthttp.request.\(str)"
}
/**
Creates a random string to use for the identifier of the background download/upload requests.
:param: code Code for error.
:returns: An NSError.
*/
private func createError(code: Int) -> NSError {
var text = "An error occured"
if code == 404 {
text = "Page not found"
} else if code == 401 {
text = "Access denied"
} else if code == -1001 {
text = "Invalid URL"
}
return NSError(domain: "HTTPTask", code: code, userInfo: [NSLocalizedDescriptionKey: text])
}
/**
Creates a random string to use for the identifier of the background download/upload requests.
:param: identifier The identifier string.
:returns: An NSError.
*/
private func cleanupBackground(identifier: String) {
backgroundTaskMap.removeValueForKey(identifier)
}
//MARK: NSURLSession Delegate Methods
/// Method for authentication challenge.
public func URLSession(session: NSURLSession, task: NSURLSessionTask, didReceiveChallenge challenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential!) -> Void) {
if let sec = security where challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
let space = challenge.protectionSpace
if let trust = space.serverTrust {
if sec.isValid(trust, domain: space.host) {
completionHandler(.UseCredential, NSURLCredential(trust: trust))
return
}
}
completionHandler(.CancelAuthenticationChallenge, nil)
return
} else if let a = auth {
let cred = a(challenge)
if let c = cred {
completionHandler(.UseCredential, c)
return
}
completionHandler(.RejectProtectionSpace, nil)
return
}
completionHandler(.PerformDefaultHandling, nil)
}
//MARK: Methods for background download/upload
///update the download/upload progress closure
func handleProgress(session: NSURLSession, totalBytesExpected: Int64, currentBytes: Int64) {
if session.configuration.valueForKey("identifier") != nil { //temp workaround for radar: 21097168
let increment = 100.0/Double(totalBytesExpected)
var current = (increment*Double(currentBytes))*0.01
if current > 1 {
current = 1;
}
if let blocks = backgroundTaskMap[session.configuration.identifier] {
if blocks.progress != nil {
blocks.progress!(current)
}
}
}
}
//call the completionHandler closure for upload/download requests
func handleFinish(session: NSURLSession, task: NSURLSessionTask, response: AnyObject) {
if session.configuration.valueForKey("identifier") != nil { //temp workaround for radar: 21097168
if let blocks = backgroundTaskMap[session.configuration.identifier] {
if let handler = blocks.completionHandler {
var resp = HTTPResponse()
if let hresponse = task.response as? NSHTTPURLResponse {
resp.headers = hresponse.allHeaderFields as? Dictionary<String,String>
resp.mimeType = hresponse.MIMEType
resp.suggestedFilename = hresponse.suggestedFilename
resp.statusCode = hresponse.statusCode
resp.URL = hresponse.URL
}
resp.responseObject = response
if let code = resp.statusCode where resp.statusCode > 299 {
resp.error = self.createError(code)
}
handler(resp)
}
}
cleanupBackground(session.configuration.identifier)
}
}
/// Called when the background task failed.
public func URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError error: NSError?) {
if let err = error {
if session.configuration.valueForKey("identifier") != nil { //temp workaround for radar: 21097168
if let blocks = backgroundTaskMap[session.configuration.identifier] {
if let handler = blocks.completionHandler {
var res = HTTPResponse()
res.error = err
handler(res)
}
}
cleanupBackground(session.configuration.identifier)
}
}
}
/// The background download finished and reports the url the data was saved to.
func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location: NSURL!) {
handleFinish(session, task: downloadTask, response: location)
}
/// Will report progress of background download
func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
handleProgress(session, totalBytesExpected: totalBytesExpectedToWrite, currentBytes:totalBytesWritten)
}
/// The background download finished, don't have to really do anything.
public func URLSessionDidFinishEventsForBackgroundURLSession(session: NSURLSession) {
}
/// The background upload finished and reports the response.
func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveData data: NSData!) {
handleFinish(session, task: dataTask, response: data)
}
///Will report progress of background upload
public func URLSession(session: NSURLSession, task: NSURLSessionTask, didSendBodyData bytesSent: Int64, totalBytesSent: Int64, totalBytesExpectedToSend: Int64) {
handleProgress(session, totalBytesExpected: totalBytesExpectedToSend, currentBytes:totalBytesSent)
}
//implement if we want to support partial file upload/download
func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didResumeAtOffset fileOffset: Int64, expectedTotalBytes: Int64) {
}
}

View File

@ -0,0 +1,81 @@
//////////////////////////////////////////////////////////////////////////////////////////////////
//
// HTTPUpload.swift
//
// Created by Dalton Cherry on 6/5/14.
// Copyright (c) 2014 Vluxe. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////////////////////////
import Foundation
#if os(iOS)
import MobileCoreServices
#endif
/// Object representation of a HTTP File Upload.
public class HTTPUpload: NSObject {
var fileUrl: NSURL? {
didSet {
updateMimeType()
loadData()
}
}
var mimeType: String?
var data: NSData?
var fileName: String?
/// Tries to determine the mime type from the fileUrl extension.
func updateMimeType() {
if mimeType == nil && fileUrl != nil {
var UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileUrl?.pathExtension as NSString?, nil);
var str = UTTypeCopyPreferredTagWithClass(UTI.takeUnretainedValue(), kUTTagClassMIMEType);
if (str == nil) {
mimeType = "application/octet-stream";
} else {
mimeType = str.takeUnretainedValue() as String
}
}
}
/// loads the fileUrl into memory.
func loadData() {
if let url = fileUrl {
self.fileName = url.lastPathComponent
self.data = NSData(contentsOfURL: url, options: NSDataReadingOptions.DataReadingMappedIfSafe, error: nil)
}
}
/// Initializes a new HTTPUpload Object.
public override init() {
super.init()
}
/**
Initializes a new HTTPUpload Object with a fileUrl. The fileName and mimeType will be infered.
:param: fileUrl The fileUrl is a standard url path to a file.
*/
public convenience init(fileUrl: NSURL) {
self.init()
self.fileUrl = fileUrl
updateMimeType()
loadData()
}
/**
Initializes a new HTTPUpload Object with a data blob of a file. The fileName and mimeType will be infered if none are provided.
:param: data The data is a NSData representation of a file's data.
:param: fileName The fileName is just that. The file's name.
:param: mimeType The mimeType is just that. The mime type you would like the file to uploaded as.
*/
///upload a file from a a data blob. Must add a filename and mimeType as that can't be infered from the data
public convenience init(data: NSData, fileName: String, mimeType: String) {
self.init()
self.data = data
self.fileName = fileName
self.mimeType = mimeType
}
}

201
ipbc-Client/Pods/SwiftHTTP/LICENSE generated Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

481
ipbc-Client/Pods/SwiftHTTP/README.md generated Normal file
View File

@ -0,0 +1,481 @@
SwiftHTTP
=========
SwiftHTTP is a thin wrapper around NSURLSession in Swift to simplify HTTP requests.
## Features
- Convenient Closure APIs
- NSOperationQueue Support
- Parameter Encoding
- Custom Response Serializer
- Builtin JSON Response Serialization
- Upload/Download with Progress Closure
- Concise Codebase. Under 1000 LOC
Full article here: [http://vluxe.io/swifthttp.html](http://vluxe.io/swifthttp.html)
First thing is to import the framework. See the Installation instructions on how to add the framework to your project.
```swift
import SwiftHTTP
```
## Examples
### GET
The most basic request. By default an NSData object will be returned for the response.
```swift
var request = HTTPTask()
request.GET("http://vluxe.io", parameters: nil, completionHandler: {(response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
if let data = response.responseObject as? NSData {
let str = NSString(data: data, encoding: NSUTF8StringEncoding)
println("response: \(str)") //prints the HTML of the page
}
})
```
We can also add parameters as with standard container objects and they will be properly serialized to their respective HTTP equivalent.
```swift
var request = HTTPTask()
request.GET("http://google.com", parameters: ["param": "param1", "array": ["first array element","second","third"], "num": 23], completionHandler: {(response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
if let res: AnyObject = response.responseObject {
println("response: \(res)")
}
})
```
The `HTTPResponse` contains all the common HTTP response data, such as the responseObject of the data and the headers of the response.
### POST
A POST request is just as easy as a GET.
```swift
var request = HTTPTask()
//we have to add the explicit type, else the wrong type is inferred. See the vluxe.io article for more info.
let params: Dictionary<String,AnyObject> = ["param": "param1", "array": ["first array element","second","third"], "num": 23, "dict": ["someKey": "someVal"]]
request.POST("http://domain.com/create", parameters: params, completionHandler: {(response: HTTPResponse) in
//do things...
})
```
### PUT
PUT works the same as post. The example also include a file upload to do a multi form request.
```swift
let fileUrl = NSURL.fileURLWithPath("/Users/dalton/Desktop/file")!
var request = HTTPTask()
request.PUT("http://domain.com/1", parameters: ["param": "hi", "something": "else", "key": "value","file": HTTPUpload(fileUrl: fileUrl)], completionHandler: {(response: HTTPResponse) in
//do stuff
})
```
The HTTPUpload object is use to represent files on disk or in memory file as data.
### DELETE
DELETE works the same as the GET.
```swift
var request = HTTPTask()
request.DELETE("http://domain.com/1", parameters: nil, completionHandler: {(response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
println("DELETE was successful!")
})
```
### HEAD
HEAD works the same as the GET.
```swift
var request = HTTPTask()
request.HEAD("http://domain.com/image.png", parameters: nil, completionHandler: {(response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
println("The file does exist!")
})
```
### Download
The download method uses the background download functionality of NSURLSession. It also has a progress closure to report the progress of the download.
```swift
var request = HTTPTask()
let downloadTask = request.download("http://vluxe.io/assets/images/logo.png", parameters: nil, progress: {(complete: Double) in
println("percent complete: \(complete)")
}, completionHandler: {(response: HTTPResponse) in
println("download finished!")
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
if let url = response.responseObject as? NSURL {
//we MUST copy the file from its temp location to a permanent location.
if let path = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first as? String {
if let fileName = response.suggestedFilename {
if let newPath = NSURL(fileURLWithPath: "\(path)/\(fileName)") {
let fileManager = NSFileManager.defaultManager()
fileManager.removeItemAtURL(newPath, error: nil)
fileManager.moveItemAtURL(url, toURL: newPath, error:nil)
}
}
}
}
})
```
Cancel the download.
```swift
if let t = downloadTask {
t.cancel()
}
```
### Upload
File uploads can be done using the `HTTPUpload` object. All files to upload should be wrapped in a HTTPUpload object and added as a parameter.
```swift
let task = HTTPTask()
var fileUrl = NSURL(fileURLWithPath: "/Users/dalton/Desktop/testfile")!
task.upload("http://domain.com/upload", method: .POST, parameters: ["aParam": "aValue", "file": HTTPUpload(fileUrl: fileUrl)], progress: { (value: Double) in
println("progress: \(value)")
}, completionHandler: { (response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
if let data = response.responseObject as? NSData {
let str = NSString(data: data, encoding: NSUTF8StringEncoding)
println("response: \(str!)") //prints the response
}
})
```
`HTTPUpload` comes in both a on disk fileUrl version and a NSData version.
### Custom Headers
Custom HTTP headers can be add to a request via the requestSerializer.
```swift
var request = HTTPTask()
request.requestSerializer = HTTPRequestSerializer()
request.requestSerializer.headers["someKey"] = "SomeValue" //example of adding a header value
```
### SSL Pinning
SSL Pinning is also supported in SwiftHTTP.
```swift
let task = HTTPTask()
let data = ... //load your certificate from disk
task.security = HTTPSecurity(certs: [HTTPSSLCert(data: data)], usePublicKeys: true)
//task.security = HTTPSecurity() //uses the .cer files in your app's bundle
request.GET("http://yourdomain.com", parameters: nil, completionHandler: {(response: HTTPResponse) in
//handle response
})
```
You load either a `NSData` blob of your certificate or you can use a `SecKeyRef` if you have a public key you want to use. The `usePublicKeys` bool is whether to use the certificates for validation or the public keys. The public keys will be extracted from the certificates automatically if `usePublicKeys` is choosen.
### Authentication
SwiftHTTP supports authentication through [NSURLCredential](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURLCredential_Class/Reference/Reference.html). Currently only Basic Auth and Digest Auth have been tested.
```swift
var request = HTTPTask()
//the auth closures will continually be called until a successful auth or rejection
var attempted = false
request.auth = {(challenge: NSURLAuthenticationChallenge) in
if !attempted {
attempted = true
return NSURLCredential(user: "user", password: "passwd", persistence: .ForSession)
}
return nil //auth failed, nil causes the request to be properly cancelled.
}
request.GET("http://httpbin.org/basic-auth/user/passwd", parameters: nil, completionHandler: {(response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
println("winning!")
})
```
Allow all certificates example:
```swift
var request = HTTPTask()
var attempted = false
request.auth = {(challenge: NSURLAuthenticationChallenge) in
if !attempted {
attempted = true
return NSURLCredential(forTrust: challenge.protectionSpace.serverTrust)
}
return nil
}
request.GET("https://somedomain.com", parameters: nil, completionHandler: {(response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
println("winning!")
})
```
### BaseURL
SwiftHTTP also supports use a request object with a baseURL. This is super handy for RESTFul API interaction.
```swift
var request = HTTPTask()
request.baseURL = "http://api.someserver.com/1"
request.GET("/users", parameters: ["key": "value"], completionHandler: {(response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
println("Got data from http://api.someserver.com/1/users")
})
request.POST("/users", parameters: ["key": "updatedVale"], completionHandler: {(response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
println("Got data from http://api.someserver.com/1/users")
})
request.GET("/resources", parameters: ["key": "value"], completionHandler: {(response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
println("Got data from http://api.someserver.com/1/resources")
})
```
### Operation Queue
Operation queues are also supported in SwiftHTTP.
```swift
let operationQueue = NSOperationQueue()
operationQueue.maxConcurrentOperationCount = 2
var request = HTTPTask()
var opt = request.create("http://vluxe.io", method: .GET, parameters: nil, completionHandler: {(response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
if let data = response.responseObject as? NSData {
let str = NSString(data: data, encoding: NSUTF8StringEncoding)
println("response: \(str)") //prints the HTML of the page
}
})
if let o = opt {
operationQueue.addOperation(o)
}
```
### Cancel
Let's say you want to cancel this request a little later, simple use the operationQueue cancel.
```swift
if let o = opt {
o.cancel()
}
```
### Serializers
Request parameters and request responses can also be serialized as needed. By default request are serialized using standard HTTP form encoding. A JSON request and response serializer are provided as well. It is also very simple to create custom serializer by subclass a request or response serializer
```swift
var request = HTTPTask()
//The parameters will be encoding as JSON data and sent.
request.requestSerializer = JSONRequestSerializer()
//The expected response will be JSON and be converted to an object return by NSJSONSerialization instead of a NSData.
request.responseSerializer = JSONResponseSerializer()
request.GET("http://vluxe.io", parameters: nil, completionHandler: {(response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
if let dict = response.responseObject as? Dictionary<String,AnyObject> {
println("example of the JSON key: \(dict["key"])")
println("print the whole response: \(response)")
}
})
```
### UI Changes
All completionHandler closures return on a background thread. This allows any data parsing to be done without blocking the UI. To make update the UI, call `dispatch_async(dispatch_get_main_queue(),{...}`.
```swift
var request = HTTPTask()
request.GET("http://vluxe.io", parameters: nil, completionHandler: {(response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
if let data = response.responseObject as? NSData {
let str = NSString(data: data, encoding: NSUTF8StringEncoding)
println("response: \(str)") //prints the HTML of the page
dispatch_async(dispatch_get_main_queue(),{
self.label.text = str //update the label's text with the HTML content
})
}
})
```
## Client/Server Example
This is a full example swiftHTTP in action. First here is a quick web server in Go.
```go
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) {
log.Println("got a web request")
fmt.Println("header: ", r.Header.Get("someKey"))
w.Write([]byte("{\"status\": \"ok\"}"))
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
```
Now for the request:
```swift
//The object that will represent our response. More Info in the JSON Parsing section below.
struct Status : JSONJoy {
var status: String?
init() {
}
init(_ decoder: JSONDecoder) {
status = decoder["status"].string
}
}
//The request
var request = HTTPTask()
request.requestSerializer = HTTPRequestSerializer()
request.requestSerializer.headers["someKey"] = "SomeValue" //example of adding a header value
request.responseSerializer = JSONResponseSerializer()
request.GET("http://localhost:8080/bar", parameters: nil, completionHandler: {(response: HTTPResponse) in
if let err = response.error {
println("error: \(err.localizedDescription)")
return //also notify app of failure as needed
}
if let obj: AnyObject = response.responseObject {
let resp = Status(JSONDecoder(obj))
println("status is: \(resp.status)")
}
})
```
## JSON Parsing
Swift has a lot of great JSON parsing libraries, but I made one specifically designed for JSON to object serialization.
[JSONJoy-Swift](https://github.com/daltoniam/JSONJoy-Swift)
## Requirements
SwiftHTTP works with iOS 7/OSX 10.9 or above. It is recommended to use iOS 8/10.10 or above for Cocoapods/framework support.
## Installation
### Cocoapods
Check out [Get Started](http://cocoapods.org/) tab on [cocoapods.org](http://cocoapods.org/).
To use SwiftHTTP in your project add the following 'Podfile' to your project
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'SwiftHTTP', '~> 0.9.4'
Then run:
pod install
### Carthage
Check out the [Carthage](https://github.com/Carthage/Carthage) docs on how to add a install. The `SwiftHTTP` framework is already setup with shared schemes.
[Carthage Install](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application)
### Rogue
First see the [installation docs](https://github.com/acmacalister/Rogue) for how to install Rogue.
To install SwiftLog run the command below in the directory you created the rogue file.
```
rogue add https://github.com/daltoniam/SwiftHTTP
```
Next open the `libs` folder and add the `SwiftHTTP.xcodeproj` to your Xcode project. Once that is complete, in your "Build Phases" add the `SwiftHTTP.framework` to your "Link Binary with Libraries" phase. Make sure to add the `libs` folder to your `.gitignore` file.
### Other
Simply grab the framework (either via git submodule or another package manager).
Add the `SwiftHTTP.xcodeproj` to your Xcode project. Once that is complete, in your "Build Phases" add the `SwiftHTTP.framework` to your "Link Binary with Libraries" phase.
### Add Copy Frameworks Phase
If you are running this in an OSX app or on a physical iOS device you will need to make sure you add the `SwiftHTTP.framework` included in your app bundle. To do this, in Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar. In the tab bar at the top of that window, open the "Build Phases" panel. Expand the "Link Binary with Libraries" group, and add `SwiftHTTP.framework`. Click on the + button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add `SwiftHTTP.framework`.
## TODOs
- [ ] Add more unit tests
## License
SwiftHTTP is licensed under the Apache v2 License.
## Contact
### Dalton Cherry
* https://github.com/daltoniam
* http://twitter.com/daltoniam
* http://daltoniam.com

View File

@ -0,0 +1,26 @@
<?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>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -0,0 +1,232 @@
# Acknowledgements
This application makes use of the following third party libraries:
## ReachabilitySwift
/*
Copyright (c) 2014, Ashley Mills
All rights reserved.
Redistribution and use in source, with or without modification, is permitted provided that the following condition is met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
## SwiftHTTP
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Generated by CocoaPods - http://cocoapods.org

View File

@ -0,0 +1,266 @@
<?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>PreferenceSpecifiers</key>
<array>
<dict>
<key>FooterText</key>
<string>This application makes use of the following third party libraries:</string>
<key>Title</key>
<string>Acknowledgements</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>/*
Copyright (c) 2014, Ashley Mills
All rights reserved.
Redistribution and use in source, with or without modification, is permitted provided that the following condition is met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
</string>
<key>Title</key>
<string>ReachabilitySwift</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</string>
<key>Title</key>
<string>SwiftHTTP</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Generated by CocoaPods - http://cocoapods.org</string>
<key>Title</key>
<string></string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
</array>
<key>StringsTable</key>
<string>Acknowledgements</string>
<key>Title</key>
<string>Acknowledgements</string>
</dict>
</plist>

View File

@ -0,0 +1,5 @@
#import <Foundation/Foundation.h>
@interface PodsDummy_Pods : NSObject
@end
@implementation PodsDummy_Pods
@end

View File

@ -0,0 +1,61 @@
#!/bin/sh
set -e
echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
install_framework()
{
if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
local source="${BUILT_PRODUCTS_DIR}/$1"
else
local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
fi
local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
if [ -L "${source}" ]; then
echo "Symlinked..."
source="$(readlink "${source}")"
fi
# use filter instead of exclude so missing patterns dont' throw errors
echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
# Resign the code if required by the build settings to avoid unstable apps
code_sign_if_enabled "${destination}/$(basename "$1")"
# Embed linked Swift runtime libraries
local basename
basename="$(basename "$1" | sed -E s/\\..+// && exit ${PIPESTATUS[0]})"
local swift_runtime_libs
swift_runtime_libs=$(xcrun otool -LX "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/${basename}.framework/${basename}" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
for lib in $swift_runtime_libs; do
echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
code_sign_if_enabled "${destination}/${lib}"
done
}
# Signs a framework with the provided identity
code_sign_if_enabled() {
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
# Use the current code_sign_identitiy
echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\""
/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1"
fi
}
if [[ "$CONFIGURATION" == "Debug" ]]; then
install_framework 'Pods/ReachabilitySwift.framework'
install_framework 'Pods/SwiftHTTP.framework'
fi
if [[ "$CONFIGURATION" == "Release" ]]; then
install_framework 'Pods/ReachabilitySwift.framework'
install_framework 'Pods/SwiftHTTP.framework'
fi

View File

@ -0,0 +1,95 @@
#!/bin/sh
set -e
mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
> "$RESOURCES_TO_COPY"
XCASSET_FILES=()
realpath() {
DIRECTORY="$(cd "${1%/*}" && pwd)"
FILENAME="${1##*/}"
echo "$DIRECTORY/$FILENAME"
}
install_resource()
{
case $1 in
*.storyboard)
echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
;;
*.xib)
echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
;;
*.framework)
echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
;;
*.xcdatamodel)
echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\""
xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom"
;;
*.xcdatamodeld)
echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\""
xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd"
;;
*.xcmappingmodel)
echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\""
xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm"
;;
*.xcassets)
ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1")
XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
;;
/*)
echo "$1"
echo "$1" >> "$RESOURCES_TO_COPY"
;;
*)
echo "${PODS_ROOT}/$1"
echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY"
;;
esac
}
mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
if [[ "${ACTION}" == "install" ]]; then
mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
fi
rm -f "$RESOURCES_TO_COPY"
if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
then
case "${TARGETED_DEVICE_FAMILY}" in
1,2)
TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
;;
1)
TARGET_DEVICE_ARGS="--target-device iphone"
;;
2)
TARGET_DEVICE_ARGS="--target-device ipad"
;;
*)
TARGET_DEVICE_ARGS="--target-device mac"
;;
esac
# Find all other xcassets (this unfortunately includes those of path pods and other targets).
OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
while read line; do
if [[ $line != "`realpath $PODS_ROOT`*" ]]; then
XCASSET_FILES+=("$line")
fi
done <<<"$OTHER_XCASSETS"
printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
fi

View File

@ -0,0 +1,6 @@
#import <Cocoa/Cocoa.h>
FOUNDATION_EXPORT double PodsVersionNumber;
FOUNDATION_EXPORT const unsigned char PodsVersionString[];

View File

@ -0,0 +1,8 @@
CODE_SIGN_IDENTITY =
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks'
OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/ReachabilitySwift.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/SwiftHTTP.framework/Headers"
OTHER_LDFLAGS = $(inherited) -framework "ReachabilitySwift" -framework "SwiftHTTP"
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods
PODS_ROOT = ${SRCROOT}/Pods

View File

@ -0,0 +1,6 @@
framework module Pods {
umbrella header "Pods-umbrella.h"
export *
module * { export * }
}

View File

@ -0,0 +1,8 @@
CODE_SIGN_IDENTITY =
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks'
OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/ReachabilitySwift.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/SwiftHTTP.framework/Headers"
OTHER_LDFLAGS = $(inherited) -framework "ReachabilitySwift" -framework "SwiftHTTP"
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods
PODS_ROOT = ${SRCROOT}/Pods

View File

@ -0,0 +1,26 @@
<?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>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -0,0 +1,8 @@
#include "ReachabilitySwift.xcconfig"
CODE_SIGN_IDENTITY =
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/ReachabilitySwift" "${PODS_ROOT}/Headers/Public"
OTHER_LDFLAGS = ${REACHABILITYSWIFT_OTHER_LDFLAGS}
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
PODS_ROOT = ${SRCROOT}
SKIP_INSTALL = YES

View File

@ -0,0 +1,5 @@
#import <Foundation/Foundation.h>
@interface PodsDummy_ReachabilitySwift : NSObject
@end
@implementation PodsDummy_ReachabilitySwift
@end

View File

@ -0,0 +1,4 @@
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif

View File

@ -0,0 +1,6 @@
#import <Cocoa/Cocoa.h>
FOUNDATION_EXPORT double ReachabilitySwiftVersionNumber;
FOUNDATION_EXPORT const unsigned char ReachabilitySwiftVersionString[];

View File

@ -0,0 +1,6 @@
framework module ReachabilitySwift {
umbrella header "ReachabilitySwift-umbrella.h"
export *
module * { export * }
}

View File

@ -0,0 +1 @@
REACHABILITYSWIFT_OTHER_LDFLAGS = -framework "SystemConfiguration"

View File

@ -0,0 +1,26 @@
<?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>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.9.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -0,0 +1,7 @@
#include "SwiftHTTP.xcconfig"
CODE_SIGN_IDENTITY =
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/SwiftHTTP" "${PODS_ROOT}/Headers/Public"
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
PODS_ROOT = ${SRCROOT}
SKIP_INSTALL = YES

View File

@ -0,0 +1,5 @@
#import <Foundation/Foundation.h>
@interface PodsDummy_SwiftHTTP : NSObject
@end
@implementation PodsDummy_SwiftHTTP
@end

View File

@ -0,0 +1,4 @@
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif

View File

@ -0,0 +1,6 @@
#import <Cocoa/Cocoa.h>
FOUNDATION_EXPORT double SwiftHTTPVersionNumber;
FOUNDATION_EXPORT const unsigned char SwiftHTTPVersionString[];

View File

@ -0,0 +1,6 @@
framework module SwiftHTTP {
umbrella header "SwiftHTTP-umbrella.h"
export *
module * { export * }
}

View File

@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
EC35AC5C1BA21DBA0004A674 /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 377F6D84A86891A23192799E /* Pods.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
ECEBE1881BA0639500E5B4E3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECEBE1871BA0639500E5B4E3 /* AppDelegate.swift */; };
ECEBE18A1BA0639500E5B4E3 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ECEBE1891BA0639500E5B4E3 /* Images.xcassets */; };
ECEBE18D1BA0639500E5B4E3 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = ECEBE18B1BA0639500E5B4E3 /* MainMenu.xib */; };
@ -15,7 +16,7 @@
ECEBE1A51BA0690B00E5B4E3 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = ECEBE1A31BA0690B00E5B4E3 /* MainViewController.xib */; };
ECEBE1A91BA0752600E5B4E3 /* EventMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECEBE1A81BA0752600E5B4E3 /* EventMonitor.swift */; };
ECEBE1AB1BA07DD600E5B4E3 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECEBE1AA1BA07DD600E5B4E3 /* Constants.swift */; };
ECEBE1AE1BA0C61100E5B4E3 /* WebserviceClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECEBE1AD1BA0C61100E5B4E3 /* WebserviceClient.swift */; };
ECEBE1AE1BA0C61100E5B4E3 /* WebServiceClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECEBE1AD1BA0C61100E5B4E3 /* WebServiceClient.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -29,6 +30,10 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
377F6D84A86891A23192799E /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A19807A65D3C20CCE59EA8E6 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
C764B4C0152B1E545800FE11 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
EC35AC5D1BA21DCA0004A674 /* ReachabilitySwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ReachabilitySwift.framework; path = "../../../../../Library/Developer/Xcode/DerivedData/ipbc-Client-argtkatyahvadigrkkcbybepzqgl/Build/Products/Debug/ReachabilitySwift.framework"; sourceTree = "<group>"; };
ECEBE1821BA0639500E5B4E3 /* ipbc-Client.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ipbc-Client.app"; sourceTree = BUILT_PRODUCTS_DIR; };
ECEBE1861BA0639500E5B4E3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
ECEBE1871BA0639500E5B4E3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@ -41,7 +46,7 @@
ECEBE1A31BA0690B00E5B4E3 /* MainViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = MainViewController.xib; path = Controller/MainViewController.xib; sourceTree = "<group>"; };
ECEBE1A81BA0752600E5B4E3 /* EventMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventMonitor.swift; sourceTree = "<group>"; };
ECEBE1AA1BA07DD600E5B4E3 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
ECEBE1AD1BA0C61100E5B4E3 /* WebserviceClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebserviceClient.swift; sourceTree = "<group>"; };
ECEBE1AD1BA0C61100E5B4E3 /* WebServiceClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebServiceClient.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -49,6 +54,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
EC35AC5C1BA21DBA0004A674 /* Pods.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -62,12 +68,39 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
2045583E351F966687B248C1 /* Pods */ = {
isa = PBXGroup;
children = (
C764B4C0152B1E545800FE11 /* Pods.debug.xcconfig */,
A19807A65D3C20CCE59EA8E6 /* Pods.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
43F7A99EEE02196803254D88 /* Frameworks */ = {
isa = PBXGroup;
children = (
EC35AC5D1BA21DCA0004A674 /* ReachabilitySwift.framework */,
377F6D84A86891A23192799E /* Pods.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
EC35AC591BA21B9A0004A674 /* third-party */ = {
isa = PBXGroup;
children = (
);
name = "third-party";
sourceTree = "<group>";
};
ECEBE1791BA0639500E5B4E3 = {
isa = PBXGroup;
children = (
ECEBE1841BA0639500E5B4E3 /* ipbc-Client */,
ECEBE1951BA0639500E5B4E3 /* ipbc-ClientTests */,
ECEBE1831BA0639500E5B4E3 /* Products */,
2045583E351F966687B248C1 /* Pods */,
43F7A99EEE02196803254D88 /* Frameworks */,
);
sourceTree = "<group>";
};
@ -83,7 +116,8 @@
ECEBE1841BA0639500E5B4E3 /* ipbc-Client */ = {
isa = PBXGroup;
children = (
ECEBE1AC1BA0C60000E5B4E3 /* WebService */,
EC35AC591BA21B9A0004A674 /* third-party */,
ECEBE1AC1BA0C60000E5B4E3 /* webservice */,
ECEBE1A71BA0693200E5B4E3 /* control */,
ECEBE1A61BA0692000E5B4E3 /* view */,
ECEBE1871BA0639500E5B4E3 /* AppDelegate.swift */,
@ -137,12 +171,12 @@
name = control;
sourceTree = "<group>";
};
ECEBE1AC1BA0C60000E5B4E3 /* WebService */ = {
ECEBE1AC1BA0C60000E5B4E3 /* webservice */ = {
isa = PBXGroup;
children = (
ECEBE1AD1BA0C61100E5B4E3 /* WebserviceClient.swift */,
ECEBE1AD1BA0C61100E5B4E3 /* WebServiceClient.swift */,
);
name = WebService;
name = webservice;
sourceTree = "<group>";
};
/* End PBXGroup section */
@ -152,9 +186,12 @@
isa = PBXNativeTarget;
buildConfigurationList = ECEBE19C1BA0639500E5B4E3 /* Build configuration list for PBXNativeTarget "ipbc-Client" */;
buildPhases = (
A2C554177912EB9B76B7CACB /* Check Pods Manifest.lock */,
ECEBE17E1BA0639500E5B4E3 /* Sources */,
ECEBE17F1BA0639500E5B4E3 /* Frameworks */,
ECEBE1801BA0639500E5B4E3 /* Resources */,
D5EB9AFFD16BAD1BD95C4255 /* Embed Pods Frameworks */,
E16403968E035DE6A349F77A /* Copy Pods Resources */,
);
buildRules = (
);
@ -240,13 +277,61 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
A2C554177912EB9B76B7CACB /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
D5EB9AFFD16BAD1BD95C4255 /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
E16403968E035DE6A349F77A /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
ECEBE17E1BA0639500E5B4E3 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
ECEBE1A91BA0752600E5B4E3 /* EventMonitor.swift in Sources */,
ECEBE1AE1BA0C61100E5B4E3 /* WebserviceClient.swift in Sources */,
ECEBE1AE1BA0C61100E5B4E3 /* WebServiceClient.swift in Sources */,
ECEBE1881BA0639500E5B4E3 /* AppDelegate.swift in Sources */,
ECEBE1A41BA0690B00E5B4E3 /* MainViewController.swift in Sources */,
ECEBE1AB1BA07DD600E5B4E3 /* Constants.swift in Sources */,
@ -365,9 +450,14 @@
};
ECEBE19D1BA0639500E5B4E3 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C764B4C0152B1E545800FE11 /* Pods.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/ipbc-Client-argtkatyahvadigrkkcbybepzqgl/Build/Products/Debug",
);
INFOPLIST_FILE = "ipbc-Client/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -376,9 +466,14 @@
};
ECEBE19E1BA0639500E5B4E3 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = A19807A65D3C20CCE59EA8E6 /* Pods.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/ipbc-Client-argtkatyahvadigrkkcbybepzqgl/Build/Products/Debug",
);
INFOPLIST_FILE = "ipbc-Client/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:ipbc-Client.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,41 @@
<?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>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>E2FF91C6-309C-4C78-ABB0-AD40A1BE29BC</string>
<key>IDESourceControlProjectName</key>
<string>ipbc-Client</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>41A46EC74341898613642098E6535621FD117950</key>
<string>ssh://services.adawim.com:7999/ipbc/statusbar-app-osx.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>ipbc-Client/ipbc-Client.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>41A46EC74341898613642098E6535621FD117950</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://services.adawim.com:7999/ipbc/statusbar-app-osx.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>41A46EC74341898613642098E6535621FD117950</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>41A46EC74341898613642098E6535621FD117950</string>
<key>IDESourceControlWCCName</key>
<string>ipbc-statusbarapp</string>
</dict>
</array>
</dict>
</plist>

View File

@ -0,0 +1,20 @@
<?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>BuildLocationStyle</key>
<string>UseAppPreferences</string>
<key>CustomBuildLocationType</key>
<string>RelativeToDerivedData</string>
<key>DerivedDataLocationStyle</key>
<string>Default</string>
<key>IssueFilterStyle</key>
<string>ShowActiveSchemeOnly</string>
<key>LiveSourceIssuesEnabled</key>
<true/>
<key>SnapshotAutomaticallyBeforeSignificantChanges</key>
<true/>
<key>SnapshotLocationStyle</key>
<string>Default</string>
</dict>
</plist>

View File

@ -20,6 +20,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(aNotification: NSNotification) {
// Insert code here to initialize your application
WebserviceClient.sharedInstance // to init
// Icon
if let button = statusItem.button {

View File

@ -22,5 +22,13 @@ struct Constants {
struct UserDefaults {
static let HOST = "USERDEFAULT_HOST"
static let TOKEN = "USERDEFAULT_TOKEN"
static let PERSIST_LAST_USERS_IP = "USERDEFAULT_PERSIST_LAST_USERS_IP"
}
struct Notification {
static let NF_NETWORK_AVAILABLE = "NOTIFICATION_NETWORK_AVAILABLE"
static let NF_NETWORK_NOT_AVAILABLE = "NOTIFICATION_NETWORK_NOT_AVAILABLE"
static let NF_IP_HAS_CHANGED = "NOTIFICATION_IP_HAS_CHANGED"
}
}

View File

@ -22,7 +22,11 @@ class MainViewController: NSViewController {
super.viewDidLoad()
// Do view setup here.
self.lblCurrentIP.stringValue = ""
NSNotificationCenter.defaultCenter().addObserver(self, selector: "observeUserIPHasChanged", name: Constants.Notification.NF_IP_HAS_CHANGED, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "observeNetworkAvailable", name: Constants.Notification.NF_NETWORK_AVAILABLE, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "observeNetworkNotAvailable", name: Constants.Notification.NF_NETWORK_NOT_AVAILABLE, object: nil)
self.lblCurrentIP.stringValue = NSUserDefaults.standardUserDefaults().stringForKey(Constants.UserDefaults.PERSIST_LAST_USERS_IP) ?? ""
let defaults = NSUserDefaults.standardUserDefaults()
if let udHost = defaults.stringForKey(Constants.UserDefaults.HOST) {
@ -31,6 +35,10 @@ class MainViewController: NSViewController {
if let udToken = defaults.stringForKey(Constants.UserDefaults.TOKEN) {
txtToken.stringValue = udToken
}
if !WebserviceClient.sharedInstance.checkNetwork() {
lblCurrentIP.stringValue = "No internet connection!"
}
}
// MARK: Actions
@ -49,4 +57,19 @@ class MainViewController: NSViewController {
defaults.setObject(txtName.stringValue, forKey: Constants.UserDefaults.HOST)
defaults.setObject(txtToken.stringValue, forKey: Constants.UserDefaults.TOKEN)
}
// MARK: Observer functions
func observeUserIPHasChanged() {
let newIP = NSUserDefaults.standardUserDefaults().stringForKey(Constants.UserDefaults.PERSIST_LAST_USERS_IP) ?? ""
lblCurrentIP.stringValue = newIP
}
func observeNetworkAvailable() {
observeUserIPHasChanged()
}
func observeNetworkNotAvailable() {
lblCurrentIP.stringValue = "Network not reachable."
}
}

View File

@ -68,8 +68,8 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xnC-6n-NBZ">
<rect key="frame" x="20" y="20" width="17" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="IP" id="GON-6q-6yN">
<rect key="frame" x="20" y="20" width="141" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="___.___.___.___" id="GON-6q-6yN">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>

View File

@ -0,0 +1,133 @@
//
// WebserviceClient.swift
// ipbc-Client
//
// Created by Gerrit Linnemann on 09.09.15.
// Copyright (c) 2015 Adawim UG (haftungsbeschränkt). All rights reserved.
//
import Foundation
import ReachabilitySwift
import SwiftHTTP
private let x_SomeManagerSharedInstance = WebserviceClient()
class WebserviceClient {
let reachability = Reachability.reachabilityForInternetConnection()
private var isNetworkAvailable : Bool = false
class var sharedInstance: WebserviceClient {
return x_SomeManagerSharedInstance
}
init() {
// init Reachability ...
let reachability = Reachability.reachabilityForInternetConnection()
self.isNetworkAvailable = reachability.isReachable()
reachability.whenReachable = { reachability in
if reachability.isReachableViaWiFi() {
println("WebserviceClient: Network reachable via WiFi")
self.isNetworkAvailable = true
} else {
println("WebserviceClient: Network reachable via Cellular")
self.isNetworkAvailable = true
}
self.detectIP()
NSNotificationCenter.defaultCenter().postNotificationName(Constants.Notification.NF_IP_HAS_CHANGED, object: nil)
}
reachability.whenUnreachable = { reachability in
println("WebserviceClient: Network not reachable")
self.isNetworkAvailable = false
NSNotificationCenter.defaultCenter().postNotificationName(Constants.Notification.NF_NETWORK_NOT_AVAILABLE, object: nil)
}
reachability.startNotifier()
// init IP things ...
self.detectIP() // initial call
// init timer ...
//var timerIPCheck = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("click"), userInfo: nil, repeats: true)
}
internal func checkNetwork() -> Bool {
return self.isNetworkAvailable
}
private func detectIP() {
if isNetworkAvailable {
var request = HTTPTask()
// we have to add the explicit type, else the wrong type is inferred. See the vluxe.io article for more info.
//let params: Dictionary<String,AnyObject> = ["param": "param1", "array": ["first array element","second","third"], "num": 23, "dict": ["someKey": "someVal"]]
request.GET(Constants.WebService.GET_USERS_IP, parameters: nil, completionHandler: {(response: HTTPResponse) in
if(response.statusCode == 200) {
let defaults = NSUserDefaults.standardUserDefaults()
let oldIP : String = defaults.stringForKey(Constants.UserDefaults.PERSIST_LAST_USERS_IP) ?? ""
defaults.setValue(response.text, forKey: Constants.UserDefaults.PERSIST_LAST_USERS_IP)
if oldIP != defaults.stringForKey(Constants.UserDefaults.PERSIST_LAST_USERS_IP) {
// IP has changed
let newIP : String = defaults.stringForKey(Constants.UserDefaults.PERSIST_LAST_USERS_IP) ?? "--"
println("WebserviceClient: new IP: \(newIP)")
NSNotificationCenter.defaultCenter().postNotificationName(Constants.Notification.NF_IP_HAS_CHANGED, object: newIP)
}
} else {
println("WebserviceClient: Error detecting users ip.")
if response.statusCode != nil {
println("\(response.statusCode): \(response.text)")
}
}
})
}
}
/*private func reachabilityChanged(note: NSNotification) {
let reachability = note.object as! Reachability
if reachability.isReachable() {
if reachability.isReachableViaWiFi() {
println("WebserviceClient: Reachable via WiFi")
} else {
println("WebserviceClient: Reachable via Cellular")
}
} else {
println("WebserviceClient: Network not reachable")
}
}*/
// MARK: Timer
func click() {
println("click")
}
// MARK: Getter
func getIP() -> String {
let defaults = NSUserDefaults.standardUserDefaults()
if let ip = defaults.stringForKey(Constants.UserDefaults.PERSIST_LAST_USERS_IP) {
return ip
} else {
return ""
}
}
func getIsNetworkAvailable() -> Bool {
return isNetworkAvailable
}
}

View File

@ -1,26 +0,0 @@
//
// WebserviceClient.swift
// ipbc-Client
//
// Created by Gerrit Linnemann on 09.09.15.
// Copyright (c) 2015 Adawim UG (haftungsbeschränkt). All rights reserved.
//
import Foundation
private let x_SomeManagerSharedInstance = WebserviceClient()
class WebserviceClient {
private var isNetworkAvailable : Bool = false
private var isRequestRunning : Bool = false
class var sharedInstance: WebserviceClient {
return x_SomeManagerSharedInstance
}
init() {
}
}