diff options
author | Ben Hamilton (Ben Gertzfield) <bhamiltoncx@gmail.com> | 2018-03-29 09:44:48 -0600 |
---|---|---|
committer | Paul Beusterien <paulbeusterien@google.com> | 2018-03-29 08:44:48 -0700 |
commit | cb1f65dfcf78a6cfc11915c2c5695fa023cf3e09 (patch) | |
tree | 51ffdb63e1e461a1af1ce7e28291f2c40e5bb834 | |
parent | 13ff01e20ca796676ba74d0b99065199eca9d309 (diff) |
Migrate Firebase off ObjC module @import statements (#992)
* Migrate Firebase off @import statements
* - Migrate tests and test utils from @import to #import.
- Update Xcode projects for tests to explicitly link in framework deps.
- Update check_no_module_imports.sh to look for @imports in tests/test utils/
integration tests.
* Ensure check_no_module_imports.sh explicitly exits with code 0 on success.
26 files changed, 86 insertions, 26 deletions
diff --git a/.travis.yml b/.travis.yml index c907873..d68fafc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ jobs: script: - ./scripts/check_whitespace.sh - ./scripts/check_copyright.sh + - ./scripts/check_no_module_imports.sh - ./scripts/style.sh test-only $TRAVIS_COMMIT_RANGE # Google C++ style compliance - ./scripts/lint.sh $TRAVIS_COMMIT_RANGE diff --git a/Example/Auth/Tests/FIRPhoneAuthProviderTests.m b/Example/Auth/Tests/FIRPhoneAuthProviderTests.m index 0dc0b44..2b58270 100644 --- a/Example/Auth/Tests/FIRPhoneAuthProviderTests.m +++ b/Example/Auth/Tests/FIRPhoneAuthProviderTests.m @@ -44,7 +44,7 @@ #import "OCMStubRecorder+FIRAuthUnitTests.h" #import "Phone/FIRPhoneAuthCredential_Internal.h" -@import SafariServices; +#import <SafariServices/SafariServices.h> NS_ASSUME_NONNULL_BEGIN diff --git a/Example/Firebase.xcodeproj/project.pbxproj b/Example/Firebase.xcodeproj/project.pbxproj index 57fbfc9..5b887a9 100644 --- a/Example/Firebase.xcodeproj/project.pbxproj +++ b/Example/Firebase.xcodeproj/project.pbxproj @@ -120,6 +120,11 @@ 7EE21F7A1FE89193009B1370 /* FIREmailLinkRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7EE21F791FE89193009B1370 /* FIREmailLinkRequestTests.m */; }; 7EE21F7C1FE8919E009B1370 /* FIREmailLinkSignInResponseTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7EE21F7B1FE8919D009B1370 /* FIREmailLinkSignInResponseTests.m */; }; 7EFA2E041F71C93300DD354F /* FIRUserMetadataTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7EFA2E031F71C93300DD354F /* FIRUserMetadataTests.m */; }; + 923F824C206C4D8000034974 /* SafariServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 923F824B206C4D8000034974 /* SafariServices.framework */; }; + 923F824E206C4D8B00034974 /* SafariServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 923F824D206C4D8B00034974 /* SafariServices.framework */; }; + 923F824F206C4DA500034974 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE45C6641E7DA8CB009E6ACD /* XCTest.framework */; }; + 923F8251206C4DC600034974 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 923F8250206C4DC500034974 /* UserNotifications.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; + 923F8252206C4DD500034974 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; AFAF36F51EC28C25004BDEE5 /* Shared.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AFAF36F41EC28C25004BDEE5 /* Shared.xcassets */; }; AFAF36F61EC28C25004BDEE5 /* Shared.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AFAF36F41EC28C25004BDEE5 /* Shared.xcassets */; }; AFAF36F71EC28C25004BDEE5 /* Shared.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AFAF36F41EC28C25004BDEE5 /* Shared.xcassets */; }; @@ -951,6 +956,9 @@ 7EE21F7B1FE8919D009B1370 /* FIREmailLinkSignInResponseTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FIREmailLinkSignInResponseTests.m; sourceTree = "<group>"; }; 7EFA2E031F71C93300DD354F /* FIRUserMetadataTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FIRUserMetadataTests.m; sourceTree = "<group>"; }; 8496034D8156555C5FCF8F14 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; }; + 923F824B206C4D8000034974 /* SafariServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SafariServices.framework; path = System/Library/Frameworks/SafariServices.framework; sourceTree = SDKROOT; }; + 923F824D206C4D8B00034974 /* SafariServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SafariServices.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/SafariServices.framework; sourceTree = DEVELOPER_DIR; }; + 923F8250206C4DC500034974 /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; }; AFAF36F41EC28C25004BDEE5 /* Shared.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Shared.xcassets; path = Shared/Shared.xcassets; sourceTree = "<group>"; }; AFC8BA9C1EBD230E00B8EEAE /* NotificationsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationsController.swift; sourceTree = "<group>"; }; AFC8BA9E1EBD51A700B8EEAE /* Environment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Environment.swift; sourceTree = "<group>"; }; @@ -1316,6 +1324,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 923F824E206C4D8B00034974 /* SafariServices.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1456,6 +1465,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 923F824C206C4D8000034974 /* SafariServices.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1463,6 +1473,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 923F8252206C4DD500034974 /* UIKit.framework in Frameworks */, + 923F8251206C4DC600034974 /* UserNotifications.framework in Frameworks */, + 923F824F206C4DA500034974 /* XCTest.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1660,6 +1673,9 @@ 6003F58C195388D20070C39A /* Frameworks */ = { isa = PBXGroup; children = ( + 923F8250206C4DC500034974 /* UserNotifications.framework */, + 923F824B206C4D8000034974 /* SafariServices.framework */, + 923F824D206C4D8B00034974 /* SafariServices.framework */, D09005301EDB32D600154410 /* OCMock-iOS/OCMock.framework */, DE45C6641E7DA8CB009E6ACD /* XCTest.framework */, DEB61E781E7C542600C04B96 /* libsqlite3.tbd */, diff --git a/Example/Messaging/Tests/FIRMessagingClientTest.m b/Example/Messaging/Tests/FIRMessagingClientTest.m index 5505b70..9c60d9c 100644 --- a/Example/Messaging/Tests/FIRMessagingClientTest.m +++ b/Example/Messaging/Tests/FIRMessagingClientTest.m @@ -14,7 +14,7 @@ * limitations under the License. */ -@import XCTest; +#import <XCTest/XCTest.h> #import <OCMock/OCMock.h> diff --git a/Example/Messaging/Tests/FIRMessagingCodedInputStreamTest.m b/Example/Messaging/Tests/FIRMessagingCodedInputStreamTest.m index 7cc2d97..bafa714 100644 --- a/Example/Messaging/Tests/FIRMessagingCodedInputStreamTest.m +++ b/Example/Messaging/Tests/FIRMessagingCodedInputStreamTest.m @@ -14,7 +14,7 @@ * limitations under the License. */ -@import XCTest; +#import <XCTest/XCTest.h> #import "FIRMessagingCodedInputStream.h" diff --git a/Example/Messaging/Tests/FIRMessagingConnectionTest.m b/Example/Messaging/Tests/FIRMessagingConnectionTest.m index 47b29d2..b770cf5 100644 --- a/Example/Messaging/Tests/FIRMessagingConnectionTest.m +++ b/Example/Messaging/Tests/FIRMessagingConnectionTest.m @@ -14,7 +14,7 @@ * limitations under the License. */ -@import XCTest; +#import <XCTest/XCTest.h> #import <OCMock/OCMock.h> diff --git a/Example/Messaging/Tests/FIRMessagingDataMessageManagerTest.m b/Example/Messaging/Tests/FIRMessagingDataMessageManagerTest.m index 5771337..8aaad51 100644 --- a/Example/Messaging/Tests/FIRMessagingDataMessageManagerTest.m +++ b/Example/Messaging/Tests/FIRMessagingDataMessageManagerTest.m @@ -14,7 +14,7 @@ * limitations under the License. */ -@import XCTest; +#import <XCTest/XCTest.h> #import <OCMock/OCMock.h> diff --git a/Example/Messaging/Tests/FIRMessagingLinkHandlingTest.m b/Example/Messaging/Tests/FIRMessagingLinkHandlingTest.m index 8f93240..4ef2525 100644 --- a/Example/Messaging/Tests/FIRMessagingLinkHandlingTest.m +++ b/Example/Messaging/Tests/FIRMessagingLinkHandlingTest.m @@ -14,7 +14,7 @@ * limitations under the License. */ -@import XCTest; +#import <XCTest/XCTest.h> #import <OCMock/OCMock.h> diff --git a/Example/Messaging/Tests/FIRMessagingPubSubTest.m b/Example/Messaging/Tests/FIRMessagingPubSubTest.m index 2981b54..3af1402 100644 --- a/Example/Messaging/Tests/FIRMessagingPubSubTest.m +++ b/Example/Messaging/Tests/FIRMessagingPubSubTest.m @@ -14,7 +14,7 @@ * limitations under the License. */ -@import XCTest; +#import <XCTest/XCTest.h> #import "FIRMessagingPubSub.h" diff --git a/Example/Messaging/Tests/FIRMessagingRegistrarTest.m b/Example/Messaging/Tests/FIRMessagingRegistrarTest.m index b32851c..863ba4b 100644 --- a/Example/Messaging/Tests/FIRMessagingRegistrarTest.m +++ b/Example/Messaging/Tests/FIRMessagingRegistrarTest.m @@ -14,8 +14,8 @@ * limitations under the License. */ -@import UIKit; -@import XCTest; +#import <UIKit/UIKit.h> +#import <XCTest/XCTest.h> #import <OCMock/OCMock.h> diff --git a/Example/Messaging/Tests/FIRMessagingRemoteNotificationsProxyTest.m b/Example/Messaging/Tests/FIRMessagingRemoteNotificationsProxyTest.m index 1e1cbf3..3453f11 100644 --- a/Example/Messaging/Tests/FIRMessagingRemoteNotificationsProxyTest.m +++ b/Example/Messaging/Tests/FIRMessagingRemoteNotificationsProxyTest.m @@ -15,9 +15,9 @@ */ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 -@import UserNotifications; +#import <UserNotifications/UserNotifications.h> #endif -@import XCTest; +#import <XCTest/XCTest.h> #import <OCMock/OCMock.h> diff --git a/Example/Messaging/Tests/FIRMessagingSecureSocketTest.m b/Example/Messaging/Tests/FIRMessagingSecureSocketTest.m index 9f6186b..b86592c 100644 --- a/Example/Messaging/Tests/FIRMessagingSecureSocketTest.m +++ b/Example/Messaging/Tests/FIRMessagingSecureSocketTest.m @@ -14,7 +14,7 @@ * limitations under the License. */ -@import XCTest; +#import <XCTest/XCTest.h> #import <OCMock/OCMock.h> diff --git a/Example/Messaging/Tests/FIRMessagingServiceTest.m b/Example/Messaging/Tests/FIRMessagingServiceTest.m index c8d61c2..0a41314 100644 --- a/Example/Messaging/Tests/FIRMessagingServiceTest.m +++ b/Example/Messaging/Tests/FIRMessagingServiceTest.m @@ -14,8 +14,8 @@ * limitations under the License. */ -@import UIKit; -@import XCTest; +#import <UIKit/UIKit.h> +#import <XCTest/XCTest.h> #import <OCMock/OCMock.h> diff --git a/Example/Messaging/Tests/FIRMessagingTest.m b/Example/Messaging/Tests/FIRMessagingTest.m index 3521290..c2a136a 100644 --- a/Example/Messaging/Tests/FIRMessagingTest.m +++ b/Example/Messaging/Tests/FIRMessagingTest.m @@ -14,7 +14,7 @@ * limitations under the License. */ -@import XCTest; +#import <XCTest/XCTest.h> #import <OCMock/OCMock.h> #import <FirebaseInstanceID/FirebaseInstanceID.h> diff --git a/Firebase/Core/FIRNetworkConstants.m b/Firebase/Core/FIRNetworkConstants.m index a92e0e2..c958201 100644 --- a/Firebase/Core/FIRNetworkConstants.m +++ b/Firebase/Core/FIRNetworkConstants.m @@ -14,7 +14,7 @@ #import "Private/FIRNetworkConstants.h" -@import Foundation; +#import <Foundation/Foundation.h> NSString *const kFIRNetworkBackgroundSessionConfigIDPrefix = @"com.firebase.network.background-upload"; diff --git a/Firebase/Core/Private/FIRMutableDictionary.h b/Firebase/Core/Private/FIRMutableDictionary.h index ebe2d33..6829dbc 100644 --- a/Firebase/Core/Private/FIRMutableDictionary.h +++ b/Firebase/Core/Private/FIRMutableDictionary.h @@ -14,7 +14,7 @@ * limitations under the License. */ -@import Foundation; +#import <Foundation/Foundation.h> /// A mutable dictionary that provides atomic accessor and mutators. @interface FIRMutableDictionary : NSObject diff --git a/Firebase/Core/Private/FIRNetwork.h b/Firebase/Core/Private/FIRNetwork.h index aac0bca..32be35a 100644 --- a/Firebase/Core/Private/FIRNetwork.h +++ b/Firebase/Core/Private/FIRNetwork.h @@ -14,7 +14,7 @@ * limitations under the License. */ -@import Foundation; +#import <Foundation/Foundation.h> #import "FIRNetworkConstants.h" #import "FIRNetworkLoggerProtocol.h" diff --git a/Firebase/Core/Private/FIRNetworkConstants.h b/Firebase/Core/Private/FIRNetworkConstants.h index 5878088..d318581 100644 --- a/Firebase/Core/Private/FIRNetworkConstants.h +++ b/Firebase/Core/Private/FIRNetworkConstants.h @@ -14,7 +14,7 @@ * limitations under the License. */ -@import Foundation; +#import <Foundation/Foundation.h> /// Error codes in Firebase Network error domain. /// Note: these error codes should never change. It would make it harder to decode the errors if diff --git a/Firebase/Core/Private/FIRNetworkLoggerProtocol.h b/Firebase/Core/Private/FIRNetworkLoggerProtocol.h index 4a4315b..add70fc 100644 --- a/Firebase/Core/Private/FIRNetworkLoggerProtocol.h +++ b/Firebase/Core/Private/FIRNetworkLoggerProtocol.h @@ -14,7 +14,7 @@ * limitations under the License. */ -@import Foundation; +#import <Foundation/Foundation.h> #import "FIRLoggerLevel.h" #import "FIRNetworkMessageCode.h" diff --git a/Firebase/Core/Private/FIRNetworkURLSession.h b/Firebase/Core/Private/FIRNetworkURLSession.h index 3b60317..a51b8a9 100644 --- a/Firebase/Core/Private/FIRNetworkURLSession.h +++ b/Firebase/Core/Private/FIRNetworkURLSession.h @@ -14,7 +14,7 @@ * limitations under the License. */ -@import Foundation; +#import <Foundation/Foundation.h> #import "FIRNetworkLoggerProtocol.h" diff --git a/Firebase/Core/Private/FIRReachabilityChecker.h b/Firebase/Core/Private/FIRReachabilityChecker.h index afbc89b..3a6a531 100644 --- a/Firebase/Core/Private/FIRReachabilityChecker.h +++ b/Firebase/Core/Private/FIRReachabilityChecker.h @@ -14,8 +14,8 @@ * limitations under the License. */ -@import Foundation; -@import SystemConfiguration; +#import <Foundation/Foundation.h> +#import <SystemConfiguration/SystemConfiguration.h> /// Reachability Status typedef enum { diff --git a/Functions/Example/IntegrationTests/FIRIntegrationTests.m b/Functions/Example/IntegrationTests/FIRIntegrationTests.m index 15a5af5..bd4b127 100644 --- a/Functions/Example/IntegrationTests/FIRIntegrationTests.m +++ b/Functions/Example/IntegrationTests/FIRIntegrationTests.m @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -@import XCTest; +#import <XCTest/XCTest.h> #import "FIRError.h" #import "FIRFunctions+Internal.h" diff --git a/Functions/Example/TestUtils/FUNFakeApp.m b/Functions/Example/TestUtils/FUNFakeApp.m index 5b31d01..370273b 100644 --- a/Functions/Example/TestUtils/FUNFakeApp.m +++ b/Functions/Example/TestUtils/FUNFakeApp.m @@ -14,6 +14,8 @@ * limitations under the License. */ +#import <Foundation/Foundation.h> + #import "FUNFakeApp.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Functions/Example/Tests/FIRFunctionsTests.m b/Functions/Example/Tests/FIRFunctionsTests.m index bec96e6..5d11601 100644 --- a/Functions/Example/Tests/FIRFunctionsTests.m +++ b/Functions/Example/Tests/FIRFunctionsTests.m @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -@import XCTest; +#import <XCTest/XCTest.h> #import "FIRFunctions+Internal.h" #import "FIRFunctions.h" diff --git a/Functions/Example/Tests/FUNSerializerTests.m b/Functions/Example/Tests/FUNSerializerTests.m index 707c3e7..ca2198e 100644 --- a/Functions/Example/Tests/FUNSerializerTests.m +++ b/Functions/Example/Tests/FUNSerializerTests.m @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -@import XCTest; +#import <XCTest/XCTest.h> #import "FIRError.h" #import "FUNSerializer.h" diff --git a/scripts/check_no_module_imports.sh b/scripts/check_no_module_imports.sh new file mode 100755 index 0000000..c00c1db --- /dev/null +++ b/scripts/check_no_module_imports.sh @@ -0,0 +1,41 @@ +# Copyright 2018 Google +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Fail if any source files contain Objective-C module @imports, excluding: +# * Example sources +# * Sample sources + +options=( + -n # show line numbers + -I # exclude binary files + '^@import' +) + +function exit_with_error { + echo "ERROR: @import statement found in the files above. Please use #import instead." + exit 1 +} + +git grep "${options[@]}" \ + -- ':(exclude,glob)**/Example/**' ':(exclude,glob)**/Sample/**' && exit_with_error + +# Tests are under the Example directory, so we have to separately grep them for +# @import statements (otherwise they'd be excluded). +git grep "${options[@]}" \ + -- ':(glob)**/Tests/**' ':(glob)**/TestUtils/**' ':(glob)**/IntegrationTests/**' && \ + exit_with_error + +# We need to explicitly exit 0, since we expect `git grep` to return an error +# if no @import calls are found. +exit 0 |