Skip to content

Commit e7bba77

Browse files
authored
(DOCSP-39147): Update SPM install instructions and privacy manifest details (#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)
1 parent 397789e commit e7bba77

File tree

5 files changed

+93
-22
lines changed

5 files changed

+93
-22
lines changed

examples/ios/Examples/MongoDBRemoteAccess.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ class MongoDBRemoteAccessTestCase: XCTestCase {
596596
}
597597
}
598598
}
599-
wait(for: [expectation, expectation2, expectation3], timeout: 20)
599+
wait(for: [expectation, expectation2, expectation3], timeout: 25)
600600
}
601601

602602
// MARK: Update Many

examples/ios/Examples/RealmActor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ class RealmActorTests: XCTestCase {
518518

519519
try await mainThreadFunction()
520520

521-
await fulfillment(of: [expectation], timeout: 5)
521+
await fulfillment(of: [expectation], timeout: 15)
522522
}
523523

524524
func testQueryForDataOnAnotherActor() async throws {

examples/ios/RealmExamples.xcodeproj/project.pbxproj

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
91713B3728AD2B0E00519F9D /* PassObjectsToView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B3428AD2B0E00519F9D /* PassObjectsToView.swift */; };
9595
91713B3928AD2B3500519F9D /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B3828AD2B3500519F9D /* Model.swift */; };
9696
91713B3B28AD2B3500519F9D /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91713B3828AD2B3500519F9D /* Model.swift */; };
97-
9175294628467FA000F8CB03 /* Realm in Frameworks */ = {isa = PBXBuildFile; productRef = 9175294528467FA000F8CB03 /* Realm */; };
9897
9175294828467FA000F8CB03 /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 9175294728467FA000F8CB03 /* RealmSwift */; };
9998
9175294A28467FB700F8CB03 /* Realm in Frameworks */ = {isa = PBXBuildFile; productRef = 9175294928467FB700F8CB03 /* Realm */; };
10099
9175294C28467FB700F8CB03 /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 9175294B28467FB700F8CB03 /* RealmSwift */; };
@@ -127,6 +126,7 @@
127126
91E5C80128256C6D00AAA239 /* EventLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91E5C80028256C6D00AAA239 /* EventLibrary.swift */; };
128127
91E608AD296E114500F84EA5 /* SyncedRealmCRUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91E608AC296E114500F84EA5 /* SyncedRealmCRUD.swift */; };
129128
91F046992A29299A000B43B2 /* Logging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91F046982A29299A000B43B2 /* Logging.swift */; };
129+
91F04E9A2BE290A80082EB2B /* RealmSwift in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 9175294728467FA000F8CB03 /* RealmSwift */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
130130
91FBD320279865080005C10C /* DeleteUsers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91FBD31F279865080005C10C /* DeleteUsers.swift */; };
131131
/* End PBXBuildFile section */
132132

@@ -147,6 +147,20 @@
147147
};
148148
/* End PBXContainerItemProxy section */
149149

150+
/* Begin PBXCopyFilesBuildPhase section */
151+
91F04E9B2BE290A80082EB2B /* Embed Frameworks */ = {
152+
isa = PBXCopyFilesBuildPhase;
153+
buildActionMask = 2147483647;
154+
dstPath = "";
155+
dstSubfolderSpec = 10;
156+
files = (
157+
91F04E9A2BE290A80082EB2B /* RealmSwift in Embed Frameworks */,
158+
);
159+
name = "Embed Frameworks";
160+
runOnlyForDeploymentPostprocessing = 0;
161+
};
162+
/* End PBXCopyFilesBuildPhase section */
163+
150164
/* Begin PBXFileReference section */
151165
228B6F9026166ED10075A6E0 /* Errors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = "<group>"; };
152166
228B6F9126166ED10075A6E0 /* Errors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Errors.m; sourceTree = "<group>"; };
@@ -271,7 +285,6 @@
271285
files = (
272286
917CA79827ECADC200F9BDDC /* FacebookLogin in Frameworks */,
273287
9143E95327EB79BD0082A5D6 /* GoogleSignIn in Frameworks */,
274-
9175294628467FA000F8CB03 /* Realm in Frameworks */,
275288
9175294828467FA000F8CB03 /* RealmSwift in Frameworks */,
276289
917CA79627ECADC200F9BDDC /* FacebookCore in Frameworks */,
277290
);
@@ -555,6 +568,7 @@
555568
4896EE482510514B00D1FABF /* Sources */,
556569
4896EE492510514B00D1FABF /* Frameworks */,
557570
4896EE4A2510514B00D1FABF /* Resources */,
571+
91F04E9B2BE290A80082EB2B /* Embed Frameworks */,
558572
);
559573
buildRules = (
560574
);
@@ -566,7 +580,6 @@
566580
9143E95227EB79BD0082A5D6 /* GoogleSignIn */,
567581
917CA79527ECADC200F9BDDC /* FacebookCore */,
568582
917CA79727ECADC200F9BDDC /* FacebookLogin */,
569-
9175294528467FA000F8CB03 /* Realm */,
570583
9175294728467FA000F8CB03 /* RealmSwift */,
571584
);
572585
productName = RealmExampleTests;
@@ -1477,7 +1490,7 @@
14771490
repositoryURL = "https://github.com/realm/realm-swift.git";
14781491
requirement = {
14791492
kind = exactVersion;
1480-
version = 10.48.1;
1493+
version = 10.49.3;
14811494
};
14821495
};
14831496
917CA79427ECADC200F9BDDC /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */ = {
@@ -1516,11 +1529,6 @@
15161529
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
15171530
productName = RealmSwift;
15181531
};
1519-
9175294528467FA000F8CB03 /* Realm */ = {
1520-
isa = XCSwiftPackageProductDependency;
1521-
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;
1522-
productName = Realm;
1523-
};
15241532
9175294728467FA000F8CB03 /* RealmSwift */ = {
15251533
isa = XCSwiftPackageProductDependency;
15261534
package = 9175294428467FA000F8CB03 /* XCRemoteSwiftPackageReference "realm-swift" */;

source/sdk/swift/install.txt

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,49 @@ Swift SDK to your project.
7272

7373
.. step:: Add Package Dependency
7474

75-
7675
In Xcode, select ``File`` > ``Add Packages...``.
7776

78-
7977
.. step:: Specify the Repository
8078

81-
8279
Copy and paste the following into the search/input box.
8380

8481
.. code-block:: sh
8582

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

88-
8985
.. step:: Specify Options
9086

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

97-
9892
.. step:: Select the Package Products
9993

94+
.. versionchanged:: 10.49.3
95+
Instead of adding both, only add one package.
96+
97+
Select either ``RealmSwift`` or ``Realm``, then click ``Add Package``.
10098

101-
Select both ``Realm`` and ``RealmSwift``, then click ``Add Package``.
99+
- If you use Swift or Swift and Objective-C APIs, add ``RealmSwift``.
100+
- If you use *only* Objective-C APIs, add ``Realm``.
101+
102+
.. step:: (Optional) Build RealmSwift as a Dynamic Framework
103+
104+
To use the Privacy Manifest supplied by the SDK, build ``RealmSwift``
105+
as a dynamic framework. If you build ``RealmSwift`` as a static
106+
framework, you must supply your own Privacy Manifest.
107+
108+
To build ``RealmSwift`` as a dynamic framework:
109+
110+
1. In your project :guilabel:`Targets`, select your build target.
111+
2. Go to the :guilabel:`General` tab.
112+
3. Expand the :guilabel:`Frameworks and Libraries` element.
113+
4. For the ``RealmSwift`` framework, change the
114+
:guilabel:`Embed` option from "Do Not Embed" to "Embed & Sign."
115+
116+
Now, Xcode builds ``RealmSwift`` dynamically, and can provide the
117+
SDK-supplied Privacy Manifest.
102118

103119
.. tab:: CocoaPods
104120
:tabid: cocoapods
@@ -431,10 +447,12 @@ refer to :ref:`swift-actor-isolated-realm`.
431447
Apple Privacy Manifest
432448
----------------------
433449

434-
Starting in Spring 2024, Apple requires apps that use ``RealmSwift`` to
435-
provide details about the SDK's data collection and use practices when
436-
submitting new apps or app updates to the App Store. For more details about
437-
Apple's requirements, refer to
450+
.. versionchanged:: 10.49.3
451+
Build RealmSwift as a dynamic framework to include the Privacy Manifest.
452+
453+
Apple requires apps that use ``RealmSwift`` to provide details about the SDK's
454+
data collection and use practices when submitting new apps or app updates to
455+
the App Store. For more details about Apple's requirements, refer to
438456
:apple:`Upcoming third-party SDK requirements <support/third-party-SDK-requirements/>`
439457
on the Apple Developer website.
440458

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

469+
To include these manifests in a build target that uses ``RealmSwift``, you must
470+
build ``RealmSwift`` as a dynamic framework. For details, refer to the Swift
471+
Package Manager Installation instructions step
472+
**(Optional) Build RealmSwift as a Dynamic Framework**.
473+
451474
The Swift SDK does not include analytics code in builds for the App Store.
452475
The SDK does not log into Atlas on its own behalf.
453476

source/sdk/swift/test-and-debug.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
Test and Debug - Swift SDK
55
==========================
66

7+
.. meta::
8+
:description: Learn how to test, debug, and troubleshoot Atlas Device SDK for Swift.
9+
:keywords: code example
10+
11+
.. facet::
12+
:name: genre
13+
:values: reference
14+
715
.. contents:: On this page
816
:local:
917
:backlinks: none
@@ -272,3 +280,35 @@ Bad Alloc/Not Enough Memory Available
272280
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
273281

274282
.. include:: /includes/ios-ipados-bad-alloc.rst
283+
284+
.. _swift-package-link-only-one-target-change:
285+
286+
Swift Package Target Cannot be Built Dynamically
287+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
288+
289+
.. versionchanged:: 10.49.3
290+
291+
Swift SDK v10.49.3 changed the details for installing the package with
292+
Swift Package Manager (SPM). When you update from an older version of the
293+
package to v10.49.3 or newer, you may get a build error similar to:
294+
295+
.. code-block:: console
296+
:copyable: false
297+
298+
Swift package target `Realm` is linked as a static library by `TargetName`
299+
and `Realm`, but cannot be built dynamically because there is a package
300+
product with the same name.
301+
302+
To resolve this error, unlink either the ``Realm`` or the ``RealmSwift``
303+
package from your build target. You can do this in Xcode by following these
304+
steps:
305+
306+
1. In your project :guilabel:`Targets`, select your build target.
307+
2. Go to the :guilabel:`Build Phases` tab.
308+
3. Expand the :guilabel:`Link Binary With Libraries` element.
309+
4. Select either ``Realm`` or ``RealmSwift``, and click the Remove items
310+
(:guilabel:`-`) button to remove the unneeded binary. For details about
311+
which binary to link, refer to the Swift Package Manager
312+
:ref:`installation instructions <ios-install>`.
313+
314+
Now your target should build without this error.

0 commit comments

Comments
 (0)