Skip to content

Commit a72f1c5

Browse files
committed
Update project for Swift 3 and Textual 6
1 parent 3e381f0 commit a72f1c5

File tree

4 files changed

+70
-32
lines changed

4 files changed

+70
-32
lines changed

Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundleVersion</key>
1616
<string>1.0.0</string>
1717
<key>MinimumTextualVersion</key>
18-
<string>5.0.0</string>
18+
<string>6.0.0</string>
1919
<key>NSPrincipalClass</key>
2020
<string>TPI_SwiftPluginExample</string>
2121
</dict>

SwiftPluginExample.swift

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,46 @@ It is appended to our new class object to inform Swift that we conform to it. */
99

1010
class TPI_SwiftPluginExample: NSObject, THOPluginProtocol
1111
{
12-
var subscribedServerInputCommands: [AnyObject]! {
12+
var subscribedServerInputCommands: [String] {
1313
get {
1414
return ["privmsg", "notice"]
1515
}
1616
}
1717

18-
func didReceiveServerInput(inputObject: THOPluginDidReceiveServerInputConcreteObject!, onClient client: IRCClient!)
18+
func didReceiveServerInput(_ inputObject: THOPluginDidReceiveServerInputConcreteObject, on client: IRCClient)
1919
{
2020
/* Swift provides a very powerful switch statement so
2121
it is easier to use that for identifying commands than
2222
using an if statement if more than the two are added. */
23-
24-
NSLog("%@ %@", inputObject.messageCommand, inputObject.messageParamaters)
25-
2623
switch (inputObject.messageCommand) {
2724
case "PRIVMSG":
28-
self.handleIncomingPrivateMessageCommand(inputObject, onClient: client)
25+
handleIncomingPrivateMessageCommand(inputObject, on: client)
2926
case "NOTICE":
30-
self.handleIncomingNoticeCommand(inputObject, onClient: client)
27+
handleIncomingNoticeCommand(inputObject, on: client)
3128
default:
3229
return
3330
}
3431
}
3532

36-
func handleIncomingPrivateMessageCommand(inputObject: THOPluginDidReceiveServerInputConcreteObject!, onClient client: IRCClient!)
33+
func handleIncomingPrivateMessageCommand(_ inputObject: THOPluginDidReceiveServerInputConcreteObject, on client: IRCClient)
3734
{
3835
/* Get message sequence of incoming message. */
39-
let messageReceived = (inputObject.messageSequence as String)
36+
let messageReceived = inputObject.messageSequence
4037

41-
let messageParamaters = (inputObject.messageParamaters as! Array<String>)
38+
let messageParamaters = inputObject.messageParamaters
4239

4340
/* Get channel that message was sent from. */
4441
/* The first paramater of the PRIVMSG command is always
4542
the channel the message was targetted to. */
4643
let senderChannel = client.findChannel(messageParamaters[0])
4744

4845
/* Do not accept private messages. */
49-
if senderChannel.isPrivateMessage {
46+
if ((senderChannel?.isPrivateMessage) != nil) {
5047
return
5148
}
5249

5350
/* Get sender of message. */
54-
let messageSender = (inputObject.senderNickname as String)
51+
let messageSender = inputObject.senderNickname
5552

5653
/* Ignore this user, he's kind of a jerk. :-( */
5754
if messageSender.hasPrefix("Alex") {
@@ -63,47 +60,47 @@ class TPI_SwiftPluginExample: NSObject, THOPluginProtocol
6360
messageReceived == "does anybody know what time it is?")
6461
{
6562
/* Format message. */
66-
let formattedString = (messageSender + ", the time where I am is: " + self.formattedDateTimeString())
63+
let formattedString = (messageSender + ", the time where I am is: " + formattedDateTimeString())
6764

6865
/* Invoke the client on the main thread when sending. */
69-
self.performBlockOnMainThread({
70-
client.sendPrivmsg(formattedString, toChannel: senderChannel)
66+
performBlock(onMainThread: {
67+
client.sendPrivmsg(formattedString, to: senderChannel)
7168
})
7269
}
7370
}
7471

75-
func handleIncomingNoticeCommand(inputObject: THOPluginDidReceiveServerInputConcreteObject!, onClient client: IRCClient!)
72+
func handleIncomingNoticeCommand(_ inputObject: THOPluginDidReceiveServerInputConcreteObject, on client: IRCClient)
7673
{
77-
// Not implemented.
74+
// Not implemented
7875
}
7976

8077
/* Support a new command in text field. */
81-
var subscribedUserInputCommands: [AnyObject]! {
78+
var subscribedUserInputCommands: [String] {
8279
get {
8380
return ["datetime"]
8481
}
8582
}
8683

87-
func userInputCommandInvokedOnClient(client: IRCClient!, commandString: String!, messageString: String!)
84+
func userInputCommandInvoked(on client: IRCClient, command commandString: String, messageString: String)
8885
{
89-
let formattedString = ("The current time is: " + self.formattedDateTimeString())
86+
let formattedString = ("The current time is: " + formattedDateTimeString())
9087

91-
let mainWindow = self.masterController().mainWindow;
88+
let mainWindow = masterController().mainWindow
9289

93-
self.performBlockOnMainThread({
94-
client.sendPrivmsg(formattedString, toChannel:mainWindow.selectedChannel)
90+
performBlock(onMainThread: {
91+
client.sendPrivmsg(formattedString, to:mainWindow?.selectedChannel)
9592
})
9693
}
9794

9895
/* Helper functions. */
9996
func formattedDateTimeString() -> (String)
10097
{
101-
let dateFormatter = NSDateFormatter()
98+
let dateFormatter = DateFormatter()
10299

103-
dateFormatter.dateStyle = NSDateFormatterStyle.FullStyle
104-
dateFormatter.timeStyle = NSDateFormatterStyle.FullStyle
100+
dateFormatter.dateStyle = DateFormatter.Style.fullStyle
101+
dateFormatter.timeStyle = DateFormatter.Style.fullStyle
105102

106-
let formattedDate = dateFormatter.stringFromDate(NSDate())
103+
let formattedDate = dateFormatter.string(from: Date())
107104

108105
return formattedDate
109106
}

SwiftPluginExample.xcodeproj/project.pbxproj

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@
115115
isa = PBXProject;
116116
attributes = {
117117
LastSwiftUpdateCheck = 0700;
118-
LastUpgradeCheck = 0700;
118+
LastUpgradeCheck = 0800;
119+
TargetAttributes = {
120+
8D57630D048677EA00EA77CD = {
121+
LastSwiftMigration = 0800;
122+
};
123+
};
119124
};
120125
buildConfigurationList = 1DEB911E08733D790010E9CD /* Build configuration list for PBXProject "SwiftPluginExample" */;
121126
compatibilityVersion = "Xcode 3.2";
@@ -162,48 +167,84 @@
162167
1DEB911B08733D790010E9CD /* Debug */ = {
163168
isa = XCBuildConfiguration;
164169
buildSettings = {
170+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
165171
BUNDLE_LOADER = /Applications/Textual.app/Contents/MacOS/Textual;
166172
COMBINE_HIDPI_IMAGES = YES;
167-
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
168173
FRAMEWORK_SEARCH_PATHS = "\"/Applications/Textual.app/Contents/Frameworks/**\"";
169174
HEADER_SEARCH_PATHS = "\"/Applications/Textual.app/Contents/Headers/**\"";
170175
INFOPLIST_FILE = Info.plist;
171176
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
172177
PRODUCT_BUNDLE_IDENTIFIER = com.example.extension.SwiftPluginExample;
173178
PRODUCT_NAME = SwiftPluginExample;
174179
SWIFT_OBJC_BRIDGING_HEADER = "SwiftPluginExample-Bridging-Header.h";
180+
SWIFT_VERSION = 3.0;
175181
WRAPPER_EXTENSION = bundle;
176182
};
177183
name = Debug;
178184
};
179185
1DEB911C08733D790010E9CD /* Release */ = {
180186
isa = XCBuildConfiguration;
181187
buildSettings = {
188+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
182189
BUNDLE_LOADER = /Applications/Textual.app/Contents/MacOS/Textual;
183190
COMBINE_HIDPI_IMAGES = YES;
184-
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
185191
FRAMEWORK_SEARCH_PATHS = "\"/Applications/Textual.app/Contents/Frameworks/**\"";
186192
HEADER_SEARCH_PATHS = "\"/Applications/Textual.app/Contents/Headers/**\"";
187193
INFOPLIST_FILE = Info.plist;
188194
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
189195
PRODUCT_BUNDLE_IDENTIFIER = com.example.extension.SwiftPluginExample;
190196
PRODUCT_NAME = SwiftPluginExample;
191197
SWIFT_OBJC_BRIDGING_HEADER = "SwiftPluginExample-Bridging-Header.h";
198+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
199+
SWIFT_VERSION = 3.0;
192200
WRAPPER_EXTENSION = bundle;
193201
};
194202
name = Release;
195203
};
196204
1DEB911F08733D790010E9CD /* Debug */ = {
197205
isa = XCBuildConfiguration;
198206
buildSettings = {
207+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
208+
CLANG_WARN_BOOL_CONVERSION = YES;
209+
CLANG_WARN_CONSTANT_CONVERSION = YES;
210+
CLANG_WARN_EMPTY_BODY = YES;
211+
CLANG_WARN_ENUM_CONVERSION = YES;
212+
CLANG_WARN_INT_CONVERSION = YES;
213+
CLANG_WARN_UNREACHABLE_CODE = YES;
214+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
215+
ENABLE_STRICT_OBJC_MSGSEND = YES;
216+
ENABLE_TESTABILITY = YES;
217+
GCC_NO_COMMON_BLOCKS = YES;
199218
GCC_OPTIMIZATION_LEVEL = 0;
219+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
220+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
221+
GCC_WARN_UNDECLARED_SELECTOR = YES;
222+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
223+
GCC_WARN_UNUSED_FUNCTION = YES;
224+
GCC_WARN_UNUSED_VARIABLE = YES;
200225
ONLY_ACTIVE_ARCH = YES;
201226
};
202227
name = Debug;
203228
};
204229
1DEB912008733D790010E9CD /* Release */ = {
205230
isa = XCBuildConfiguration;
206231
buildSettings = {
232+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
233+
CLANG_WARN_BOOL_CONVERSION = YES;
234+
CLANG_WARN_CONSTANT_CONVERSION = YES;
235+
CLANG_WARN_EMPTY_BODY = YES;
236+
CLANG_WARN_ENUM_CONVERSION = YES;
237+
CLANG_WARN_INT_CONVERSION = YES;
238+
CLANG_WARN_UNREACHABLE_CODE = YES;
239+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
240+
ENABLE_STRICT_OBJC_MSGSEND = YES;
241+
GCC_NO_COMMON_BLOCKS = YES;
242+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
243+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
244+
GCC_WARN_UNDECLARED_SELECTOR = YES;
245+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
246+
GCC_WARN_UNUSED_FUNCTION = YES;
247+
GCC_WARN_UNUSED_VARIABLE = YES;
207248
};
208249
name = Release;
209250
};

SwiftPluginExample.xcodeproj/xcshareddata/xcschemes/SwiftPluginExample.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0700"
3+
LastUpgradeVersion = "0800"
44
version = "2.0">
55
<BuildAction
66
parallelizeBuildables = "YES"

0 commit comments

Comments
 (0)