Skip to content

Commit

Permalink
Use Swift packages for direct dependencies and drop Carthage
Browse files Browse the repository at this point in the history
Only 2 dependencies left:
* Testing only: OHHTTPStubs for network mocking
* GzipSwift: for TestUtils to decode gzip'ed payloads

Both are available as Swift packages, so we can consume them that way.
  • Loading branch information
badboy committed Jun 13, 2022
1 parent 7f5039f commit 3073252
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 30 deletions.
3 changes: 0 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,6 @@ jobs:
command: |
rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios
# Bootstrap dependencies
bin/bootstrap.sh
UDID=$(xcrun xctrace list devices 2>&1 | grep 'iPhone 11 Simulator (14' | awk -F'[()]' '{print $4}')
xcrun simctl boot "$UDID"
# Store build type for use in cache key
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

[Full changelog](https://github.com/mozilla/glean/compare/v50.0.1...main)

* iOS
* Dropped usage of Carthage for internal dependencies.

# v50.0.1 (2022-05-25)

[Full changelog](https://github.com/mozilla/glean/compare/v50.0.0...v50.0.1)
Expand Down
2 changes: 0 additions & 2 deletions Cartfile.private

This file was deleted.

7 changes: 0 additions & 7 deletions bin/bootstrap.sh

This file was deleted.

8 changes: 3 additions & 5 deletions docs/dev/ios/setup-ios-build-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
## Prepare your build environment

1. Install Xcode 13.0 or higher.
2. Install [Carthage](https://github.com/Carthage/Carthage): `brew install carthage`
3. Ensure you have Python 3 installed: `brew install python`
4. Install linting and formatting tools: `brew install swiftlint`
5. Run `bin/bootstrap.sh` to download dependencies.
6. (Optional, only required for building on the CLI) Install [xcpretty](https://github.com/xcpretty/xcpretty): `gem install xcpretty`
2. Ensure you have Python 3 installed: `brew install python`
3. Install linting and formatting tools: `brew install swiftlint`
4. (Optional, only required for building on the CLI) Install [xcpretty](https://github.com/xcpretty/xcpretty): `gem install xcpretty`

### Setting up Rust

Expand Down
62 changes: 54 additions & 8 deletions glean-core/ios/Glean.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
AC1DB401237EF0ED005A0F8A /* Glean.h in Headers */ = {isa = PBXBuildFile; fileRef = BF3DE3942243A2F20018E23F /* Glean.h */; settings = {ATTRIBUTES = (Public, ); }; };
BF10008023548B0500064051 /* MemoryDistributionMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF10007F23548B0500064051 /* MemoryDistributionMetric.swift */; };
BF10008223548C4400064051 /* MemoryDistributionMetricTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF10008123548C4400064051 /* MemoryDistributionMetricTests.swift */; };
BF234D1F25CC4A580015D957 /* Gzip.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD6E200525CAD66100C7EF2B /* Gzip.xcframework */; };
BF2E57052334B77D00364D92 /* EventMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF2E57042334B77D00364D92 /* EventMetric.swift */; };
BF2E57072334BD7600364D92 /* EventMetricTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF2E57062334BD7600364D92 /* EventMetricTests.swift */; };
BF30FDC22332312300840607 /* Sysctl.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF30FDC12332312300840607 /* Sysctl.swift */; };
Expand Down Expand Up @@ -61,7 +60,9 @@
CD0F7CC026F0F27900EDA6A4 /* UrlMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD0F7CBF26F0F27900EDA6A4 /* UrlMetric.swift */; };
CD0F7CC226F0F28900EDA6A4 /* UrlMetricTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD0F7CC126F0F28900EDA6A4 /* UrlMetricTests.swift */; };
CD38786D271DCCC700C097D8 /* libglean_ffi.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CD38786C271DCCC700C097D8 /* libglean_ffi.a */; };
CD6E200A25CAD68900C7EF2B /* OHHTTPStubs.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD6E200925CAD68900C7EF2B /* OHHTTPStubs.xcframework */; };
CD70CF932850D69500FC2014 /* Gzip in Frameworks */ = {isa = PBXBuildFile; productRef = CD70CF922850D69500FC2014 /* Gzip */; };
CD70CF982850D77200FC2014 /* OHHTTPStubs in Frameworks */ = {isa = PBXBuildFile; productRef = CD70CF972850D77200FC2014 /* OHHTTPStubs */; };
CD70CF9A2850D79200FC2014 /* OHHTTPStubsSwift in Frameworks */ = {isa = PBXBuildFile; productRef = CD70CF992850D79200FC2014 /* OHHTTPStubsSwift */; };
CD81DCFA282A8F9B00347965 /* RateMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD81DCF9282A8F9A00347965 /* RateMetric.swift */; };
CD81DCFC282A911400347965 /* RateMetricTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD81DCFB282A911400347965 /* RateMetricTests.swift */; };
CDBFB4DC27C3FA520045CCB9 /* Dispatchers.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDBFB4DB27C3FA520045CCB9 /* Dispatchers.swift */; };
Expand Down Expand Up @@ -138,8 +139,6 @@
CD0F7CC126F0F28900EDA6A4 /* UrlMetricTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UrlMetricTests.swift; sourceTree = "<group>"; };
CD387868271D9CD100C097D8 /* glean.udl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = glean.udl; path = ../../src/glean.udl; sourceTree = "<group>"; };
CD38786C271DCCC700C097D8 /* libglean_ffi.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libglean_ffi.a; path = ../../target/libglean_ffi.a; sourceTree = "<group>"; };
CD6E200525CAD66100C7EF2B /* Gzip.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Gzip.xcframework; path = ../../Carthage/Build/Gzip.xcframework; sourceTree = "<group>"; };
CD6E200925CAD68900C7EF2B /* OHHTTPStubs.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = OHHTTPStubs.xcframework; path = ../../Carthage/Build/OHHTTPStubs.xcframework; sourceTree = "<group>"; };
CD81DCF9282A8F9A00347965 /* RateMetric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RateMetric.swift; sourceTree = "<group>"; };
CD81DCFB282A911400347965 /* RateMetricTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RateMetricTests.swift; sourceTree = "<group>"; };
CDBFB4DB27C3FA520045CCB9 /* Dispatchers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Dispatchers.swift; sourceTree = "<group>"; };
Expand All @@ -152,6 +151,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
CD70CF932850D69500FC2014 /* Gzip in Frameworks */,
CD38786D271DCCC700C097D8 /* libglean_ffi.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -160,9 +160,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
BF234D1F25CC4A580015D957 /* Gzip.xcframework in Frameworks */,
CD6E200A25CAD68900C7EF2B /* OHHTTPStubs.xcframework in Frameworks */,
BF3DE39B2243A2F20018E23F /* Glean.framework in Frameworks */,
CD70CF9A2850D79200FC2014 /* OHHTTPStubsSwift in Frameworks */,
CD70CF982850D77200FC2014 /* OHHTTPStubs in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -353,8 +353,6 @@
isa = PBXGroup;
children = (
CD38786C271DCCC700C097D8 /* libglean_ffi.a */,
CD6E200925CAD68900C7EF2B /* OHHTTPStubs.xcframework */,
CD6E200525CAD66100C7EF2B /* Gzip.xcframework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -417,6 +415,9 @@
dependencies = (
);
name = Glean;
packageProductDependencies = (
CD70CF922850D69500FC2014 /* Gzip */,
);
productName = Glean;
productReference = BF3DE3912243A2F20018E23F /* Glean.framework */;
productType = "com.apple.product-type.framework";
Expand All @@ -436,6 +437,10 @@
BF3DE39D2243A2F20018E23F /* PBXTargetDependency */,
);
name = GleanTests;
packageProductDependencies = (
CD70CF972850D77200FC2014 /* OHHTTPStubs */,
CD70CF992850D79200FC2014 /* OHHTTPStubsSwift */,
);
productName = GleanTests;
productReference = BF3DE39A2243A2F20018E23F /* GleanTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
Expand Down Expand Up @@ -468,6 +473,10 @@
Base,
);
mainGroup = BF3DE3872243A2F20018E23F;
packageReferences = (
CD70CF912850D69500FC2014 /* XCRemoteSwiftPackageReference "GzipSwift" */,
CD70CF942850D6F900FC2014 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */,
);
productRefGroup = BF3DE3922243A2F20018E23F /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -905,6 +914,43 @@
defaultConfigurationName = Debug;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
CD70CF912850D69500FC2014 /* XCRemoteSwiftPackageReference "GzipSwift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/1024jp/GzipSwift";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.1.1;
};
};
CD70CF942850D6F900FC2014 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/alisoftware/OHHTTPStubs";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 9.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
CD70CF922850D69500FC2014 /* Gzip */ = {
isa = XCSwiftPackageProductDependency;
package = CD70CF912850D69500FC2014 /* XCRemoteSwiftPackageReference "GzipSwift" */;
productName = Gzip;
};
CD70CF972850D77200FC2014 /* OHHTTPStubs */ = {
isa = XCSwiftPackageProductDependency;
package = CD70CF942850D6F900FC2014 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */;
productName = OHHTTPStubs;
};
CD70CF992850D79200FC2014 /* OHHTTPStubsSwift */ = {
isa = XCSwiftPackageProductDependency;
package = CD70CF942850D6F900FC2014 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */;
productName = OHHTTPStubsSwift;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = BF3DE3882243A2F20018E23F /* Project object */;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"object": {
"pins" : [
{
"package": "GzipSwift",
"repositoryURL" : "https://github.com/1024jp/GzipSwift",
"state" : {
"branch": null,
"revision" : "7a7f17761c76a932662ab77028a4329f67d645a4",
"version" : "5.2.0"
}
},
{
"package" : "OHHTTPStubs",
"repositoryURL" : "https://github.com/alisoftware/OHHTTPStubs",
"state" : {
"branch": null,
"revision" : "12f19662426d0434d6c330c6974d53e2eb10ecd9",
"version" : "9.1.0"
}
}
]
},
"version": 1
}
5 changes: 3 additions & 2 deletions glean-core/ios/GleanTests/GleanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

@testable import Glean
import OHHTTPStubs
import OHHTTPStubsSwift
import XCTest

private typealias GleanInternalMetrics = GleanMetrics.GleanInternalMetrics
Expand Down Expand Up @@ -376,7 +377,7 @@ class GleanTests: XCTestCase {
self.expectation?.fulfill()
}

return OHHTTPStubsResponse(
return HTTPStubsResponse(
jsonObject: [],
statusCode: 200,
headers: ["Content-Type": "application/json"]
Expand Down Expand Up @@ -414,7 +415,7 @@ class GleanTests: XCTestCase {
self.expectation?.fulfill()
}

return OHHTTPStubsResponse(
return HTTPStubsResponse(
jsonObject: [],
statusCode: 200,
headers: ["Content-Type": "application/json"]
Expand Down
5 changes: 3 additions & 2 deletions glean-core/ios/GleanTests/TestUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@testable import Glean
import Gzip
import OHHTTPStubs
import OHHTTPStubsSwift
import XCTest

/// Stub out receiving a request on Glean's default Telemetry endpoint.
Expand Down Expand Up @@ -35,7 +36,7 @@ func stubServerReceive(callback: @escaping (String, [String: Any]?) -> Void) {

callback(pingType, payload)

return OHHTTPStubsResponse(
return HTTPStubsResponse(
jsonObject: [],
statusCode: 200,
headers: ["Content-Type": "application/json"]
Expand Down Expand Up @@ -96,7 +97,7 @@ func resetGleanDiscardingInitialPings(testCase: XCTestCase, tag: String, clearSt
}

func tearDownStubs() {
OHHTTPStubs.removeAllStubs()
HTTPStubs.removeAllStubs()
}

/// Stringify a JSON object and if unable to, just return an empty string.
Expand Down

0 comments on commit 3073252

Please sign in to comment.