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

FR: Support for Swift Package Manager #3136

Open
w0mba7 opened this issue Jun 4, 2019 · 33 comments
Open

FR: Support for Swift Package Manager #3136

w0mba7 opened this issue Jun 4, 2019 · 33 comments

Comments

@w0mba7
Copy link

@w0mba7 w0mba7 commented Jun 4, 2019

With iOS support for Swift Package Manager in Xcode 11 can we please get that added to this project.

@google-oss-bot

This comment was marked as resolved.

Copy link

@google-oss-bot google-oss-bot commented Jun 4, 2019

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.
@ryanwilson

This comment has been minimized.

Copy link
Member

@ryanwilson ryanwilson commented Jun 4, 2019

Hey @w0mba7 - thanks for the report 😄

We're excited and looking into the best way we can support this as soon as we can, but there are a few dependencies and file structure changes we may need to do. We started experimenting with support on a branch at https://github.com/firebase/firebase-ios-sdk/tree/spm-master a few weeks ago and have a better idea of the approach we need.

We also started a discussion on binary framework distribution on the Swift forums but it looks like we may get some more information from a WWDC session this week titled Binary Frameworks in Swift
.

This won't be something we can do overnight but want to support it as soon as we can, there are a few bugs to work out as well (like SR-10707 that I discovered while working on adding support).

@possen

This comment has been minimized.

Copy link

@possen possen commented Jun 6, 2019

#2135 linking issues.

@possen

This comment has been minimized.

Copy link

@possen possen commented Jun 6, 2019

My experiment was to take the Carthage Binaries and add this to the Targets section but complains that the module map is in the wrong place:

error: package has unsupported layout;modulemap '/Users/user/Projects/RideCore/Carthage/Build/iOS/nanopb.framework/Modules/module.modulemap' should be inside the 'include' directory

moving things around in the folders and renaming did not seem to help.

     targets: [
        .target(
            name: "Core",
            dependencies: ["stuff"],
            path: "Carthage/Build/iOS",
            linkerSettings: [
                LinkerSetting.linkedFramework("FirebaseAnalytics"),
                LinkerSetting.linkedFramework("FirebaseCore"),
                LinkerSetting.linkedFramework("FirebaseDatabase"),
                LinkerSetting.linkedFramework("FirebaseMessaging"),
                LinkerSetting.linkedFramework("GoogleUtilities"),
                LinkerSetting.linkedFramework("leveldb-library"),
                LinkerSetting.linkedFramework("GoogleAppMeasurement"),
                LinkerSetting.linkedFramework("GTMSessionFetcher"),
                LinkerSetting.linkedFramework("nanopb"),
                LinkerSetting.linkedFramework("Protobuf")
            ]
@morganchen12 morganchen12 changed the title Support for Swift Package Manager FR: Support for Swift Package Manager Jun 11, 2019
@morganchen12

This comment was marked as resolved.

Copy link
Contributor

@morganchen12 morganchen12 commented Jun 11, 2019

Related to #2135

@paulb777

This comment has been minimized.

Copy link
Member

@paulb777 paulb777 commented Jun 27, 2019

Follow the progress at https://github.com/firebase/firebase-ios-sdk/commits/spm-master. Suggestions and PRs welcome!

@paulb777

This comment has been minimized.

Copy link
Member

@paulb777 paulb777 commented Jun 27, 2019

Much of Firebase Unit Testing relies on OCMock which does not yet support Swift PM. That could be a great place for someone in the community to contribute to accelerate the migration.

@paulb777

This comment has been minimized.

Copy link
Member

@paulb777 paulb777 commented Jul 9, 2019

For Firebase to support Swift Package Manager, there will need to be several changes to both Swift Package Manager and Firebase. See https://github.com/firebase/firebase-ios-sdk/commits/spm-master for the prototype implementation which successfully built a few of the Firebase libraries with SwiftPM. Below is a summary of some of the key requirements:

Binary library support
Some of the Firebase libraries are unlikely to ever open source. Thus for Firebase to completely move to SwiftPM, binary library support must be added, including support for depending on a source-based Package from a binary package. See the Swift forum discussion. The pitch to support framework search paths could provide a workaround.

Resource support
Firebase ML, Firebase In App Messaging and Firebase Firestore require resource support. There may be a workaround for Firestore, but not for the others. See Swift bug.

Separately versioned libraries per repo
Firebase currently separately versions its libraries from a single mono-repo. This could be accomplished with SwiftPM by adding multiple package support to a repo or by adding the ability to version libraries within a package. Xcode would also need to be similarly updated.

Firebase could consider abandoning separately versioning its libraries like it already does for binary and Carthage distributions. This would be especially unfortunate for managing new libraries with zero major versions of semantic versioning.

Build Settings
Some Firebase libraries rely upon being able to build some of their sources with and without Automatic Reference Counting (ARC). There does not seem to be a way to do this. See Forum discussion and Swift build setting proposal.

Module Map Generation
Objective-C modules aren't generated for Objective-C targets. This causes us to rely on changing our import statements to use local header paths instead of framework paths. See https://bugs.swift.org/browse/SR-10707

Testing - OCMock
Most of Firebase unit testing relies upon OCMock which does not yet have Swift Package Manager support.

Subspec support
Firebase relies upon subspecs so that different library combinations can choose different subsets of the GoogleUtilities support library. Now that static libraries/frameworks are better supported, it is probably feasible to split each GoogleUtilities subspec into a separate library.

Private Headers
Firebase uses the CocoaPods/Xcode private headers feature to share non-public APIs across libraries. It might be feasible for Firebase to abandon the use of this feature in favor of repo-relative import paths.

@possen

This comment has been minimized.

Copy link

@possen possen commented Jul 16, 2019

Thanks for your work on this!

@possen

This comment has been minimized.

Copy link

@possen possen commented Jul 18, 2019

The latest Xcode Beta 4 says under resolved issues "Swift packages that use unsafeFlags build settings can’t be used as a dependency. (50354068)" this could be a breakthrough in getting prebuilt binaries to work. It may allow "-F" to be passed as well as "no-objc-arc". Haven't tried it yet but thought I would let you know.

@ivanvorobei

This comment has been minimized.

Copy link

@ivanvorobei ivanvorobei commented Aug 6, 2019

Trying install spm-master branch via SPM, get this error:

Screenshot 2019-08-06 at 11 18 23

$(SRCROOT) in Package.swift

@ryanwilson

This comment has been minimized.

Copy link
Member

@ryanwilson ryanwilson commented Aug 6, 2019

@ivanvorobei thanks for testing! Which version of Xcode are you using?

@ivanvorobei

This comment has been minimized.

Copy link

@ivanvorobei ivanvorobei commented Aug 6, 2019

@ryanwilson I am use last beta of 11 Xcode.

@julienbodet

This comment has been minimized.

Copy link

@julienbodet julienbodet commented Aug 15, 2019

Trying install spm-master branch via SPM, get this error:

Screenshot 2019-08-06 at 11 18 23

$(SRCROOT) in Package.swift

I got the same error using Xcode Version 11.0 beta 5 (11M382q) when trying to add the package to my project. After a quick look at the documentation, it seems the path has to be relative to the project directory:

/// - Parameters:
///   - path: The path of the directory that contains the  headers. The path is relative to the target's directory.
///   - condition: A condition that restricts the application of the build setting.
public static func headerSearchPath(_ path: String, _ condition: PackageDescription.BuildSettingCondition? = nil) -> PackageDescription.CSetting
@paulb777

This comment has been minimized.

Copy link
Member

@paulb777 paulb777 commented Aug 16, 2019

@ivanvorobei @julienbodet Thanks for the reports! Something has changed between Xcode 11 beta 2 and beta 5 that leads to this issue.

I've asked a question about it on the SwiftPM forum.

@paulb777

This comment has been minimized.

Copy link
Member

@paulb777 paulb777 commented Aug 19, 2019

FYI, a forum discussion today about adding the -fno-objc-arc option to library builds. Firebase needs this in libraries that depend on Protobuf.

@vmanot

This comment has been minimized.

Copy link

@vmanot vmanot commented Sep 18, 2019

Any update on this?

@paulb777

This comment has been minimized.

Copy link
Member

@paulb777 paulb777 commented Sep 18, 2019

We'll do a full reassessment with the latest Xcode 11 in the next week or two, but it doesn't seem there has been much progress on most of the open issues.

@mmgrt

This comment has been minimized.

Copy link

@mmgrt mmgrt commented Oct 9, 2019

Any update on this?

@paulb777

This comment has been minimized.

Copy link
Member

@paulb777 paulb777 commented Oct 10, 2019

There's essentially no change from the July 9th comment above. There have been some proposals and discussions about some of the necessary features in the Swift Package Manager Forums, but not much tangible progress yet.

@MihaelIsaev

This comment has been minimized.

Copy link

@MihaelIsaev MihaelIsaev commented Oct 29, 2019

Any chance to use firebase through SPM now?

@zyxsimonxyz

This comment has been minimized.

Copy link

@zyxsimonxyz zyxsimonxyz commented Nov 3, 2019

still no update? its been so long

@rhysforyou

This comment has been minimized.

Copy link

@rhysforyou rhysforyou commented Nov 3, 2019

While it's great to see everyone so excited to adopt Swift Package Manager in their projects, there's currently nothing the Firebase team can do to support it. Once SPM supports binary frameworks I'm sure they'll give us an update, but until then all the comments asking for updates aren't particularly useful.

@inPhilly

This comment has been minimized.

Copy link

@inPhilly inPhilly commented Nov 6, 2019

It's difficult if you don't use CocoaPods... I have a legacy Objective-C project that I'm trying to integrate Firebase into. It doesn't use CocoaPods because there were so many issues. I just spent an hour manually integrating Firebase and Crashlytics and get this error:

*** Terminating app due to uncaught exception 'FIRAnalyticsVersionMismatch', reason: 'Google Analytics for Firebase version (60105000) does not match with Google App Measurement (60103000) version. Please update.'

I have the latest firebase manual download and the latest Crashlytics manual download. So with manual, it won't work; Swift Package Manager isn't happening; and there is no Carthage support. So basically, unless you use CocoaPods, you are out of luck. Discouraging.

@paulb777

This comment has been minimized.

Copy link
Member

@paulb777 paulb777 commented Nov 6, 2019

@inPhilly It looks like you have a FirebaseAnalytics.framework and GoogleAppMeasurement.framework from two different distributions.

Firebase does have an experimental Carthage distribution. See https://github.com/firebase/firebase-ios-sdk/blob/master/Carthage.md

@bdrelling

This comment has been minimized.

Copy link

@bdrelling bdrelling commented Nov 26, 2019

Until SE-0272 is integrated, there's nothing Firebase can do here... I'm eagerly awaiting for SPM support as a consumer as well, but they literally can't do anything when SPM is missing a feature that Firebase depends on.

Be reasonable, people.

@tychop

This comment has been minimized.

Copy link

@tychop tychop commented Nov 28, 2019

Why don't they use linked binary frameworks?
See https://forums.swift.org/t/binary-frameworks-with-swiftpm/26225/2

@paulb777

This comment has been minimized.

Copy link
Member

@paulb777 paulb777 commented Nov 28, 2019

@tychop Missing support for binary dependencies is just one of several missing Swift Package Manager features necessary to support Firebase. See above.

@amit6061

This comment has been minimized.

Copy link

@amit6061 amit6061 commented Dec 2, 2019

Any one suugest to me ,I want the Firebase initialise without Google-Service.plist?

@floriangbh

This comment has been minimized.

Copy link

@floriangbh floriangbh commented Dec 2, 2019

@amit6061 I'm not sure this is the great place to ask this kind of questions.

Please stop spamming this issue (every post will notify by email a lot of people), I'm pretty sure Firebase engineers will updated us once SPM will be more compliant with Firebase.

@amit6061

This comment was marked as off-topic.

Copy link

@amit6061 amit6061 commented Dec 4, 2019

I have send the notification from Firebase Cloud Messaging Panel .
I am getting the error ,Please help me

objc[600]: Class FIRMessagingPersistentSyncMessage is implemented in both /private/var/containers/Bundle/Application/E28A6E76-BC27-4207-AD6C-03C7D95ADBA6/iZootoTesting.app/Frameworks/iZooto_release.framework/iZooto_release (0x1013a0920) and /var/containers/Bundle/Application/E28A6E76-BC27-4207-AD6C-03C7D95ADBA6/iZootoTesting.app/iZootoTesting (0x100968950). One of the two will be used. Which one is undefined.

@Umar-M-Haroon

This comment was marked as resolved.

Copy link

@Umar-M-Haroon Umar-M-Haroon commented Dec 4, 2019

@amit6061 Please make a separate issue. Your issues aren’t relevant to the actual SPM thread and I can imagine others aren’t too happy getting notifications over this... (ironically I’m sending emails to a ton of people too, which I apologize in advance for)

@amit6061

This comment was marked as off-topic.

Copy link

@amit6061 amit6061 commented Dec 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.