Skip to content
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

feat(firestore): Swift Package Manager support #13329

Merged
merged 79 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
d70a20b
chore(firestore): initial SPM move
russellwheatley Sep 12, 2024
047bf04
chore: initial macOS SPM
russellwheatley Sep 12, 2024
af7ef51
ios updates
russellwheatley Sep 12, 2024
5871bf5
ios pigeon
russellwheatley Sep 12, 2024
570d760
update imports
russellwheatley Sep 12, 2024
1029482
ios podspec working
russellwheatley Sep 12, 2024
19b3dad
update package.swift
russellwheatley Sep 13, 2024
4130346
hide .build config
russellwheatley Sep 13, 2024
42f7f15
try package.swift in root of repo
russellwheatley Sep 13, 2024
3354b03
push latest package.swift
russellwheatley Sep 13, 2024
53aec13
rm: package.swift file for experiment
russellwheatley Sep 13, 2024
e65a2f8
update point to Sources
russellwheatley Sep 13, 2024
a6651c9
url firestore
russellwheatley Sep 13, 2024
f6587d6
update package.swift root
russellwheatley Sep 13, 2024
a5615ae
update
russellwheatley Sep 13, 2024
8cacdac
ignore build files
russellwheatley Sep 16, 2024
eac1404
fix: reinsert package.swift core and fix path to core from firestore
russellwheatley Oct 10, 2024
a7cfe90
fix: imports for Swift integration are correct
russellwheatley Oct 10, 2024
f91c6e2
Merge branch 'main' into spm-firestore
russellwheatley Oct 10, 2024
0c5b666
test: see if I can source firebase core from remote
russellwheatley Oct 10, 2024
c59875d
cloud firestore example test
russellwheatley Oct 10, 2024
980770e
reinsert package.swift file for firebase core
russellwheatley Oct 10, 2024
fa94b1a
try using publicHeadersPath
russellwheatley Oct 10, 2024
5fa6cd9
further tweaks to test
russellwheatley Oct 10, 2024
71180b3
try without headerSearchPath
russellwheatley Oct 10, 2024
0436baf
change
russellwheatley Oct 10, 2024
7528a42
fix: firestore working
russellwheatley Oct 11, 2024
18ad50d
fix: add dummy remote firebase core source
russellwheatley Oct 14, 2024
48156bc
wrapper method that causes duplicate symbols
russellwheatley Oct 15, 2024
d83fd50
rm podfile from example
russellwheatley Oct 15, 2024
eee275f
working version of firestore and core
russellwheatley Oct 22, 2024
418065e
fix: import of core header files
russellwheatley Oct 22, 2024
75ef674
fix: headers for cocopod builds
russellwheatley Oct 22, 2024
4599687
fix: header files for swift or cocoapods
russellwheatley Oct 22, 2024
baa4510
spm core generate tag script
russellwheatley Oct 22, 2024
b43893c
rm dummy file
russellwheatley Oct 22, 2024
fb60fc9
symlink files for swift firebase core
russellwheatley Oct 22, 2024
d6d6fce
update the package.swift in root of project
russellwheatley Oct 22, 2024
636d1fc
update package.swift files to point to flutterfire repo
russellwheatley Oct 22, 2024
b59e17c
reinsert Podfile for firestore
russellwheatley Oct 22, 2024
be0d164
update branch ahead of main merge
russellwheatley Oct 23, 2024
2b09f9f
Merge branch 'main' into spm-firestore
russellwheatley Oct 23, 2024
d5cfa4a
fix: import headers for shared iOS
russellwheatley Oct 23, 2024
863744f
chore: rm dead code
russellwheatley Oct 28, 2024
d71500e
update Package.swifts to get versions
russellwheatley Oct 28, 2024
b3bdb32
tests: swift integration for core & firestore
russellwheatley Oct 28, 2024
727754d
format
russellwheatley Oct 28, 2024
f7bf67e
test: fix tests
russellwheatley Oct 28, 2024
e4df845
fix: symlinks to macOS
russellwheatley Oct 28, 2024
86e83d5
public symlinks
russellwheatley Oct 28, 2024
2247b23
chore: update symlinks for macOS
russellwheatley Oct 28, 2024
cbf4869
firestore macos packag.swift file
russellwheatley Oct 28, 2024
fff70c9
update core macos package.swift
russellwheatley Oct 29, 2024
b9ed5b7
fix: firestore macOS headers
russellwheatley Oct 29, 2024
da92423
license header
russellwheatley Oct 29, 2024
af70d95
debug swift integration
russellwheatley Oct 29, 2024
30c398f
add colon
russellwheatley Oct 29, 2024
c301949
tests: fix swift integration
russellwheatley Oct 29, 2024
4469aee
test: code sign for ios only
russellwheatley Oct 29, 2024
e18c11a
update macOS podspec
russellwheatley Oct 29, 2024
c59fbf7
deleted symlink
russellwheatley Oct 29, 2024
48b72f6
gitkeep
russellwheatley Oct 29, 2024
2135f99
test: update swift integration code
russellwheatley Oct 29, 2024
403e3b8
test swift
russellwheatley Oct 29, 2024
6b44ed9
macos build
russellwheatley Oct 29, 2024
a5e559e
rm macOS swift builds
russellwheatley Oct 29, 2024
ccbfadb
increase timeout
russellwheatley Oct 29, 2024
7366c6c
swift integration time increase
russellwheatley Oct 29, 2024
6d5f9b6
rm unneeded property in pubspec
russellwheatley Oct 29, 2024
728650f
Merge branch 'main' into spm-firestore
russellwheatley Nov 7, 2024
df03b5d
Merge branch 'main' into spm-firestore
russellwheatley Nov 8, 2024
89ab888
chore: every plugin with Swift needs access to firebase-ios-sdk version
russellwheatley Nov 8, 2024
035ca20
chore: pull version only from cloud_firestore plugin
russellwheatley Nov 8, 2024
8845393
license header
russellwheatley Nov 8, 2024
960a303
hard code version
russellwheatley Nov 8, 2024
cb32fba
revert
russellwheatley Nov 8, 2024
a39cc57
remove caret from version
russellwheatley Nov 8, 2024
e68f3bd
format
russellwheatley Nov 8, 2024
ad688cb
Merge branch 'main' into spm-firestore
russellwheatley Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/all_plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
- name: 'Swift Integration Setup'
run: flutter config --enable-swift-package-manager
- name: 'Build Apps with Swift Package Manager'
run: ./.github/workflows/scripts/swift-integration.sh
run: dart ./.github/workflows/scripts/swift-integration.dart

test:
runs-on: ubuntu-latest
Expand Down
105 changes: 105 additions & 0 deletions .github/workflows/scripts/swift-integration.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright 2024, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:io';
import 'dart:convert';

void main() async {
await buildSwiftExampleApp('ios', 'firebase_core');
await buildSwiftExampleApp('ios', 'cloud_firestore');
await buildSwiftExampleApp('macos', 'firebase_core');
await buildSwiftExampleApp('macos', 'cloud_firestore');
Comment on lines +9 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we need to do the other packages? Or is it just because cloud_firestore has its own SPM package?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's just for the packages which have Swift support; core + firestore.

}

Future<void> deleteFirstLine(String filePath) async {
final file = File(filePath);

if (!file.existsSync()) {
print('File does not exist: $filePath');
return;
}

final lines = await file.readAsLines();
if (lines.isNotEmpty) {
final updatedContent = lines.skip(1).join('\n');
await file.writeAsString(updatedContent);
print('First line deleted from $filePath');
} else {
print('File is empty: $filePath');
}
}

Future<void> buildSwiftExampleApp(String platform, String plugin) async {
final initialDirectory = Directory.current;
final platformName = platform == 'ios' ? 'iOS' : 'macOS';

print('Building $plugin $platformName example app with swift (SPM)');

final directory = Directory('packages/$plugin/$plugin/example/$platform');
if (!directory.existsSync()) {
print('Directory does not exist: ${directory.path}');
exit(1);
}

if (platform == 'macos') {
await deleteFirstLine(
'packages/$plugin/$plugin/example/macos/Flutter/Flutter-Debug.xcconfig');
}
// Change to the appropriate directory
Directory.current = directory;

// Remove Podfile and deintegrate pods
await _runCommand('rm', ['Podfile']);
await _runCommand('pod', ['deintegrate']);

// Determine the arguments for the flutter build command
final flutterArgs = ['build', platform];
if (platform == 'ios') {
flutterArgs.add('--no-codesign');
}

// Run the flutter build command
final flutterResult = await _runCommand('flutter', flutterArgs);

// Check if the flutter build command was successful
if (flutterResult.exitCode != 0) {
print('Flutter build failed with exit code ${flutterResult.exitCode}.');
exit(1);
}

// Check the output for the specific string
if (flutterResult.stdout.contains('Running pod install')) {
print('Failed. Pods are being installed when they should not be.');
exit(1);
} else {
print(
'Successfully built $plugin $platformName project using Swift Package Manager.');
}

Directory.current = initialDirectory;
}

Future<ProcessResult> _runCommand(
String command, List<String> arguments) async {
final process = await Process.start(command, arguments);

// Listen to stdout
process.stdout.transform(utf8.decoder).listen((data) {
print(data);
});

// Listen to stderr
process.stderr.transform(utf8.decoder).listen((data) {
print('stderr output: $data');
});

// Wait for the process to complete
final exitCode = await process.exitCode;

if (exitCode != 0) {
print('Command failed: $command ${arguments.join(' ')}');
}

return ProcessResult(process.pid, exitCode, '', '');
}
63 changes: 0 additions & 63 deletions .github/workflows/scripts/swift-integration.sh

This file was deleted.

1 change: 1 addition & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ command:
preCommit: |
dart run scripts/generate_vertexai_version.dart && \
dart run scripts/generate_dataconnect_version.dart && \
dart run scripts/generate_ios_sdk_version_txt_spm && \
git add packages/firebase_vertexai/firebase_vertexai/lib/src/vertex_version.dart && \
git add packages/firebase_data_connect/firebase_data_connect/lib/src/dataconnect_version.dart
post: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
A83F699FC746D5736A6B5780 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E8EC7192C60686BF1D599360 /* Pods_Runner.framework */; };
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -56,6 +57,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */,
A83F699FC746D5736A6B5780 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -131,6 +133,9 @@

/* Begin PBXNativeTarget section */
97C146ED1CF9000F007C117D /* Runner */ = {
packageProductDependencies = (
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */,
);
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
Expand All @@ -157,6 +162,9 @@

/* Begin PBXProject section */
97C146E61CF9000F007C117D /* Project object */ = {
packageReferences = (
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */,
);
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1510;
Expand Down Expand Up @@ -571,6 +579,18 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCLocalSwiftPackageReference section */
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage;
};
/* End XCLocalSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = {
isa = XCSwiftPackageProductDependency;
productName = FlutterGeneratedPluginSwiftPackage;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Prepare Flutter Framework Script"
scriptText = "/bin/sh &quot;$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh&quot; prepare&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ Pod::Spec.new do |s|
s.license = { :file => '../LICENSE' }
s.authors = 'The Chromium Authors'
s.source = { :path => '.' }

s.source_files = 'Classes/**/*.{h,m}'
s.public_header_files = 'Classes/Public/*.h'
s.private_header_files = 'Classes/Private/*.h'
s.source_files = 'cloud_firestore/Sources/cloud_firestore/**/*.{h,m}'
s.public_header_files = 'cloud_firestore/Sources/cloud_firestore/include/Public/**/*.h'
s.private_header_files = 'cloud_firestore/Sources/cloud_firestore/include/Private/**/*.h'

s.ios.deployment_target = '13.0'
s.dependency 'Flutter'
Expand All @@ -37,7 +36,7 @@ Pod::Spec.new do |s|

s.static_framework = true
s.pod_target_xcconfig = {
'GCC_PREPROCESSOR_DEFINITIONS' => "LIBRARY_VERSION=\\@\\\"#{library_version}\\\" LIBRARY_NAME=\\@\\\"flutter-fire-fst\\\"",
'GCC_PREPROCESSOR_DEFINITIONS' => "LIBRARY_VERSION=\\\"#{library_version}\\\" LIBRARY_NAME=\\\"flutter-fire-fst\\\"",
'DEFINES_MODULE' => 'YES'
}
end
Loading
Loading