Skip to content

Commit b271160

Browse files
author
Gabe Shahbazian
committed
Add Xcode project and fix build
Add gitignore items for Xcode stuffs
1 parent 5c32dbc commit b271160

File tree

4 files changed

+285
-3
lines changed

4 files changed

+285
-3
lines changed

.gitignore

+19
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
11
.build
2+
3+
# Xcode
4+
.DS_Store
5+
*/build/*
6+
*.pbxuser
7+
!default.pbxuser
8+
*.mode1v3
9+
!default.mode1v3
10+
*.mode2v3
11+
!default.mode2v3
12+
*.perspectivev3
13+
!default.perspectivev3
14+
xcuserdata
15+
profile
16+
*.moved-aside
17+
DerivedData
18+
.idea/
19+
*.hmap
20+
*.xccheckout

Sources/http.swift

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#if os(Linux)
22
import Glibc
33
#else
4-
import Darwin.C
4+
import Darwin
55
#endif
66

77
public class HTTP {
@@ -20,16 +20,17 @@ public class HTTP {
2020
}
2121

2222
init(port: UInt16) {
23-
serverSocket = socket(AF_INET, Int32(SOCK_STREAM.rawValue), 0)
23+
serverSocket = socket(AF_INET, Int32(SOCK_STREAM), 0)
2424
if (serverSocket > 0) {
2525
print("Socket init: OK")
2626
}
2727

2828
serverAddress = sockaddr_in(
29+
sin_len: __uint8_t(sizeof(sockaddr_in)),
2930
sin_family: sa_family_t(AF_INET),
3031
sin_port: htons(port),
3132
sin_addr: in_addr(s_addr: in_addr_t(0)),
32-
sin_zero: (UInt8(0),UInt8(0),UInt8(0),UInt8(0),UInt8(0),UInt8(0),UInt8(0),UInt8(0))
33+
sin_zero: (0, 0, 0, 0, 0, 0, 0, 0)
3334
)
3435

3536
setsockopt(serverSocket, SOL_SOCKET, SO_RCVBUF, &bufferSize, socklen_t(sizeof(Int)))
@@ -39,6 +40,10 @@ public class HTTP {
3940
print("Server started at port \(port)")
4041
}
4142
}
43+
44+
func htons(value: CUnsignedShort) -> CUnsignedShort {
45+
return (value << 8) + (value >> 8);
46+
}
4247

4348
func start() {
4449
while (true) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 46;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
6C70CFBA1C1229890008EC56 /* http.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C70CFB81C1229890008EC56 /* http.swift */; };
11+
6C70CFBB1C1229890008EC56 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C70CFB91C1229890008EC56 /* main.swift */; };
12+
/* End PBXBuildFile section */
13+
14+
/* Begin PBXCopyFilesBuildPhase section */
15+
6C70CFAB1C1229640008EC56 /* CopyFiles */ = {
16+
isa = PBXCopyFilesBuildPhase;
17+
buildActionMask = 2147483647;
18+
dstPath = /usr/share/man/man1/;
19+
dstSubfolderSpec = 0;
20+
files = (
21+
);
22+
runOnlyForDeploymentPostprocessing = 1;
23+
};
24+
/* End PBXCopyFilesBuildPhase section */
25+
26+
/* Begin PBXFileReference section */
27+
6C70CFAD1C1229640008EC56 /* swift-http */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "swift-http"; sourceTree = BUILT_PRODUCTS_DIR; };
28+
6C70CFB81C1229890008EC56 /* http.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = http.swift; sourceTree = "<group>"; };
29+
6C70CFB91C1229890008EC56 /* main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
30+
/* End PBXFileReference section */
31+
32+
/* Begin PBXFrameworksBuildPhase section */
33+
6C70CFAA1C1229640008EC56 /* Frameworks */ = {
34+
isa = PBXFrameworksBuildPhase;
35+
buildActionMask = 2147483647;
36+
files = (
37+
);
38+
runOnlyForDeploymentPostprocessing = 0;
39+
};
40+
/* End PBXFrameworksBuildPhase section */
41+
42+
/* Begin PBXGroup section */
43+
6C70CFA41C1229640008EC56 = {
44+
isa = PBXGroup;
45+
children = (
46+
6C70CFB71C1229890008EC56 /* Sources */,
47+
6C70CFAE1C1229640008EC56 /* Products */,
48+
);
49+
sourceTree = "<group>";
50+
};
51+
6C70CFAE1C1229640008EC56 /* Products */ = {
52+
isa = PBXGroup;
53+
children = (
54+
6C70CFAD1C1229640008EC56 /* swift-http */,
55+
);
56+
name = Products;
57+
sourceTree = "<group>";
58+
};
59+
6C70CFB71C1229890008EC56 /* Sources */ = {
60+
isa = PBXGroup;
61+
children = (
62+
6C70CFB81C1229890008EC56 /* http.swift */,
63+
6C70CFB91C1229890008EC56 /* main.swift */,
64+
);
65+
name = Sources;
66+
path = ../Sources;
67+
sourceTree = "<group>";
68+
};
69+
/* End PBXGroup section */
70+
71+
/* Begin PBXNativeTarget section */
72+
6C70CFAC1C1229640008EC56 /* swift-http */ = {
73+
isa = PBXNativeTarget;
74+
buildConfigurationList = 6C70CFB41C1229640008EC56 /* Build configuration list for PBXNativeTarget "swift-http" */;
75+
buildPhases = (
76+
6C70CFA91C1229640008EC56 /* Sources */,
77+
6C70CFAA1C1229640008EC56 /* Frameworks */,
78+
6C70CFAB1C1229640008EC56 /* CopyFiles */,
79+
);
80+
buildRules = (
81+
);
82+
dependencies = (
83+
);
84+
name = "swift-http";
85+
productName = "swift-http";
86+
productReference = 6C70CFAD1C1229640008EC56 /* swift-http */;
87+
productType = "com.apple.product-type.tool";
88+
};
89+
/* End PBXNativeTarget section */
90+
91+
/* Begin PBXProject section */
92+
6C70CFA51C1229640008EC56 /* Project object */ = {
93+
isa = PBXProject;
94+
attributes = {
95+
LastSwiftUpdateCheck = 0710;
96+
LastUpgradeCheck = 0710;
97+
ORGANIZATIONNAME = "swift-http";
98+
TargetAttributes = {
99+
6C70CFAC1C1229640008EC56 = {
100+
CreatedOnToolsVersion = 7.1.1;
101+
};
102+
};
103+
};
104+
buildConfigurationList = 6C70CFA81C1229640008EC56 /* Build configuration list for PBXProject "swift-http" */;
105+
compatibilityVersion = "Xcode 3.2";
106+
developmentRegion = English;
107+
hasScannedForEncodings = 0;
108+
knownRegions = (
109+
en,
110+
);
111+
mainGroup = 6C70CFA41C1229640008EC56;
112+
productRefGroup = 6C70CFAE1C1229640008EC56 /* Products */;
113+
projectDirPath = "";
114+
projectRoot = "";
115+
targets = (
116+
6C70CFAC1C1229640008EC56 /* swift-http */,
117+
);
118+
};
119+
/* End PBXProject section */
120+
121+
/* Begin PBXSourcesBuildPhase section */
122+
6C70CFA91C1229640008EC56 /* Sources */ = {
123+
isa = PBXSourcesBuildPhase;
124+
buildActionMask = 2147483647;
125+
files = (
126+
6C70CFBB1C1229890008EC56 /* main.swift in Sources */,
127+
6C70CFBA1C1229890008EC56 /* http.swift in Sources */,
128+
);
129+
runOnlyForDeploymentPostprocessing = 0;
130+
};
131+
/* End PBXSourcesBuildPhase section */
132+
133+
/* Begin XCBuildConfiguration section */
134+
6C70CFB21C1229640008EC56 /* Debug */ = {
135+
isa = XCBuildConfiguration;
136+
buildSettings = {
137+
ALWAYS_SEARCH_USER_PATHS = NO;
138+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
139+
CLANG_CXX_LIBRARY = "libc++";
140+
CLANG_ENABLE_MODULES = YES;
141+
CLANG_ENABLE_OBJC_ARC = YES;
142+
CLANG_WARN_BOOL_CONVERSION = YES;
143+
CLANG_WARN_CONSTANT_CONVERSION = YES;
144+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
145+
CLANG_WARN_EMPTY_BODY = YES;
146+
CLANG_WARN_ENUM_CONVERSION = YES;
147+
CLANG_WARN_INT_CONVERSION = YES;
148+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
149+
CLANG_WARN_UNREACHABLE_CODE = YES;
150+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
151+
CODE_SIGN_IDENTITY = "-";
152+
COPY_PHASE_STRIP = NO;
153+
DEBUG_INFORMATION_FORMAT = dwarf;
154+
ENABLE_STRICT_OBJC_MSGSEND = YES;
155+
ENABLE_TESTABILITY = YES;
156+
GCC_C_LANGUAGE_STANDARD = gnu99;
157+
GCC_DYNAMIC_NO_PIC = NO;
158+
GCC_NO_COMMON_BLOCKS = YES;
159+
GCC_OPTIMIZATION_LEVEL = 0;
160+
GCC_PREPROCESSOR_DEFINITIONS = (
161+
"DEBUG=1",
162+
"$(inherited)",
163+
);
164+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
165+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
166+
GCC_WARN_UNDECLARED_SELECTOR = YES;
167+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
168+
GCC_WARN_UNUSED_FUNCTION = YES;
169+
GCC_WARN_UNUSED_VARIABLE = YES;
170+
MACOSX_DEPLOYMENT_TARGET = 10.11;
171+
MTL_ENABLE_DEBUG_INFO = YES;
172+
ONLY_ACTIVE_ARCH = YES;
173+
SDKROOT = macosx;
174+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
175+
};
176+
name = Debug;
177+
};
178+
6C70CFB31C1229640008EC56 /* Release */ = {
179+
isa = XCBuildConfiguration;
180+
buildSettings = {
181+
ALWAYS_SEARCH_USER_PATHS = NO;
182+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
183+
CLANG_CXX_LIBRARY = "libc++";
184+
CLANG_ENABLE_MODULES = YES;
185+
CLANG_ENABLE_OBJC_ARC = YES;
186+
CLANG_WARN_BOOL_CONVERSION = YES;
187+
CLANG_WARN_CONSTANT_CONVERSION = YES;
188+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
189+
CLANG_WARN_EMPTY_BODY = YES;
190+
CLANG_WARN_ENUM_CONVERSION = YES;
191+
CLANG_WARN_INT_CONVERSION = YES;
192+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
193+
CLANG_WARN_UNREACHABLE_CODE = YES;
194+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
195+
CODE_SIGN_IDENTITY = "-";
196+
COPY_PHASE_STRIP = NO;
197+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
198+
ENABLE_NS_ASSERTIONS = NO;
199+
ENABLE_STRICT_OBJC_MSGSEND = YES;
200+
GCC_C_LANGUAGE_STANDARD = gnu99;
201+
GCC_NO_COMMON_BLOCKS = YES;
202+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
203+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
204+
GCC_WARN_UNDECLARED_SELECTOR = YES;
205+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
206+
GCC_WARN_UNUSED_FUNCTION = YES;
207+
GCC_WARN_UNUSED_VARIABLE = YES;
208+
MACOSX_DEPLOYMENT_TARGET = 10.11;
209+
MTL_ENABLE_DEBUG_INFO = NO;
210+
SDKROOT = macosx;
211+
};
212+
name = Release;
213+
};
214+
6C70CFB51C1229640008EC56 /* Debug */ = {
215+
isa = XCBuildConfiguration;
216+
buildSettings = {
217+
PRODUCT_NAME = "$(TARGET_NAME)";
218+
};
219+
name = Debug;
220+
};
221+
6C70CFB61C1229640008EC56 /* Release */ = {
222+
isa = XCBuildConfiguration;
223+
buildSettings = {
224+
PRODUCT_NAME = "$(TARGET_NAME)";
225+
};
226+
name = Release;
227+
};
228+
/* End XCBuildConfiguration section */
229+
230+
/* Begin XCConfigurationList section */
231+
6C70CFA81C1229640008EC56 /* Build configuration list for PBXProject "swift-http" */ = {
232+
isa = XCConfigurationList;
233+
buildConfigurations = (
234+
6C70CFB21C1229640008EC56 /* Debug */,
235+
6C70CFB31C1229640008EC56 /* Release */,
236+
);
237+
defaultConfigurationIsVisible = 0;
238+
defaultConfigurationName = Release;
239+
};
240+
6C70CFB41C1229640008EC56 /* Build configuration list for PBXNativeTarget "swift-http" */ = {
241+
isa = XCConfigurationList;
242+
buildConfigurations = (
243+
6C70CFB51C1229640008EC56 /* Debug */,
244+
6C70CFB61C1229640008EC56 /* Release */,
245+
);
246+
defaultConfigurationIsVisible = 0;
247+
};
248+
/* End XCConfigurationList section */
249+
};
250+
rootObject = 6C70CFA51C1229640008EC56 /* Project object */;
251+
}

swift-http/swift-http.xcodeproj/project.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)