-
Notifications
You must be signed in to change notification settings - Fork 216
feat(shorebird_cli): generate podspec for iOS framework releases #3675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
254c86a
2d2fd4f
e96dd62
5d25999
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,6 +115,9 @@ class IosFrameworkReleaser extends Releaser { | |
| p.join(targetLibraryDirectory.path, 'ShorebirdFlutter.xcframework'), | ||
| ); | ||
|
|
||
| // Generate a podspec so users can integrate via CocoaPods if preferred. | ||
| _writePodspec(targetLibraryDirectory); | ||
|
|
||
| return targetLibraryDirectory; | ||
| } | ||
|
|
||
|
|
@@ -148,18 +151,44 @@ class IosFrameworkReleaser extends Releaser { | |
| ), | ||
| ); | ||
|
|
||
| /// Writes a podspec that wraps the release xcframework output, enabling | ||
| /// CocoaPods-based integration as an alternative to manual Xcode embedding. | ||
| void _writePodspec(Directory releaseDir) { | ||
| final podspecPath = p.join( | ||
| releaseDir.path, | ||
| 'ShorebirdFlutter.podspec', | ||
| ); | ||
| File(podspecPath).writeAsStringSync(''' | ||
| Pod::Spec.new do |s| | ||
| s.name = 'ShorebirdFlutter' | ||
| s.version = '0.0.1' | ||
| s.summary = 'Shorebird Flutter framework for add-to-app integration.' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bdero's review bot: 🧹 |
||
| s.homepage = 'https://shorebird.dev' | ||
| s.license = { :type => 'BSD-3-Clause' } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bdero's review bot: 💡 |
||
| s.author = 'Shorebird' | ||
| s.source = { :path => '.' } | ||
| s.platform = :ios, '12.0' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bdero's review bot: 💡 |
||
| s.vendored_frameworks = 'App.xcframework', 'ShorebirdFlutter.xcframework' | ||
| end | ||
| '''); | ||
| } | ||
|
|
||
| @override | ||
| String get postReleaseInstructions { | ||
| final relativeFrameworkDirectoryPath = p.relative(releaseDirectory.path); | ||
| return ''' | ||
|
|
||
| Your next step is to add the .xcframework files found in the ${lightCyan.wrap(relativeFrameworkDirectoryPath)} directory to your iOS app. | ||
|
|
||
| To do this: | ||
| 1. Add the relative path to the ${lightCyan.wrap(relativeFrameworkDirectoryPath)} directory to your app's Framework Search Paths in your Xcode build settings. | ||
| 2. Embed the App.xcframework and ShorebirdFlutter.framework in your Xcode project. | ||
| ${styleBold.wrap('Option A: CocoaPods')} | ||
| Add the following to your app's Podfile: | ||
| ${lightCyan.wrap("pod 'ShorebirdFlutter', :path => '$relativeFrameworkDirectoryPath'")} | ||
| Then run ${lightCyan.wrap('pod install')}. | ||
|
|
||
| Instructions for these steps can be found at https://docs.flutter.dev/add-to-app/ios/project-setup#option-b---embed-frameworks-in-xcode. | ||
| ${styleBold.wrap('Option B: Manual Xcode embedding')} | ||
| 1. Add the relative path to the ${lightCyan.wrap(relativeFrameworkDirectoryPath)} directory to your app's Framework Search Paths in your Xcode build settings. | ||
| 2. Embed the App.xcframework and ShorebirdFlutter.xcframework in your Xcode project. | ||
| Instructions: https://docs.flutter.dev/add-to-app/ios/project-setup#option-b---embed-frameworks-in-xcode | ||
|
Comment on lines
+183
to
+191
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bdero's review bot: 🧹 If CocoaPods is the new recommended path, worth labeling it that way ("Option A: CocoaPods (recommended)") so users don't read Option A, glance at Option B, and feel like they need to pick. Otherwise both options read as equally weighted choices and we get more "which one should I use?" support questions. |
||
| '''; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -479,6 +479,24 @@ void main() { | |
| verify(() => artifactBuilder.buildIosFramework(args: [])).called(1); | ||
| }); | ||
|
|
||
| test('generates podspec in release directory', () async { | ||
| await runWithOverrides(iosFrameworkReleaser.buildReleaseArtifacts); | ||
|
|
||
| final podspecFile = File( | ||
| p.join(projectRoot.path, 'release', 'ShorebirdFlutter.podspec'), | ||
| ); | ||
| expect(podspecFile.existsSync(), isTrue); | ||
| final content = podspecFile.readAsStringSync(); | ||
| expect(content, contains("s.name = 'ShorebirdFlutter'")); | ||
| expect( | ||
| content, | ||
| contains( | ||
| "s.vendored_frameworks = 'App.xcframework', " | ||
| "'ShorebirdFlutter.xcframework'", | ||
| ), | ||
| ); | ||
| }); | ||
|
Comment on lines
+482
to
+498
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bdero's review bot: 💡 Test only asserts two |
||
|
|
||
| group('when --obfuscate is passed', () { | ||
| setUp(() { | ||
| when(() => argResults['obfuscate']).thenReturn(true); | ||
|
|
@@ -686,18 +704,22 @@ void main() { | |
| final relativeFrameworkDirectoryPath = p.relative( | ||
| p.join(projectRoot.path, 'release'), | ||
| ); | ||
| final instructions = runWithOverrides( | ||
| () => iosFrameworkReleaser.postReleaseInstructions, | ||
| ); | ||
| expect(instructions, contains('Option A: CocoaPods')); | ||
| expect(instructions, contains('Option B: Manual Xcode embedding')); | ||
| expect( | ||
| runWithOverrides(() => iosFrameworkReleaser.postReleaseInstructions), | ||
| equals(''' | ||
|
|
||
| Your next step is to add the .xcframework files found in the ${lightCyan.wrap(relativeFrameworkDirectoryPath)} directory to your iOS app. | ||
|
|
||
| To do this: | ||
| 1. Add the relative path to the ${lightCyan.wrap(relativeFrameworkDirectoryPath)} directory to your app's Framework Search Paths in your Xcode build settings. | ||
| 2. Embed the App.xcframework and ShorebirdFlutter.framework in your Xcode project. | ||
|
|
||
| Instructions for these steps can be found at https://docs.flutter.dev/add-to-app/ios/project-setup#option-b---embed-frameworks-in-xcode. | ||
| '''), | ||
| instructions, | ||
| contains( | ||
| "pod 'ShorebirdFlutter', :path => " | ||
| "'$relativeFrameworkDirectoryPath'", | ||
| ), | ||
| ); | ||
| expect(instructions, contains('pod install')); | ||
| expect( | ||
| instructions, | ||
| contains('App.xcframework and ShorebirdFlutter.xcframework'), | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bdero's review bot:
💡
s.version = '0.0.1'is the same string for every release, soPodfile.lockandpod outdatedwill show stale info regardless of which Shorebird release the user is actually shipping. With:path =>integration the version doesn't drive resolution, so nothing breaks — but plumbing throughargResults['release-version'](the same valuegetReleaseVersionreturns) makes the lockfile actually reflect reality. One catch: Flutter'srelease-versioncan include+buildsuffixes, and CocoaPods' SemVer parser is stricter than pub's, so we may need to strip or transform.