Skip to content

Merge 9715 and 9720 to master #9719

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 5 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions FirebaseStorage/Sources/StorageListResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,18 @@ import FirebaseStorageInternal
*/
@objc public let pageToken: String?

// MARK: - NSObject overrides

@objc override open func copy() -> Any {
return StorageListResult(impl.copy() as! FIRIMPLStorageListResult)
}

// MARK: - Internal APIs

internal let impl: FIRIMPLStorageListResult

internal init(_ impl: FIRIMPLStorageListResult) {
self.impl = impl
prefixes = impl.prefixes.map { StorageReference($0) }
items = impl.items.map { StorageReference($0) }
pageToken = impl.pageToken
Expand Down
21 changes: 21 additions & 0 deletions FirebaseStorage/Sources/StorageMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,27 @@ import FirebaseStorageInternal
self.init(impl: FIRIMPLStorageMetadata(dictionary: dictionary)!)
}

// MARK: - NSObject overrides

@objc override open func copy() -> Any {
return StorageMetadata(impl: impl.copy() as! FIRIMPLStorageMetadata)
}

@objc override open func isEqual(_ object: Any?) -> Bool {
guard let ref = object as? StorageMetadata else {
return false
}
return impl.isEqual(ref.impl)
}

@objc override public var hash: Int {
return impl.hash
}

@objc override public var description: String {
return impl.description
}

// MARK: - Internal APIs

internal let impl: FIRIMPLStorageMetadata
Expand Down
60 changes: 60 additions & 0 deletions FirebaseStorage/Tests/Unit/StorageMetadataTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation

import FirebaseStorage

import XCTest

class StorageMetadataTests: XCTestCase {
func testReflexiveMetadataEquality() {
let metaDict = ["bucket": "bucket", "name": "/path/to/file"]
let metadata0 = StorageMetadata(dictionary: metaDict)
let metadata1 = metadata0
XCTAssertEqual(metadata0, metadata1)
}

func testMetadataEquality() {
let metaDict = [
"bucket": "bucket",
"name": "/path/to/file",
"md5Hash": "d41d8cd98f00b204e9800998ecf8427e",
]
let metadata0 = StorageMetadata(dictionary: metaDict)
let metadata1 = StorageMetadata(dictionary: metaDict)
XCTAssertEqual(metadata0, metadata1)
}

func testMetadataMd5Inequality() {
let metaDict0 = ["md5Hash": "d41d8cd98f00b204e9800998ecf8427e"]
let metaDict1 = ["md5Hash": "d41d8cd98f00b204e9800998ecf8427f"]
let metadata0 = StorageMetadata(dictionary: metaDict0)
let metadata1 = StorageMetadata(dictionary: metaDict1)
XCTAssertNotEqual(metadata0, metadata1)
}

func testMetadataCopy() {
let metaDict = [
"bucket": "bucket",
"name": "/path/to/file",
"md5Hash": "d41d8cd98f00b204e9800998ecf8427e",
]
let metadata0 = StorageMetadata(dictionary: metaDict)
let metadata1 = metadata0.copy() as? StorageMetadata
// Verify that copied object has a new reference.
XCTAssertFalse(metadata0 === metadata1)
XCTAssertEqual(metadata0, metadata1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ - (void)testSameInstanceCustomBucket {
XCTAssertEqual(storage1, storage2);
}

- (void)testDiffferentInstance {
- (void)testDifferentInstance {
FIRStorage *storage1 = [FIRStorage storageForApp:self.app];
FIRStorage *storage2 = [FIRStorage storageForApp:self.app URL:@"gs://foo-bar.appspot.com"];
XCTAssertNotEqual(storage1, storage2);
Expand All @@ -175,6 +175,22 @@ - (void)testGetMetadata {
[self waitForExpectations];
}

- (void)testCopyMetadata {
XCTestExpectation *expectation = [self expectationWithDescription:@"testGetMetadata"];
FIRStorageReference *ref = [self.storage.reference child:@"ios/public/1mb"];

[ref metadataWithCompletion:^(FIRStorageMetadata *metadata, NSError *error) {
XCTAssertNotNil(metadata, "Metadata should not be nil");
XCTAssertNil(error, "Error should be nil");
FIRStorageMetadata *metadata2 = metadata.copy;
XCTAssertNotEqual(metadata, metadata2);
XCTAssertEqualObjects(metadata, metadata2);
[expectation fulfill];
}];

[self waitForExpectations];
}

- (void)testDelete {
XCTestExpectation *expectation = [self expectationWithDescription:@"testDelete"];

Expand Down Expand Up @@ -829,6 +845,25 @@ - (void)testListFilesAtRoot {
[self waitForExpectations];
}

- (void)testCopyListResult {
XCTestExpectation *expectation = [self expectationWithDescription:@"testCopyListResult"];

FIRStorageReference *ref = [self.storage referenceWithPath:@""];

[ref listAllWithCompletion:^(FIRStorageListResult *_Nullable listResult,
NSError *_Nullable error) {
XCTAssertNotNil(listResult);
XCTAssertNil(error);
XCTAssertNil(listResult.pageToken);
FIRStorageListResult *listResult2 = listResult.copy;
XCTAssertEqual(listResult.pageToken, listResult2.pageToken);
XCTAssertNotEqual(listResult, listResult2);
[expectation fulfill];
}];

[self waitForExpectations];
}

- (void)waitForExpectations {
[self waitForExpectationsWithTimeout:kFIRStorageIntegrationTestTimeout
handler:^(NSError *_Nullable error) {
Expand Down
37 changes: 22 additions & 15 deletions ReleaseTooling/Template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ To integrate a Firebase SDK with your app:
want the framework to be added to has a checkmark next to it, and that
you've selected "Copy items if needed".

*To disable AdId support, do not copy
`GoogleAppMeasurementIdentitySupport.xcframework`.*
> ⚠ To disable AdId support, do not copy
> `GoogleAppMeasurementIdentitySupport.xcframework`.

*If the app does not use any Firebase Swift specific APIs, you do not need
to copy any xcframeworks whose name includes "Swift" for this and the next
step.*
> ⚠ If the app does not use any Firebase Swift specific APIs, you do not need
> to copy any xcframeworks whose name includes `Swift` for this and the next
> step.

6. Drag each framework from the directory named after the SDK into the Project
Navigator pane. Note that there may be no additional frameworks, in which
Expand All @@ -38,22 +38,25 @@ To integrate a Firebase SDK with your app:
box that appears, make sure the target you want this framework to be added to
has a checkmark next to it, and that you've selected "Copy items if needed."

*Do not add the Firebase frameworks to the "Embed Frameworks" Xcode build
phase. The Firebase frameworks are not embedded dynamic frameworks, but are
[static frameworks](https://www.raywenderlich.com/65964/create-a-framework-for-ios)
which cannot be embedded into your application's bundle.*
> ⚠ Do not add the Firebase frameworks to the **Embed Frameworks** Xcode build
> phase. The Firebase frameworks are not embedded dynamic frameworks, but are
> [static frameworks](https://www.raywenderlich.com/65964/create-a-framework-for-ios)
> which cannot be embedded into your application's bundle.

7. If the SDK has resources, go into the Resources folders, which will be in
the SDK folder. Drag all of those resources into the Project Navigator, just
like the frameworks, again making sure that the target you want to add these
resources to has a checkmark next to it, and that you've selected "Copy items
if needed".
8. Add the -ObjC flag to "Other Linker Settings":
a. In your project settings, open the Settings panel for your target
b. Go to the Build Settings tab and find the "Other Linker Flags" setting
in the Linking section.
c. Double-click the setting, click the '+' button, and add "-ObjC" (without
quotes)
8. Add the `-ObjC` flag to **Other Linker Settings**:

a. In your project settings, open the **Settings** panel for your target.

b. Go to the Build Settings tab and find the **Other Linker Flags** setting
in the **Linking** section.

c. Double-click the setting, click the '+' button, and add `-ObjC`

9. Drag the `Firebase.h` header in this directory into your project. This will
allow you to `#import "Firebase.h"` and start using any Firebase SDK that you
have.
Expand All @@ -64,6 +67,10 @@ To integrate a Firebase SDK with your app:
a dummy Swift file to the app to prevent Swift system library missing
symbol linker errors. See
https://forums.swift.org/t/using-binary-swift-sdks-from-non-swift-apps/55989.

> ⚠ If prompted with the option to create a corresponding bridging header
> for the new Swift file, select **Don't create**.

12. You're done! Compile your target and start using Firebase.

If you want to add another SDK, repeat the steps above with the xcframeworks for
Expand Down