Skip to content

Commit

Permalink
Fix UIKitProject for Xcode 14
Browse files Browse the repository at this point in the history
  • Loading branch information
ileitch committed Oct 30, 2023
1 parent 8b94c23 commit 1ff2001
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 178 deletions.
18 changes: 0 additions & 18 deletions Tests/XcodeTests/UIKitProject/MyWidget/AppIntent.swift

This file was deleted.

92 changes: 0 additions & 92 deletions Tests/XcodeTests/UIKitProject/MyWidget/MyWidget.swift

This file was deleted.

117 changes: 53 additions & 64 deletions Tests/XcodeTests/UIKitProject/UIKitProject.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3CFFB5A62AEF8FDE002EFB86"
BuildableName = "MyWidgetExtension.appex"
BlueprintName = "MyWidgetExtension"
BlueprintIdentifier = "3CBEB9D02AEFC25B00F5947D"
BuildableName = "WatchWidgetExtension.appex"
BlueprintName = "WatchWidgetExtension"
ReferencedContainer = "container:UIKitProject.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?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>INEnums</key>
<array/>
<key>INIntentDefinitionModelVersion</key>
<string>1.2</string>
<key>INIntentDefinitionNamespace</key>
<string>88xZPY</string>
<key>INIntentDefinitionSystemVersion</key>
<string>20A294</string>
<key>INIntentDefinitionToolsBuildVersion</key>
<string>12A6144</string>
<key>INIntentDefinitionToolsVersion</key>
<string>12.0</string>
<key>INIntents</key>
<array>
<dict>
<key>INIntentCategory</key>
<string>information</string>
<key>INIntentDescriptionID</key>
<string>tVvJ9c</string>
<key>INIntentEligibleForWidgets</key>
<true/>
<key>INIntentIneligibleForSuggestions</key>
<true/>
<key>INIntentName</key>
<string>Configuration</string>
<key>INIntentResponse</key>
<dict>
<key>INIntentResponseCodes</key>
<array>
<dict>
<key>INIntentResponseCodeName</key>
<string>success</string>
<key>INIntentResponseCodeSuccess</key>
<true/>
</dict>
<dict>
<key>INIntentResponseCodeName</key>
<string>failure</string>
</dict>
</array>
</dict>
<key>INIntentTitle</key>
<string>Configuration</string>
<key>INIntentTitleID</key>
<string>gpCwrM</string>
<key>INIntentType</key>
<string>Custom</string>
<key>INIntentVerb</key>
<string>View</string>
</dict>
</array>
<key>INTypes</key>
<array/>
</dict>
</plist>
75 changes: 75 additions & 0 deletions Tests/XcodeTests/UIKitProject/WatchWidget/WatchWidget.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//
// WatchWidget.swift
// WatchWidget
//
// Created by Ian Leitch on 30.10.23.
//

import WidgetKit
import SwiftUI
import Intents

struct Provider: IntentTimelineProvider {
func placeholder(in context: Context) -> SimpleEntry {
SimpleEntry(date: Date(), configuration: ConfigurationIntent())
}

func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) {
let entry = SimpleEntry(date: Date(), configuration: configuration)
completion(entry)
}

func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
var entries: [SimpleEntry] = []

// Generate a timeline consisting of five entries an hour apart, starting from the current date.
let currentDate = Date()
for hourOffset in 0 ..< 5 {
let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)!
let entry = SimpleEntry(date: entryDate, configuration: configuration)
entries.append(entry)
}

let timeline = Timeline(entries: entries, policy: .atEnd)
completion(timeline)
}

func recommendations() -> [IntentRecommendation<ConfigurationIntent>] {
return [
IntentRecommendation(intent: ConfigurationIntent(), description: "My Intent Widget")
]
}
}

struct SimpleEntry: TimelineEntry {
let date: Date
let configuration: ConfigurationIntent
}

struct WatchWidgetEntryView : View {
var entry: Provider.Entry

var body: some View {
Text(entry.date, style: .time)
}
}

@main
struct WatchWidget: Widget {
let kind: String = "WatchWidget"

var body: some WidgetConfiguration {
IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in
WatchWidgetEntryView(entry: entry)
}
.configurationDisplayName("My Widget")
.description("This is an example widget.")
}
}

struct WatchWidget_Previews: PreviewProvider {
static var previews: some View {
WatchWidgetEntryView(entry: SimpleEntry(date: Date(), configuration: ConfigurationIntent()))
.previewContext(WidgetPreviewContext(family: .accessoryRectangular))
}
}
2 changes: 1 addition & 1 deletion Tests/XcodeTests/UIKitProjectTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class UIKitProjectTest: SourceGraphTestCase {

configuration.project = UIKitProjectPath.string
configuration.schemes = ["UIKitProject"]
configuration.targets = ["UIKitProject", "NotificationServiceExtension", "MyWidgetExtension",
configuration.targets = ["UIKitProject", "NotificationServiceExtension", "WatchWidgetExtension",
"UIKitProjectTests", "LocalPackage.LocalPackageTarget",
"LocalPackage.LocalPackageTargetTests"]

Expand Down

0 comments on commit 1ff2001

Please sign in to comment.