Skip to content

Commit 59a1067

Browse files
authored
[url_launcher] Add Swift Package Manager integration to example app (#8128)
This migrates the example app to have Swift Package Manager integration. This raises the example app's Flutter SDK requirement to 3.24.0 or higher. Scenarios: 1. **Run the example app using Flutter 3.24 or higher with SwiftPM feature on**: Plugin is added using Swift Package Manager. 2. **Run the example app using Flutter 3.24 or higher with SwiftPM feature off**: Plugin is added using CocoaPods. The tool generates an empty `FlutterGeneratedPluginSwiftPackage` local package. 3. **Run the example app using Flutter version lower than 3.24**: you get a build error because the example app's Xcode project expects a `FlutterGeneratedPluginSwiftPackage` local package but cannot find it. Part of: flutter/flutter#159173 ### Tests Current tests build the example apps twice: once with SwiftPM on, once with SwiftPM off. Currently, the tests with SwiftPM on also migrate the example app to add SwiftPM integration. After this change, these tests will no longer need to migrate the example app as it is already migrated. In other words, this change is covered by existing tests. ### Migration steps The app was migrated using these steps: ```console flutter channel master flutter upgrade flutter config --enable-swift-package-manager flutter build ios --config-only flutter build macos --config-only ```
1 parent 0d92794 commit 59a1067

File tree

5 files changed

+89
-43
lines changed

5 files changed

+89
-43
lines changed

packages/url_launcher/url_launcher/example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
2D92223F1EC1DA93007564B0 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D92223E1EC1DA93007564B0 /* GeneratedPluginRegistrant.m */; };
1111
2E37D9A274B2EACB147AC51B /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 856D0913184F79C678A42603 /* libPods-Runner.a */; };
1212
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
13+
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
1314
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
1415
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
1516
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
@@ -58,6 +59,7 @@
5859
isa = PBXFrameworksBuildPhase;
5960
buildActionMask = 2147483647;
6061
files = (
62+
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */,
6163
2E37D9A274B2EACB147AC51B /* libPods-Runner.a in Frameworks */,
6264
);
6365
runOnlyForDeploymentPostprocessing = 0;
@@ -153,13 +155,15 @@
153155
97C146EC1CF9000F007C117D /* Resources */,
154156
9705A1C41CF9048500538489 /* Embed Frameworks */,
155157
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
156-
41669A922CFCCB42BF5DF63C /* [CP] Copy Pods Resources */,
157158
);
158159
buildRules = (
159160
);
160161
dependencies = (
161162
);
162163
name = Runner;
164+
packageProductDependencies = (
165+
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */,
166+
);
163167
productName = Runner;
164168
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
165169
productType = "com.apple.product-type.application";
@@ -170,7 +174,7 @@
170174
97C146E61CF9000F007C117D /* Project object */ = {
171175
isa = PBXProject;
172176
attributes = {
173-
LastUpgradeCheck = 1430;
177+
LastUpgradeCheck = 1510;
174178
ORGANIZATIONNAME = "The Flutter Authors";
175179
TargetAttributes = {
176180
97C146ED1CF9000F007C117D = {
@@ -188,6 +192,9 @@
188192
Base,
189193
);
190194
mainGroup = 97C146E51CF9000F007C117D;
195+
packageReferences = (
196+
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */,
197+
);
191198
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
192199
projectDirPath = "";
193200
projectRoot = "";
@@ -228,24 +235,6 @@
228235
shellPath = /bin/sh;
229236
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
230237
};
231-
41669A922CFCCB42BF5DF63C /* [CP] Copy Pods Resources */ = {
232-
isa = PBXShellScriptBuildPhase;
233-
buildActionMask = 2147483647;
234-
files = (
235-
);
236-
inputPaths = (
237-
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh",
238-
"${PODS_CONFIGURATION_BUILD_DIR}/url_launcher_ios/url_launcher_ios_privacy.bundle",
239-
);
240-
name = "[CP] Copy Pods Resources";
241-
outputPaths = (
242-
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/url_launcher_ios_privacy.bundle",
243-
);
244-
runOnlyForDeploymentPostprocessing = 0;
245-
shellPath = /bin/sh;
246-
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
247-
showEnvVarsInLog = 0;
248-
};
249238
9740EEB61CF901F6004384FC /* Run Script */ = {
250239
isa = PBXShellScriptBuildPhase;
251240
alwaysOutOfDate = 1;
@@ -490,6 +479,20 @@
490479
defaultConfigurationName = Release;
491480
};
492481
/* End XCConfigurationList section */
482+
483+
/* Begin XCLocalSwiftPackageReference section */
484+
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = {
485+
isa = XCLocalSwiftPackageReference;
486+
relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage;
487+
};
488+
/* End XCLocalSwiftPackageReference section */
489+
490+
/* Begin XCSwiftPackageProductDependency section */
491+
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = {
492+
isa = XCSwiftPackageProductDependency;
493+
productName = FlutterGeneratedPluginSwiftPackage;
494+
};
495+
/* End XCSwiftPackageProductDependency section */
493496
};
494497
rootObject = 97C146E61CF9000F007C117D /* Project object */;
495498
}

packages/url_launcher/url_launcher/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1430"
3+
LastUpgradeVersion = "1510"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
77
buildImplicitDependencies = "YES">
8+
<PreActions>
9+
<ExecutionAction
10+
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
11+
<ActionContent
12+
title = "Run Prepare Flutter Framework Script"
13+
scriptText = "/bin/sh &quot;$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh&quot; prepare&#10;">
14+
<EnvironmentBuildable>
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
18+
BuildableName = "Runner.app"
19+
BlueprintName = "Runner"
20+
ReferencedContainer = "container:Runner.xcodeproj">
21+
</BuildableReference>
22+
</EnvironmentBuildable>
23+
</ActionContent>
24+
</ExecutionAction>
25+
</PreActions>
826
<BuildActionEntries>
927
<BuildActionEntry
1028
buildForTesting = "YES"

packages/url_launcher/url_launcher/example/macos/Runner.xcodeproj/project.pbxproj

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
2727
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
2828
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
29+
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
2930
DD4A1B9DEDBB72C87CD7AE27 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5067D74CB28D28AE3B3DD05B /* Pods_Runner.framework */; };
3031
/* End PBXBuildFile section */
3132

@@ -80,6 +81,7 @@
8081
isa = PBXFrameworksBuildPhase;
8182
buildActionMask = 2147483647;
8283
files = (
84+
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */,
8385
DD4A1B9DEDBB72C87CD7AE27 /* Pods_Runner.framework in Frameworks */,
8486
);
8587
runOnlyForDeploymentPostprocessing = 0;
@@ -184,14 +186,16 @@
184186
33CC10EB2044A3C60003C045 /* Resources */,
185187
33CC110E2044A8840003C045 /* Bundle Framework */,
186188
3399D490228B24CF009A79C7 /* ShellScript */,
187-
50C74DCD840D9B569BE3D48F /* [CP] Embed Pods Frameworks */,
188189
);
189190
buildRules = (
190191
);
191192
dependencies = (
192193
33CC11202044C79F0003C045 /* PBXTargetDependency */,
193194
);
194195
name = Runner;
196+
packageProductDependencies = (
197+
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */,
198+
);
195199
productName = Runner;
196200
productReference = 33CC10ED2044A3C60003C045 /* url_launcher_example_example.app */;
197201
productType = "com.apple.product-type.application";
@@ -203,7 +207,7 @@
203207
isa = PBXProject;
204208
attributes = {
205209
LastSwiftUpdateCheck = 0920;
206-
LastUpgradeCheck = 1300;
210+
LastUpgradeCheck = 1510;
207211
ORGANIZATIONNAME = "The Flutter Authors";
208212
TargetAttributes = {
209213
33CC10EC2044A3C60003C045 = {
@@ -231,6 +235,9 @@
231235
Base,
232236
);
233237
mainGroup = 33CC10E42044A3C60003C045;
238+
packageReferences = (
239+
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */,
240+
);
234241
productRefGroup = 33CC10EE2044A3C60003C045 /* Products */;
235242
projectDirPath = "";
236243
projectRoot = "";
@@ -292,24 +299,6 @@
292299
shellPath = /bin/sh;
293300
shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh\ntouch Flutter/ephemeral/tripwire\n";
294301
};
295-
50C74DCD840D9B569BE3D48F /* [CP] Embed Pods Frameworks */ = {
296-
isa = PBXShellScriptBuildPhase;
297-
buildActionMask = 2147483647;
298-
files = (
299-
);
300-
inputPaths = (
301-
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
302-
"${BUILT_PRODUCTS_DIR}/url_launcher_macos/url_launcher_macos.framework",
303-
);
304-
name = "[CP] Embed Pods Frameworks";
305-
outputPaths = (
306-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_macos.framework",
307-
);
308-
runOnlyForDeploymentPostprocessing = 0;
309-
shellPath = /bin/sh;
310-
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
311-
showEnvVarsInLog = 0;
312-
};
313302
C318D59394D0E38099411848 /* [CP] Check Pods Manifest.lock */ = {
314303
isa = PBXShellScriptBuildPhase;
315304
buildActionMask = 2147483647;
@@ -641,6 +630,20 @@
641630
defaultConfigurationName = Release;
642631
};
643632
/* End XCConfigurationList section */
633+
634+
/* Begin XCLocalSwiftPackageReference section */
635+
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = {
636+
isa = XCLocalSwiftPackageReference;
637+
relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage;
638+
};
639+
/* End XCLocalSwiftPackageReference section */
640+
641+
/* Begin XCSwiftPackageProductDependency section */
642+
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = {
643+
isa = XCSwiftPackageProductDependency;
644+
productName = FlutterGeneratedPluginSwiftPackage;
645+
};
646+
/* End XCSwiftPackageProductDependency section */
644647
};
645648
rootObject = 33CC10E52044A3C60003C045 /* Project object */;
646649
}

packages/url_launcher/url_launcher/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1510"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
77
buildImplicitDependencies = "YES">
8+
<PreActions>
9+
<ExecutionAction
10+
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
11+
<ActionContent
12+
title = "Run Prepare Flutter Framework Script"
13+
scriptText = "&quot;$FLUTTER_ROOT&quot;/packages/flutter_tools/bin/macos_assemble.sh prepare&#10;">
14+
<EnvironmentBuildable>
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
18+
BuildableName = "url_launcher_example_example.app"
19+
BlueprintName = "Runner"
20+
ReferencedContainer = "container:Runner.xcodeproj">
21+
</BuildableReference>
22+
</EnvironmentBuildable>
23+
</ActionContent>
24+
</ExecutionAction>
25+
</PreActions>
826
<BuildActionEntries>
927
<BuildActionEntry
1028
buildForTesting = "YES"

packages/url_launcher/url_launcher/example/macos/Runner/AppDelegate.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
import Cocoa
66
import FlutterMacOS
77

8-
@NSApplicationMain
8+
@main
99
class AppDelegate: FlutterAppDelegate {
1010
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
1111
return true
1212
}
13+
14+
override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
15+
return true
16+
}
1317
}

0 commit comments

Comments
 (0)