mirror of
https://github.com/zhigang1992/facebook-ios-sdk.git
synced 2026-04-30 02:16:16 +08:00
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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8a840e51c0
commit
4610b07bda
@@ -61,6 +61,9 @@ custom_rules:
|
||||
objc_members_above_objc:
|
||||
regex: "@objc[^\n]*?\n@objcMembers"
|
||||
message: "Place @objcMembers above @objc"
|
||||
objc_used_without_importing_foundation:
|
||||
regex: "LICENSE file in the root directory of this source tree.\n \\*/\n+@objc"
|
||||
message: "@objc attribute used without importing module 'Foundation'"
|
||||
|
||||
only_rules:
|
||||
- array_init
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
@objc(FBSDKLoginManager) // for NSClassFromString(@"FBSDKLoginManager")
|
||||
class FBSDKLoginManager: NSObject {
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class SampleEventBinding: NSObject {
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class SampleRawRemoteEventBindings: NSObject {
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class ServerConfigurationFixtures: NSObject {
|
||||
// swiftlint:disable line_length
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestATEPublisher: NSObject, ATEPublishing {
|
||||
var publishATEWasCalled = false
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestATEPublisherFactory: NSObject, ATEPublisherCreating {
|
||||
var stubbedPublisher: ATEPublishing? = TestATEPublisher()
|
||||
|
||||
@@ -6,5 +6,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
final class TestAccessTokenExpirer: NSObject, AccessTokenExpiring {}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestAppEventsConfiguration: NSObject, AppEventsConfigurationProtocol {
|
||||
static var stubbedDefaultConfiguration: TestAppEventsConfiguration?
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestAppEventsConfigurationProvider: NSObject, AppEventsConfigurationProviding {
|
||||
var stubbedConfiguration: AppEventsConfigurationProtocol?
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestAppEventsReporter: NSObject, AppEventsReporter {
|
||||
var enableWasCalled = false
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestAppEventsStateProvider: NSObject, AppEventsStateProviding {
|
||||
var state: TestAppEventsState?
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestAppEventsStateStore: NSObject, AppEventsStatePersisting {
|
||||
var capturedPersistedState: [Any] = []
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestAppLinkResolver: NSObject, AppLinkResolving {
|
||||
var capturedURL: URL?
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestAppStoreReceiptProvider: AppStoreReceiptProviding {
|
||||
var wasAppStoreReceiptURLRead = false
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestApplicationDelegateObserver: NSObject, FBSDKApplicationObserving {
|
||||
var didFinishLaunchingCallCount = 0
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestBackgroundEventLogger: NSObject, BackgroundEventLogging {
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestBridgeAPIResponseFactory: NSObject, BridgeAPIResponseCreating {
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestCodelessEvents: NSObject, CodelessIndexing {
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestDylibResolver: NSObject, FBSDKDynamicFrameworkResolving {
|
||||
var stubSafariViewControllerClass: AnyClass?
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestErrorConfigurationProvider: NSObject, ErrorConfigurationProviding {
|
||||
var configuration: ErrorConfigurationProtocol?
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestGateKeeperManager: NSObject, GateKeeperManaging {
|
||||
static var gateKeepers = [String?: Bool]()
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestGraphRequestBody: GraphRequestBody {
|
||||
var capturedKey: String?
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestLogger: Logger {
|
||||
static var capturedLoggingBehavior: LoggingBehavior?
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestLoggerFactory: NSObject, LoggerCreating {
|
||||
var capturedLoggingBehavior: LoggingBehavior?
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestMetadataIndexer: NSObject, MetadataIndexing {
|
||||
var enableWasCalled = false
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestPaymentObserver: NSObject, PaymentObserving {
|
||||
var didStartObservingTransactions = false
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestTimeSpentRecorder: NSObject, SourceApplicationTracking, TimeSpentRecording {
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestTouch: UITouch {
|
||||
var stubbedView: UIView?
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestURLSessionProxy: NSObject, URLSessionProxying {
|
||||
var delegateQueue: OperationQueue?
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestURLSessionProxyFactory: NSObject, URLSessionProxyProviding {
|
||||
private var stubbedSessions: [TestURLSessionProxy]
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
class TestUserIDProvider: NSObject, UserIDProviding {
|
||||
var userID: String?
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
final class TestInternalURLOpener: NSObject, ShareInternalURLOpening {
|
||||
var canOpenURL = false
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
final class TestShareUtility: NSObject, _ShareUtilityProtocol {
|
||||
static var stubbedValidateShareShouldThrow = false
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
public class TestBridgeAPIRequest: NSObject, BridgeAPIRequestProtocol {
|
||||
public var actionID: String
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
public class TestBridgeAPIRequestOpener: NSObject, BridgeAPIRequestOpening {
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
public final class TestErrorFactory: NSObject, ErrorCreating {
|
||||
public func error(
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc public enum TestSDKErrorType: Int {
|
||||
case general
|
||||
case invalidArgument
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
public class TestSettings: NSObject, SettingsProtocol, SettingsLogging {
|
||||
public var isEventDataUsageLimited = false
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers
|
||||
public class UserDefaultsSpy: UserDefaults {
|
||||
public var capturedObjectRetrievalKeys = [String]()
|
||||
|
||||
Reference in New Issue
Block a user