Commit Graph

137 Commits

Author SHA1 Message Date
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
Sam Odom
d654c9e909 Inject components and configurator to application delegate
Summary: This allows us to use both the consolidated list of components and the configurator to help bootstrap the SDK

Reviewed By: joesus

Differential Revision: D33345887

fbshipit-source-id: 8ee6d8fb6a6085e430646bd6f342955da1de92d7
2021-12-29 10:22:38 -08:00
Andres Suarez
1be77973cc Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33331776

fbshipit-source-id: 31b16e5e4cd0bb26c1e7cf49d9f8168eefdfe5ce
2021-12-27 17:08:35 -08:00
Sam Odom
50f0f4fd6e Abstract settings dependency from internal utility
Reviewed By: jamestouri

Differential Revision: D33163085

fbshipit-source-id: 4edcde9fc4fde8e45c6dd9b14387e0bec205d748
2021-12-20 15:32:24 -08:00
Jawwad Ahmad
f4b449ac4d SwiftFormat: Enable the redundantClosure rule to eliminate redundant closures
Summary:
- Also enabled the assertionFailures rule but that doesn't produce any changes
- Added comments to some of the commented out disabled rules to explain what they do

Reviewed By: joesus

Differential Revision: D33180271

fbshipit-source-id: 9e9785de04108741bf6376cd0d3261448173a9ca
2021-12-17 14:37:53 -08:00
Jawwad Ahmad
1ae235b9cb SwiftFormat: Capitalized a few cases of Url to URL by temporarily enabling the swiftformat acronyms rule
Summary: Just fixed things in tests since these wouldn't affect the public API. (There were a lot of things that I also didn't fix that could have been fixed without changing the public API because there were just so many changes). Mostly commiting this as a proof of concept as to how the acronyms rule can eventually make us more pedantic.

Reviewed By: joesus

Differential Revision: D33180069

fbshipit-source-id: 9c5cad75c33016e2a8154abada74bda59699c899
2021-12-17 13:56:52 -08:00
Sam Odom
0a32727e47 Abstract dependencies from device login manager
Summary:
* Abstract settings dependency
* Abstract internal utility dependency
* Correct initializer chain

Reviewed By: joesus

Differential Revision: D33154975

fbshipit-source-id: 68d082f68f7d41825721c46fd8b56ccdfa32dd69
2021-12-16 21:35:45 -08:00
Sam Odom
9d8da543c6 Abstract dependencies from bridge API protocol web v2
Summary:
* Abstract info dictionary provider
* Add bundle identifier to info dictionary providing protocol
* Abstract internal utility
* Lots of test changes to account for convoluted URL transformations in production code and transitive dependencies

Reviewed By: joesus

Differential Revision: D33105452

fbshipit-source-id: 32fab998a278b7ffba45b904362824f9ffb93845
2021-12-16 21:35:44 -08:00
Sam Odom
b3f73c0895 Abstract internal utility from bridge API protocol web v1
Summary: This required reworking a test that was indirectly testing the shared internal utility and, by extension, other transitive dependencies

Reviewed By: joesus

Differential Revision: D33096088

fbshipit-source-id: b44d4ed9e606c12dbae565381565da7ea3c90da9
2021-12-16 21:35:44 -08:00
Sam Odom
2987278dae URL query item dictionary fixes
Summary: A previous change to some URL creation interfaces to move query items from `[String: Any]` to `[String: String]` needed further propagation to other interfaces resulting in a cascade of changes to internal files.

Reviewed By: joesus

Differential Revision: D33154458

fbshipit-source-id: 1bcc5813769d6486e3f7463252f2768ab907324e
2021-12-16 21:35:44 -08:00
Joe Susnick
13d61e8ff1 Convert InternalUtilityTests to Swift
Summary: $title

Reviewed By: samodom

Differential Revision: D33000436

fbshipit-source-id: dd1c8abc22cea2ade8d9ec14c22035d2d1e91b9d
2021-12-15 12:01:06 -08:00
Jawwad Ahmad
19d736ed5e SwiftFormat: Enable the redundantSelf rule
Summary:
This rule has the following options:
```
--self # Explicit self: "insert", "remove" (default) or "init-only"
```

The init-only option will always use self in init methods even if it's not needed, but with the default "remove" option it will only use if its needed because of the parameter name being the same as the variable being set.

Reviewed By: samodom

Differential Revision: D33051306

fbshipit-source-id: 3dd5508ce7970792bdfe0c184a0eb8255283e047
2021-12-14 09:32:21 -08:00