-
Notifications
You must be signed in to change notification settings - Fork 4k
feat(core): support for using SPM (Swift Package Manager) #12786
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
Merged
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
3b81fa1
feat(core): support for package swift
russellwheatley 09aa361
chore: core example app updates
russellwheatley 3ff39e5
fix: package integration requires exact package name
russellwheatley b9f7df9
ios updates
russellwheatley 0f29a97
hide package.resolved
russellwheatley 01adfca
chore: remove ios config
russellwheatley f17a719
format
russellwheatley 04a671f
fix up the pigeon setup
russellwheatley 5250627
license for Package.swift
russellwheatley e02ba2c
update preprocessor definitions for podspec and package.swift
russellwheatley a56af80
update code for LIBRARY_NAME & LIBRARY_VERSION
russellwheatley bd55dff
working version
russellwheatley ea62464
Merge branch 'master' into spm-core-2
russellwheatley 5ae50bf
works on `flutter run` but not in Xcode
russellwheatley 5a2ede9
hard code lib versions
russellwheatley f55f0c6
format
russellwheatley c4ea595
move macos
russellwheatley 6a73e6a
fix symlink
russellwheatley f503c29
Discard changes to packages/firebase_core/firebase_core/ios/firebase_…
russellwheatley d2adbef
update core ios podspec after mistakenly reverting changes
russellwheatley 41f2321
fix: macOS.podspec header/source files
russellwheatley 2b1ebe7
ci: integrationt test for SPM firebase_core
russellwheatley 764bb5f
update integration test
russellwheatley b520a67
no-codesign
russellwheatley 7cc820b
pod deintegrate
russellwheatley a9d02ad
check build is successful as well
russellwheatley 31c3935
update Package.swift with ability to get versions dynamically
russellwheatley 4b78c08
rm unused output
russellwheatley 11d3ee6
get exitcode
russellwheatley e01ffdd
macos package swift
russellwheatley 7d3d225
rm macos from iOS package swift
russellwheatley 5d95766
ci: swift integration into own shell script + macos build
russellwheatley df77338
optional include for macOS release
russellwheatley 7613444
update swift script
russellwheatley 1329b2e
debug script
russellwheatley a021747
update macos test
russellwheatley a3c7a66
incorrect mac path
russellwheatley b9379b4
stop exiting script
russellwheatley 6c6d828
Merge branch 'master' into spm-core-2
russellwheatley 95ade96
Apply suggestions from code review
russellwheatley 8100b13
chore(core): bump ios version for swift
russellwheatley 9ca913f
Merge branch 'main' into spm-core-2
russellwheatley 1eaa3d1
chore(core): bump minimum macOS version
russellwheatley 15a4d36
Merge branch 'main' into spm-core-2
russellwheatley 0107af0
test: clean up disk space on macOS runner
russellwheatley 0fb8313
test: further clean up
russellwheatley 3fcaeb1
test: remove swift clean up
russellwheatley 4d81d07
test: remove further clean up
russellwheatley 758c3cb
chore(core): move to iOS 13 for core swift
russellwheatley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Just Core example has pure Swift capability at the moment | ||
|
||
|
||
# firebase_core iOS example | ||
|
||
# Setup for SPM integration | ||
cd packages/firebase_core/firebase_core/example/ios | ||
rm Podfile | ||
pod deintegrate | ||
|
||
# Run the flutter build command and capture the output and exit status | ||
flutter_output=$(flutter build ios --no-codesign) | ||
flutter_exit_code=$? | ||
|
||
# Check if the flutter build command was successful | ||
if [[ $flutter_exit_code -ne 0 ]]; then | ||
echo "Flutter build failed with exit code $flutter_exit_code." | ||
exit 1 | ||
fi | ||
|
||
# Check the output for the specific string | ||
if [[ "$flutter_output" =~ "Running pod install" ]]; then | ||
exit 1 | ||
else | ||
echo "Successfully built iOS project using Swift Package Manager." | ||
fi | ||
|
||
# firebase_core macOS example | ||
|
||
# Setup for SPM integration | ||
cd ../macos | ||
rm Podfile | ||
pod deintegrate | ||
|
||
# Run the flutter build command and capture the output and exit status | ||
flutter_output=$(flutter build macos) | ||
flutter_exit_code=$? | ||
|
||
# Check if the flutter build command was successful | ||
if [[ $flutter_exit_code -ne 0 ]]; then | ||
echo "Flutter build failed with exit code $flutter_exit_code." | ||
exit 1 | ||
fi | ||
|
||
# Check the output for the specific string | ||
if [[ "$flutter_output" =~ "Running pod install" ]]; then | ||
exit 1 | ||
else | ||
echo "Successfully built macOS project using Swift Package Manager." | ||
exit 0 | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/firebase_core/firebase_core/example/ios/Flutter/Debug.xcconfig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" | ||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" | ||
#include "Generated.xcconfig" |
2 changes: 1 addition & 1 deletion
2
packages/firebase_core/firebase_core/example/ios/Flutter/Release.xcconfig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" | ||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" | ||
#include "Generated.xcconfig" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...re/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?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>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/firebase_core/firebase_core/example/macos/Flutter/Flutter-Release.xcconfig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" | ||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" | ||
#include "ephemeral/Flutter-Generated.xcconfig" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
packages/firebase_core/firebase_core/ios/firebase_core/Package.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// swift-tools-version: 5.9 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
// 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 Foundation | ||
import PackageDescription | ||
|
||
enum ConfigurationError: Error { | ||
case fileNotFound(String) | ||
case parsingError(String) | ||
case invalidFormat(String) | ||
} | ||
|
||
let iosRootDirectory = String(URL(string: #file)!.deletingLastPathComponent().absoluteString | ||
.dropLast()) | ||
|
||
func loadPubspecVersion() throws -> String { | ||
let pubspecPath = NSString.path(withComponents: [iosRootDirectory, "..", "..", "pubspec.yaml"]) | ||
do { | ||
let yamlString = try String(contentsOfFile: pubspecPath, encoding: .utf8) | ||
if let versionLine = yamlString.split(separator: "\n") | ||
.first(where: { $0.starts(with: "version:") }) { | ||
let version = versionLine.split(separator: ":")[1].trimmingCharacters(in: .whitespaces) | ||
return version.replacingOccurrences(of: "+", with: "-") | ||
} else { | ||
throw ConfigurationError.invalidFormat("No version line found in pubspec.yaml") | ||
} | ||
} catch { | ||
throw ConfigurationError.fileNotFound("Error loading or parsing pubspec.yaml: \(error)") | ||
} | ||
} | ||
|
||
func loadFirebaseSDKVersion() throws -> String { | ||
let firebaseCoreScriptPath = NSString.path(withComponents: [ | ||
iosRootDirectory, | ||
"..", | ||
"..", | ||
"..", | ||
"firebase_core", | ||
"ios", | ||
"firebase_sdk_version.rb", | ||
]) | ||
do { | ||
let content = try String(contentsOfFile: firebaseCoreScriptPath, encoding: .utf8) | ||
let pattern = #"def firebase_sdk_version!\(\)\n\s+'([^']+)'\nend"# | ||
if let regex = try? NSRegularExpression(pattern: pattern, options: []), | ||
let match = regex.firstMatch( | ||
in: content, | ||
range: NSRange(content.startIndex..., in: content) | ||
) { | ||
if let versionRange = Range(match.range(at: 1), in: content) { | ||
return String(content[versionRange]) | ||
} else { | ||
throw ConfigurationError.invalidFormat("Invalid format in firebase_sdk_version.rb") | ||
} | ||
} else { | ||
throw ConfigurationError.parsingError("No match found in firebase_sdk_version.rb") | ||
} | ||
} catch { | ||
throw ConfigurationError | ||
.fileNotFound("Error loading or parsing firebase_sdk_version.rb: \(error)") | ||
} | ||
} | ||
|
||
let library_version: String | ||
let firebase_sdk_version_string: String | ||
|
||
do { | ||
library_version = try loadPubspecVersion() | ||
firebase_sdk_version_string = try loadFirebaseSDKVersion() | ||
} catch { | ||
fatalError("Failed to load configuration: \(error)") | ||
} | ||
|
||
guard let firebase_sdk_version = Version(firebase_sdk_version_string) else { | ||
fatalError("Invalid Firebase SDK version: \(firebase_sdk_version_string)") | ||
} | ||
|
||
let package = Package( | ||
name: "firebase_core", | ||
platforms: [ | ||
.iOS("13.0"), | ||
], | ||
products: [ | ||
.library(name: "firebase-core", targets: ["firebase_core"]), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/firebase/firebase-ios-sdk", from: firebase_sdk_version), | ||
], | ||
targets: [ | ||
.target( | ||
name: "firebase_core", | ||
dependencies: [ | ||
// No product for firebase-core so we pull in the smallest one | ||
.product(name: "FirebaseInstallations", package: "firebase-ios-sdk"), | ||
], | ||
resources: [ | ||
.process("Resources"), | ||
], | ||
cSettings: [ | ||
.headerSearchPath("include/firebase_core"), | ||
.define("LIBRARY_VERSION", to: "\"\(library_version)\""), | ||
.define("LIBRARY_NAME", to: "\"flutter-fire-core\""), | ||
] | ||
), | ||
] | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.