148 Commits

Author SHA1 Message Date
Ryan Tobin
3183c7eca8 Added Privacy Manifests
Summary: Added Privacy Manifests

Reviewed By: jjiang10

Differential Revision: D53290629

fbshipit-source-id: c018ebad092402de1015f93ec2051bc70dfce4ee
2024-02-13 18:31:44 -08:00
Zilin Zhang
272bff5cd6 Fix duplicate install issue
Summary:
There exists a potential issue that duplicate install can be sent because `applicationDidBecomeActive` may be triggered multiple times within a very short time (e.g. App Launch and ATT prompt can trigger this function) and thus cause  `publichInstall` is triggered multiple times.

In order to fix this issue, this diff reuses the existing key `lastAttributionPingString` and `lastInstallResponseKey`. The flow will be
1. PublishInstall is triggered
2. Check if `lastAttributionPingString` exists and will send install event and set the key if the key doesn't exist. We do nothing if the key exists.
3. If the install event is sent successfully, we will set the key `lastInstallResponseKey`. If not, we'll remove the key `lastAttributionPingString`.
4. When app terminates, we'll check if `lastInstallResponseKey` exists to check if the install event is sent successfully. If the key exists, we'll do nothing. If the key doesn't exist, it means the install event is not sent successfully in the app launch and we'll remove the key `lastAttributionPingString`.

Reviewed By: jjiang10

Differential Revision: D53170017

fbshipit-source-id: 340e21188d884088215a65d06fffc402065a5102
2024-01-29 11:56:16 -08:00
Xin Wu
361f27efe0 connect v2 reporter
Summary:
In this diff:
1. Add `FBSDKSKAdNetworkReporterV2` crash sheild
2. Add `FBSDKFeatureSKAdNetworkV4` feature flag,  corresponding GK is `mobile_sdk_skadnetwork_v4`
3. Hook up logic for `SKAdNetworkReporter` and `SKAdNetworkReporterV2`
4. Intentionally didn't change AEM since it's deprecated

Reviewed By: dreamolight

Differential Revision: D48942596

fbshipit-source-id: bf12e35e5361e8a414ed96d6dfbb756c601a64e6
2023-09-08 16:39:22 -07:00
Jawwad Ahmad
897d66be0d Remove support for tvOS
Summary: tvOS is no longer supported

Reviewed By: samodom

Differential Revision: D40691780

fbshipit-source-id: f189dc7a95825ac04c9e87cb98b990ea29eaebf4
2022-10-26 09:02:20 -07:00
Sam Odom
85f1179ed1 Convert Settings and SettingsProtocol to Swift
Reviewed By: joesus

Differential Revision: D40398411

fbshipit-source-id: 9ec8a647f6f3b48be50b4c259bf2d6c13d2f8de4
2022-10-18 14:28:16 -07:00
Jawwad Ahmad
b3ec797cda Fix private method definition inconsistency and add a few missing imports
Summary:
All of the other public "configureWithNetworker" methods have an override for NS_SWIFT_NAME that renames the Swift method to use "networker" instead of "withNetworker". This "fixes" the definition of what the private method should be in Swift.
Also adding a few missing imports that will have to be eventually added when the FBAEMKit.h file is removed.

Reviewed By: samodom

Differential Revision: D40191595

fbshipit-source-id: 033c316c42ec976702bb40aba7e074703200df68
2022-10-10 11:52:21 -07:00
Jawwad Ahmad
090b00cc2f Remove TestTools.h
Summary:
- TestTools is now 100% Swift
- FBSDKCoreKit imports had to be added since it was no longer imported globally via TestTools.h
- A few line breaks had to be added above the new import to prevent the "Imports should be sorted" violation from SwiftLint

Reviewed By: samodom

Differential Revision: D40077738

fbshipit-source-id: 2cb5cbeceb90214f58fa0f6fe635eef133faa336
2022-10-04 16:35:17 -07:00
Jawwad Ahmad
492bf192a9 Move some exposed methods into FBSDKAuthenticationToken.h guarded by an #if DEBUG so that FBSDKAuthenticationToken+Testing.h can be removed
Summary: This is the only other header file in TestTools other than TestTools.h

Reviewed By: samodom

Differential Revision: D40077737

fbshipit-source-id: 8cc5810f87046623304e354714ffe9fdb8a48286
2022-10-04 16:35:14 -07:00
Sam Odom
148d7ef397 Make URL-producing method signatures consistent across protocols and languages
Reviewed By: jawwad

Differential Revision: D39978936

fbshipit-source-id: b242c501d628ffb7f30ecf804c031597e3d18c70
2022-10-04 13:34:08 -07:00
Jawwad Ahmad
eb0dd45ba1 Enable SwiftFormat on more directories in the internal folder
Summary: Refactored and moved excludes into a new .swiftconfig in the internal folder

Reviewed By: samodom

Differential Revision: D39933313

fbshipit-source-id: 6875ea67efbe52b5203ac64fb10a1c445717e170
2022-09-30 13:04:49 -07:00
Joe Susnick
0f8519fcea Convert FBSDKGraphRequestPiggybackManager.h/m to Swift
Summary: $title

Reviewed By: josueBrizuelaXD

Differential Revision: D39872537

fbshipit-source-id: 6393b5a703fc982a0b55bf9b3eeeaf26344b1f41
2022-09-29 09:07:43 -07:00
Sam Odom
d5d8c9a24e Clean up and simplify testing use of graph requests and their creation
Reviewed By: josueBrizuelaXD

Differential Revision: D39833084

fbshipit-source-id: d838b2ad032e97d11f55eed9001e2613a0edfa14
2022-09-27 17:51:52 -07:00
Jawwad Ahmad
b304e2fb82 Eliminate use of FBSDKTestCoder since it can't be converted to Swift
Summary: The decodeObjectCheck in ProfileTests was unused

Reviewed By: joesus

Differential Revision: D39778958

fbshipit-source-id: 7b7b539548d94f8078fb552455271a0ac16e11b1
2022-09-26 08:14:46 -07:00
Jawwad Ahmad
54e2b9e6cb Fix "Update to recommended settings" warnings in Xcode
Summary: Updated `xcodeVersion` from **13.3** to **14.0** in `xcodegen_project_common.yml` so that the `LastUpgradeCheck` gets set to **1440** so that Xcode doesn't ask to update to recommended settings.

Reviewed By: samodom

Differential Revision: D39708211

fbshipit-source-id: 0a4c135451dd5a9c64b7bc42a934d6869778eb72
2022-09-21 14:24:46 -07:00
Jawwad Ahmad
5fc2a734ed Fix the new "Run script build phase" warning for Swiftlint in Xcode 14
Summary:
More context here:
https://github.com/realm/SwiftLint/issues/4015

The full warning is:
```
warning build: Run script build phase 'Run Swiftlint' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase.
```

The fix is to uncheck "Based on dependency analysis" for the run script build phase.

This adds a "alwaysOutOfDate = 1;" setting to the Xcode pbxproj file

This setting is turned on by using "basedOnDependencyAnalysis: false" in xcodegen

Reviewed By: samodom

Differential Revision: D39678897

fbshipit-source-id: 90ed96cab52c3e2a0be3082dc94884a773faa1c6
2022-09-21 11:29:38 -07:00
Jawwad Ahmad
5f3acf206b Use the "targetTemplates" feature of xcodegen to centralize the Swiftlint Build Phase code that needs to be part of every target
Summary: See: https://github.com/yonaskolb/XcodeGen/blob/master/Docs/ProjectSpec.md#target-template

Reviewed By: samodom

Differential Revision: D39678898

fbshipit-source-id: 0439d6e7d4a6500f030e39b35c10538befff6703
2022-09-21 11:29:35 -07:00
Jawwad Ahmad
463d81eefb Drop support for iOS 11.0. Update deployment target for iOS and tvOS to iOS 12.0
Summary:
The IPHONEOS_DEPLOYMENT_TARGET and TVOS_DEPLOYMENT_TARGET are now 12.0

The main code change update was to use the "requiringSecureCoding" version of the `NSKeyedArchiver.archivedData(withRootObject:requiringSecureCoding:)` method.

Reviewed By: samodom

Differential Revision: D39670757

fbshipit-source-id: c98c47d4bef591c96bed33391b0393920a50ebfe
2022-09-20 15:33:24 -07:00
Sam Odom
a1bc1e410e Temporarily expose CoreKit types for Swift conversion (4/n)
Reviewed By: joesus

Differential Revision: D39084810

fbshipit-source-id: a5d92c9c89c3e88e542aa1873f09285c889d8457
2022-08-30 10:52:50 -07:00
Sam Odom
f3127fb22f Temporarily expose CoreKit types for Swift conversion (1/n)
Reviewed By: joesus

Differential Revision: D38874696

fbshipit-source-id: 519e5dcc7a3e745faebde99fc5b783cddf640cab
2022-08-23 09:00:04 -07:00
Pablo Brizuela Guardado
d5fde34427 Changed TestTools Xcode compatibility Version
Summary: Xcode compatibility version is changed to 11 in TestTools every time "generate-projects.sh" is run. Changing it once and for all to avoid its generation every time.

Reviewed By: samodom

Differential Revision: D38867127

fbshipit-source-id: 6101ba28d13461399da5d0b35499c020da607f97
2022-08-19 09:58:53 -07:00
Joe Susnick
945586c1ec Adding additional method to NotificationDelivering
Summary: Adds additional method to notification delivering protocol to mirror what is in Foundation’s Notification interface.

Reviewed By: josueBrizuelaXD

Differential Revision: D37653609

fbshipit-source-id: a1d2f6bd25d3749317fe5c7635773b85bdc40f6d
2022-07-06 15:30:00 -07:00
Joe Susnick
17dbd77f74 Moving TestNotificationCenter to TestTools
Summary: Moves the helper to test tools so that it can be used in GamingServicesKit tests.

Reviewed By: josueBrizuelaXD

Differential Revision: D37648330

fbshipit-source-id: b135bcc2b56989c49b00b38d0632dd5f2b47856c
2022-07-06 14:39:50 -07:00
Joe Susnick
01c1a6e398 Abstract dependencies for GameRequestDialog
Reviewed By: josueBrizuelaXD

Differential Revision: D37567777

fbshipit-source-id: 9d1b027cf4958eb6fcf70205d0c12b25839d29c6
2022-07-06 13:24:37 -07:00
Sam Odom
a706e69f77 Make URLSessionProviding and NetworkTask protocols less likely to produce conflicts
Summary: The NSURLSessionDataTask and NSURLSession bases for these protocols create a risk of conflict if we make any of the referenced symbols more abstract

Reviewed By: joesus

Differential Revision: D37358714

fbshipit-source-id: 4d88162f2f212702612a1eebe1f157a6d9a08154
2022-06-23 13:40:25 -07:00
Sam Odom
bb29366ee2 Make InfoDictionaryProviding protocol less likely to produce conflicts
Summary: The NSBundle basis for this protocol creates a risk of conflict if we make any of the referenced symbols more abstract

Reviewed By: joesus

Differential Revision: D37358716

fbshipit-source-id: 2ca5885075e89bddbab664a1e6b785772577f6cd
2022-06-23 13:40:22 -07:00
Sam Odom
8c733434c9 Convert LoginManager and LoginProviding to Swift
Reviewed By: joesus

Differential Revision: D36986845

fbshipit-source-id: b3242ca73fbd67bf123481ad2585dedee0dcb676
2022-06-13 16:07:43 -07:00
Sam Odom
5edd93279c Remove AuthenticationTokenSetting protocol
Summary: This protocol isn't strictly necessary and will cause issues with symbol ambiguity in Swift.

Reviewed By: shuxinzhang

Differential Revision: D36887434

fbshipit-source-id: b26d3f446a7c38c0c2360c8609dd505e3b64ec02
2022-06-03 12:33:15 -07:00
Sam Odom
3ee39cee06 Remove AccessTokenSetting protocol
Summary: This protocol isn't strictly necessary and is causing issues with symbol ambiguity in Swift.

Reviewed By: shuxinzhang

Differential Revision: D36887435

fbshipit-source-id: f876d53e3b055d55051921e9c5190d8f33c010ee
2022-06-03 12:33:15 -07:00
Sam Odom
429adb9d03 Add missing conformance declarations of CoreKit types to protocols
Summary:
* Make `AuthenticationToken` use `current` as the Swift name for `currentAuthenticationToken`
* Declare `AccessToken` conformance to `AccessTokenSetting`
* Declare `AuthenticationToken` conformance to `AuthenticationTokenProviding` and `AuthenticationTokenSetting`
* Make `AuthenticationTokenProviding` and `AuthenticationTokenSetting` use `current` as the Swift name for `currentAuthenticationToken`
* Declare `Profile` conformance to `ProfileProviding`

Reviewed By: josueBrizuelaXD

Differential Revision: D36706552

fbshipit-source-id: 714e02483c23cb1dbff001cb27c2cb59e9e1626b
2022-05-26 16:40:17 -07:00
Sam Odom
0ab188aafe Improve test coverage of MessageDialog in ShareKit
Reviewed By: shuxinzhang

Differential Revision: D35806609

fbshipit-source-id: d205dba25e18b47bca22ea4f5d142f64f018a170
2022-04-21 15:30:32 -07:00
Sam Odom
71be3fa1f7 Correct internal access token Swift property name
Summary: We were using the wrong Swift name for the current access token when accessing it via the provider abstraction.

Reviewed By: jawwad

Differential Revision: D35806611

fbshipit-source-id: fdf857e5343b913bed36f84d46ef5c2af62470c5
2022-04-21 15:30:32 -07:00
Sam Odom
d8de719de9 Improve test coverage of ShareDialog in ShareKit (3/n)
Summary: Test sharing via browser

Differential Revision: D35726807

fbshipit-source-id: 244885092ed29dbd720069fcfe99db65c38dc474
2022-04-18 18:17:07 -07:00
Jawwad Ahmad
ddb4db621a Eliminate use of FBSDKTestCoder from FBAEMKit/FBAEMKitTests/AEMInvocationTests.swift
Summary:
This diff also ads a TestUtils.encodeAndDecode(_:) method to reduce some boilerplate in tests and make it silghtly easier to do the rest of these tasks.

I couldn't use XCTUnwrap in TestUtils since I can't import XCTest because its in the TestTools project and not in a test target. So I decided to just return an optional and have the caller unwrap it.

Reviewed By: wx0165927473, samodom

Differential Revision: D35320238

fbshipit-source-id: 53c5f1a96b32e71eb8efc48a5a24a7920d2487a4
2022-04-04 12:01:38 -07:00
Sam Odom
b1e227929b Improve test coverage of ShareDialog in ShareKit (2/n)
Differential Revision: D35271216

fbshipit-source-id: 05460b4120a492a474ed376dffebc1cbf8b9b7eb
2022-04-01 13:09:30 -07:00
Jawwad Ahmad
7c5e9565b9 Fix "Update to recommended settings" warnings in Xcode
Summary:
Updated `xcodeVersion` from **13.2** to **13.3** in `xcodegen_project_common.yml` so that the `LastUpgradeCheck` gets set to **1330** so that Xcode doesn't ask to update to recommended settings.

Did it manually for the `FBSDKTVOSKit` project since that project file isn't generated with xcodegen.

Reviewed By: samodom

Differential Revision: D35147732

fbshipit-source-id: 3dbd970e846d45439b60df6bcefecc9db56fdbdf
2022-03-25 14:01:02 -07:00
Jawwad Ahmad
32d6c5ef06 Reduce the verbosity of the xcodebuild output by disabling the option to show environment variables in build log
Summary:
- In the build phase this is shown as a "Show environment variables in build log" option that can be unchecked
- This in turn adds the following line to the pbxproj file "showEnvVarsInLog = 0"
- With xcodegen this option is disabled by setting "showEnvVars: false"

This gets rid of the lines that say "export ENV_VAR_NAME..."

This change reduces the number of lines in the build output from ~6000 to ~3000

```
xcodebuild clean build -workspace FacebookSDK.xcworkspace -scheme BuildAllKits-Dynamic > ~/Desktop/xcodebuild_log_before.txt

// Made this change

xcodebuild clean build -workspace FacebookSDK.xcworkspace -scheme BuildAllKits-Dynamic > ~/Desktop/xcodebuild_log_after.txt

$ wc -l ~/Desktop/xcodebuild_log_before.txt
    6232 /Users/jawwad/Desktop/xcodebuild_log_before.txt

$ wc -l ~/Desktop/xcodebuild_log_after.txt
    3123 /Users/jawwad/Desktop/xcodebuild_log_after.txt
```

Reviewed By: samodom

Differential Revision: D35067834

fbshipit-source-id: c1a42a053a4a31e4646e9d766f00b970e776472d
2022-03-23 13:34:33 -07:00
Sam Odom
2f45776daa Add stubbed error to TestErrorFactory
Summary: This allows for stubbing behavior and maintains the spy-like behavior already available.

Differential Revision: D34899787

fbshipit-source-id: 84b6f77c1bf27c1a1879510ec8b0e5efc5b44681
2022-03-16 08:37:32 -07:00
Daniel Huri
d57a25a755 Support deeplinking using universal links
Summary:
## See the following [Proposal](https://fburl.com/gdoc/z90ch5in)

## Problem

We want to add support for universal links.
In order to do that, developers who have app events integration (AEM) will be required to add a call to the `openURL:` on the SDK delegate class from `application(_:continue:restorationHandler:)` in the short term.

We would like to simplify things for app developers since extracting the webpage URL from NSUserActivity may cause confusion and errors for deep linking.

## Solution

The better way is to just introduce a method with a similar signature to `application(_:continue:restorationHandler:)` in the SDK delegate.
Developers could simply invoke that method in order to have the universal link processed.

By doing that, we will to make FB SDK more accessible to developers.

## Testing

See the test plan section

Reviewed By: samodom

Differential Revision: D34786435

fbshipit-source-id: 289fea5ecc9e106fe0c9fcc94bf2a65b0c07c0ab
2022-03-14 13:40:41 -07:00
Sam Odom
95a1c44fab Abstract dependencies and backfill tests for FBSendButton
Reviewed By: jawwad

Differential Revision: D34621468

fbshipit-source-id: 7f9e570bf3a3e4f4a9b5a5d6657846e8d9c4e355
2022-03-04 17:13:30 -08:00
Jawwad Ahmad
d921d808fb SwiftLint: Enable the trailing_comma rule in swiftlint
Summary: Also enabled the `trailingCommas` rule in SwiftFormat so that these will be corrected when running swiftformat

Reviewed By: samodom

Differential Revision: D34253615

fbshipit-source-id: 7c450fdd8a15070a8445c9380ab5ba33c2952cdc
2022-02-15 14:06:31 -08:00
Jawwad Ahmad
624db61799 Add a swiftlint rule to prefer final classes
Summary:
There were only 2 instances in which I had to add a disable comment for prefer_final_classes due to subclassing

Used the following to add the final keyword (Adds final to any class that doesn't have final or open before it and doesn't have func after it)
```
find . -name '*.swift' | xargs perl -pi -e 's/(?<!final )(?<!open )(class (?!func).*\{)/final \1/g'
```

Reviewed By: samodom

Differential Revision: D34119233

fbshipit-source-id: 963d64fefc1686095d0bfe18ac7cb9677606f4e6
2022-02-09 23:10:04 -08:00
Sam Odom
ea94ad08a9 Renaming window finding protocol to indicate internal use
Summary:
* Conformance to protocol in multiple places by InternalUtility was failing to compile (from Swift conversion of ShareDialog)
* Corrected name (and file name) to reflect internal use

Reviewed By: jawwad

Differential Revision: D33923076

fbshipit-source-id: 8517accfd70ab39b3837c03c32fff97996628807
2022-02-03 16:30:30 -08:00
Jawwad Ahmad
f96fb30608 SwiftLint: Add custom rule for flagging usage of global swiftlint:disable comments
Summary:
Added a custom rule named `swiftlint_disable_without_this_or_next` to discourage bare usage of "swiftlint:disable"

If you really need to use a global disable, you can add the following line before it to disable its flagging
```
// swiftlint:disable:next swiftlint_disable_without_this_or_next
```

Yes, you'd need to disable flagging of your swiftlint:disable with a swiftlint:disable:next.

There are 2 rules that are exempt from being flagged when disabled globally: implicitly_unwrapped_optional and force_unwrapping
i.e. the following disables won't be flagged

```
// swiftlint:disable implicitly_unwrapped_optional
// swiftlint:disable force_unwrapping
```

Reviewed By: samodom

Differential Revision: D33809590

fbshipit-source-id: f2b6d656b6ea8a4c5f4e20ddd16790cb9d650473
2022-01-27 12:19:38 -08:00
Jawwad Ahmad
c435701b81 SwiftLint: Relax identifier_name length rule
Summary: Set it to 56 which is our current maximum variable length. (Setting to 55 shows 2 warnings)

Reviewed By: samodom

Differential Revision: D33808397

fbshipit-source-id: c162362a20d11426fa024bd79f1bc8563d19e01f
2022-01-27 09:08:36 -08:00
Jawwad Ahmad
5face70317 Add "import Foundation" to any class that is using @objc
Summary:
This is to prevent the following error that was seen in D33750740 (8044535803)
```
objc attribute used without importing module 'Foundation'
```

Found the files with:
```
git ls-files '*.swift' | xargs ack -l 'objc' | xargs ack -L 'import (Foundation|XCTest)'
```

Note: In D33783526 (4610b07bda) a custom SwiftLint rule was added to detect this but it only works if there aren't any other imports.

Reviewed By: samodom

Differential Revision: D33803396

fbshipit-source-id: 575d7798a77aac30384f8f44c1d45f97d60fe8f7
2022-01-26 18:23:28 -08:00
Jawwad Ahmad
4610b07bda Add custom SwiftLint rule to prevent missing foundation import to prevent error
Summary:
In D33750740 (8044535803) Hackbook started showing me the following error

```
objc attribute used without importing module 'Foundation'
```

This custom rule should prevent most cases of this. (It will only detect cases in which there are only empty lines between the license and the first objc)

Ran the following to add missing imports
```
git ls-files '*.swift' | xargs perl -0777 -pi -e s'/(of this source tree.\n \*\/)\n+\objc/\1\n\nimport Foundation\n\n\objc/'
```

Reviewed By: samodom

Differential Revision: D33783526

fbshipit-source-id: e75e1a66152d9a9790aa363d2fe7c71fd9446849
2022-01-26 14:25:44 -08:00
Jawwad Ahmad
105a784e7e Drop support for iOS 10.0. Update deployment target for iOS and tvOS to iOS 11.0
Summary: The IPHONEOS_DEPLOYMENT_TARGET and TVOS_DEPLOYMENT_TARGET are now 11.0

Reviewed By: samodom

Differential Revision: D33721097

fbshipit-source-id: 95afae6119fe09c0773252890aef6411f54d24d1
2022-01-24 18:23:07 -08:00
Zilin Zhang
f6510247cb Move FBSDKDataPersisting protocol to CoreKit Basics
Summary: $title

Reviewed By: samodom

Differential Revision: D33380276

fbshipit-source-id: 9fa2ac58f5905b034f89b4f6faad35c54fbe22b6
2022-01-05 16:56:48 -08:00
Sam Odom
507b406e96 Abstract dependencies from referral manager
Summary:
Abstract and inject the following dependencies:
* Internal utility
* Settings
* Bridge API request opener
* Error factory

Reviewed By: joesus

Differential Revision: D33399096

fbshipit-source-id: 60ef39ee7491bc795cf82200261c0b72b3d073c9
2022-01-04 16:23:21 -08:00
Sam Odom
34c39977c5 Move test error factory and error to TestTools
Summary: Also unnest test error type

Reviewed By: jamestouri

Differential Revision: D33380686

fbshipit-source-id: b9a966222a720087858ab0dde693b965f0644d1b
2022-01-04 13:23:22 -08:00