Skip to content

Commit

Permalink
(DOCSP-39147): Update SPM install instructions and privacy manifest d…
Browse files Browse the repository at this point in the history
…etails (#3237)

## Pull Request Info

Jira ticket: https://jira.mongodb.org/browse/DOCSP-39147

-
[Install](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-39147/sdk/swift/install/):
Update the Swift Package Manager and Privacy Manifest sections with
information about building as a dynamic framework and linking only to
one package.
- [Test and
Debug](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-39147/sdk/swift/test-and-debug/#swift-package-target-cannot-be-built-dynamically):
Add info for the error related to linking to both `Realm` and
`RealmSwift`.

### Reminder Checklist

Before merging your PR, make sure to check a few things.

- [x] Did you tag pages appropriately?
  - genre
  - meta.keywords
  - meta.description
- [x] Describe your PR's changes in the Release Notes section
- [x] Create a Jira ticket for related docs-app-services work, if any

### Release Notes

- **Swift SDK**
- Install: Update the Swift Package Manager and Privacy Manifest
sections with information about building as a dynamic framework and
linking only to one package.
- Test and Debug: Add information about how to resolve an error related
to linking to both `Realm` and `RealmSwift`.

### Review Guidelines


[REVIEWING.md](https://github.com/mongodb/docs-realm/blob/master/REVIEWING.md)
  • Loading branch information
dacharyc authored May 1, 2024
1 parent 397789e commit e7bba77
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 22 deletions.
2 changes: 1 addition & 1 deletion examples/ios/Examples/MongoDBRemoteAccess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ class MongoDBRemoteAccessTestCase: XCTestCase {
}
}
}
wait(for: [expectation, expectation2, expectation3], timeout: 20)
wait(for: [expectation, expectation2, expectation3], timeout: 25)
}

// MARK: Update Many
Expand Down
2 changes: 1 addition & 1 deletion examples/ios/Examples/RealmActor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ class RealmActorTests: XCTestCase {

try await mainThreadFunction()

await fulfillment(of: [expectation], timeout: 5)
await fulfillment(of: [expectation], timeout: 15)
}

func testQueryForDataOnAnotherActor() async throws {
Expand Down
26 changes: 17 additions & 9 deletions examples/ios/RealmExamples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
91713B3728AD2B0E00519F9D /* PassObjectsToView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B3428AD2B0E00519F9D /* PassObjectsToView.swift */; };
91713B3928AD2B3500519F9D /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B3828AD2B3500519F9D /* Model.swift */; };
91713B3B28AD2B3500519F9D /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B3828AD2B3500519F9D /* Model.swift */; };
9175294628467FA000F8CB03 /* Realm in Frameworks */ = {isa = PBXBuildFile; productRef = 9175294528467FA000F8CB03 /* Realm */; };
9175294828467FA000F8CB03 /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 9175294728467FA000F8CB03 /* RealmSwift */; };
9175294A28467FB700F8CB03 /* Realm in Frameworks */ = {isa = PBXBuildFile; productRef = 9175294928467FB700F8CB03 /* Realm */; };
9175294C28467FB700F8CB03 /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 9175294B28467FB700F8CB03 /* RealmSwift */; };
Expand Down Expand Up @@ -127,6 +126,7 @@
91E5C80128256C6D00AAA239 /* EventLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91E5C80028256C6D00AAA239 /* EventLibrary.swift */; };
91E608AD296E114500F84EA5 /* SyncedRealmCRUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91E608AC296E114500F84EA5 /* SyncedRealmCRUD.swift */; };
91F046992A29299A000B43B2 /* Logging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91F046982A29299A000B43B2 /* Logging.swift */; };
91F04E9A2BE290A80082EB2B /* RealmSwift in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 9175294728467FA000F8CB03 /* RealmSwift */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
91FBD320279865080005C10C /* DeleteUsers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91FBD31F279865080005C10C /* DeleteUsers.swift */; };
/* End PBXBuildFile section */

Expand All @@ -147,6 +147,20 @@
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
91F04E9B2BE290A80082EB2B /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
91F04E9A2BE290A80082EB2B /* RealmSwift in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
228B6F9026166ED10075A6E0 /* Errors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = "<group>"; };
228B6F9126166ED10075A6E0 /* Errors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Errors.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -271,7 +285,6 @@
files = (
917CA79827ECADC200F9BDDC /* FacebookLogin in Frameworks */,
9143E95327EB79BD0082A5D6 /* GoogleSignIn in Frameworks */,
9175294628467FA000F8CB03 /* Realm in Frameworks */,
9175294828467FA000F8CB03 /* RealmSwift in Frameworks */,
917CA79627ECADC200F9BDDC /* FacebookCore in Frameworks */,
);
Expand Down Expand Up @@ -555,6 +568,7 @@
4896EE482510514B00D1FABF /* Sources */,
4896EE492510514B00D1FABF /* Frameworks */,
4896EE4A2510514B00D1FABF /* Resources */,
91F04E9B2BE290A80082EB2B /* Embed Frameworks */,
);
buildRules = (
);
Expand All @@ -566,7 +580,6 @@
9143E95227EB79BD0082A5D6 /* GoogleSignIn */,
917CA79527ECADC200F9BDDC /* FacebookCore */,
917CA79727ECADC200F9BDDC /* FacebookLogin */,
9175294528467FA000F8CB03 /* Realm */,
9175294728467FA000F8CB03 /* RealmSwift */,
);
productName = RealmExampleTests;
Expand Down Expand Up @@ -1477,7 +1490,7 @@
repositoryURL = "https://github.com/realm/realm-swift.git";
requirement = {
kind = exactVersion;
version = 10.48.1;
version = 10.49.3;
};
};
917CA79427ECADC200F9BDDC /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */ = {
Expand Down Expand Up @@ -1516,11 +1529,6 @@
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
productName = RealmSwift;
};
9175294528467FA000F8CB03 /* Realm */ = {
isa = XCSwiftPackageProductDependency;
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
productName = Realm;
};
9175294728467FA000F8CB03 /* RealmSwift */ = {
isa = XCSwiftPackageProductDependency;
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
Expand Down
45 changes: 34 additions & 11 deletions source/sdk/swift/install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,33 +72,49 @@ Swift SDK to your project.

.. step:: Add Package Dependency


In Xcode, select ``File`` > ``Add Packages...``.


.. step:: Specify the Repository


Copy and paste the following into the search/input box.

.. code-block:: sh

https://github.com/realm/realm-swift.git


.. step:: Specify Options


In the options for the ``realm-swift`` package, we recommend setting
the ``Dependency Rule`` to ``Up to Next Major Version``,
and enter the `current Realm Swift SDK version
<https://github.com/realm/realm-swift/releases>`__ . Then, click ``Add Package``.


.. step:: Select the Package Products

.. versionchanged:: 10.49.3
Instead of adding both, only add one package.

Select either ``RealmSwift`` or ``Realm``, then click ``Add Package``.

Select both ``Realm`` and ``RealmSwift``, then click ``Add Package``.
- If you use Swift or Swift and Objective-C APIs, add ``RealmSwift``.
- If you use *only* Objective-C APIs, add ``Realm``.

.. step:: (Optional) Build RealmSwift as a Dynamic Framework

To use the Privacy Manifest supplied by the SDK, build ``RealmSwift``
as a dynamic framework. If you build ``RealmSwift`` as a static
framework, you must supply your own Privacy Manifest.

To build ``RealmSwift`` as a dynamic framework:

1. In your project :guilabel:`Targets`, select your build target.
2. Go to the :guilabel:`General` tab.
3. Expand the :guilabel:`Frameworks and Libraries` element.
4. For the ``RealmSwift`` framework, change the
:guilabel:`Embed` option from "Do Not Embed" to "Embed & Sign."

Now, Xcode builds ``RealmSwift`` dynamically, and can provide the
SDK-supplied Privacy Manifest.

.. tab:: CocoaPods
:tabid: cocoapods
Expand Down Expand Up @@ -431,10 +447,12 @@ refer to :ref:`swift-actor-isolated-realm`.
Apple Privacy Manifest
----------------------

Starting in Spring 2024, Apple requires apps that use ``RealmSwift`` to
provide details about the SDK's data collection and use practices when
submitting new apps or app updates to the App Store. For more details about
Apple's requirements, refer to
.. versionchanged:: 10.49.3
Build RealmSwift as a dynamic framework to include the Privacy Manifest.

Apple requires apps that use ``RealmSwift`` to provide details about the SDK's
data collection and use practices when submitting new apps or app updates to
the App Store. For more details about Apple's requirements, refer to
:apple:`Upcoming third-party SDK requirements <support/third-party-SDK-requirements/>`
on the Apple Developer website.

Expand All @@ -448,6 +466,11 @@ GitHub repository:
- ``Realm``: `https://github.com/realm/realm-swift/blob/master/Realm/PrivacyInfo.xcprivacy <https://github.com/realm/realm-swift/blob/master/Realm/PrivacyInfo.xcprivacy>`_
- ``RealmSwift``: `https://github.com/realm/realm-swift/blob/master/RealmSwift/PrivacyInfo.xcprivacy <https://github.com/realm/realm-swift/blob/master/RealmSwift/PrivacyInfo.xcprivacy>`_

To include these manifests in a build target that uses ``RealmSwift``, you must
build ``RealmSwift`` as a dynamic framework. For details, refer to the Swift
Package Manager Installation instructions step
**(Optional) Build RealmSwift as a Dynamic Framework**.

The Swift SDK does not include analytics code in builds for the App Store.
The SDK does not log into Atlas on its own behalf.

Expand Down
40 changes: 40 additions & 0 deletions source/sdk/swift/test-and-debug.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
Test and Debug - Swift SDK
==========================

.. meta::
:description: Learn how to test, debug, and troubleshoot Atlas Device SDK for Swift.
:keywords: code example

.. facet::
:name: genre
:values: reference

.. contents:: On this page
:local:
:backlinks: none
Expand Down Expand Up @@ -272,3 +280,35 @@ Bad Alloc/Not Enough Memory Available
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. include:: /includes/ios-ipados-bad-alloc.rst

.. _swift-package-link-only-one-target-change:

Swift Package Target Cannot be Built Dynamically
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. versionchanged:: 10.49.3

Swift SDK v10.49.3 changed the details for installing the package with
Swift Package Manager (SPM). When you update from an older version of the
package to v10.49.3 or newer, you may get a build error similar to:

.. code-block:: console
:copyable: false

Swift package target `Realm` is linked as a static library by `TargetName`
and `Realm`, but cannot be built dynamically because there is a package
product with the same name.

To resolve this error, unlink either the ``Realm`` or the ``RealmSwift``
package from your build target. You can do this in Xcode by following these
steps:

1. In your project :guilabel:`Targets`, select your build target.
2. Go to the :guilabel:`Build Phases` tab.
3. Expand the :guilabel:`Link Binary With Libraries` element.
4. Select either ``Realm`` or ``RealmSwift``, and click the Remove items
(:guilabel:`-`) button to remove the unneeded binary. For details about
which binary to link, refer to the Swift Package Manager
:ref:`installation instructions <ios-install>`.

Now your target should build without this error.

0 comments on commit e7bba77

Please sign in to comment.