Skip to content

Commit 367eaa9

Browse files
Make Google Places package self-contained (#202)
* Make Google Places package self-contained * Validate self-contained Places delivery
1 parent 531b1c8 commit 367eaa9

13 files changed

Lines changed: 1074 additions & 231 deletions

File tree

.github/workflows/google-foundation-validation.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ on:
1515
- "source/Google/Places/**"
1616
- "tests/E2E/Google.Foundation/**"
1717
- "tools/e2e/check-consumer-shapes.sh"
18+
- "tools/e2e/check-package-structure.sh"
19+
- "tools/e2e/check-offline-build.sh"
1820
- "tools/e2e/run-google-foundation.sh"
1921
push:
2022
branches:
@@ -32,6 +34,8 @@ on:
3234
- "source/Google/Places/**"
3335
- "tests/E2E/Google.Foundation/**"
3436
- "tools/e2e/check-consumer-shapes.sh"
37+
- "tools/e2e/check-package-structure.sh"
38+
- "tools/e2e/check-offline-build.sh"
3539
- "tools/e2e/run-google-foundation.sh"
3640
workflow_dispatch:
3741

@@ -75,12 +79,24 @@ jobs:
7579
- name: Pack Google.Places
7680
run: dotnet tool run dotnet-cake -- --target=nuget --names=Google.Places
7781

82+
- name: Package structure checks
83+
run: >-
84+
tools/e2e/check-package-structure.sh
85+
--target Places
86+
--package-dir output
87+
7888
- name: Direct and transitive consumer checks
7989
run: >-
8090
tools/e2e/check-consumer-shapes.sh
8191
--target Places
8292
--package-dir output
8393
94+
- name: Offline build proof
95+
run: >-
96+
tools/e2e/check-offline-build.sh
97+
--target Places
98+
--package-dir output
99+
84100
- name: Simulator E2E
85101
run: >-
86102
tools/e2e/run-google-foundation.sh

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ tools/e2e/*
1010
!tools/e2e/run-firebase-foundation.sh
1111
!tools/e2e/run-google-foundation.sh
1212
!tools/e2e/check-consumer-shapes.sh
13+
!tools/e2e/check-package-structure.sh
14+
!tools/e2e/check-offline-build.sh
1315
tmp-nugets
1416
*.userprefs
1517
*.DS_Store

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Firebase `12.10.0` is the current published Firebase package line.
197197
| Package | Version |
198198
| --- | --- |
199199
| `Maps` | `9.2.0.8` |
200-
| `Places` | `7.4.0.2` |
200+
| `Places` | `7.4.0.3` |
201201
| `SignIn` | `9.0.0` |
202202

203203
#### Google support packages (`AdamE.Google.iOS.*`)

build.cake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ Task ("externals")
171171
FirebaseAnalyticsDownload ();
172172
if (ARTIFACTS_TO_BUILD.Contains (GOOGLE_GOOGLE_APP_MEASUREMENT_ARTIFACT))
173173
GoogleAppMeasurementDownload ();
174+
if (ARTIFACTS_TO_BUILD.Contains (GOOGLE_PLACES_ARTIFACT))
175+
GooglePlacesDownload ();
174176
});
175177

176178
Task ("ci-setup")

components.cake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Artifact GOOGLE_ANALYTICS_ARTIFACT = new Artifact ("Google.Analy
2121
Artifact GOOGLE_CAST_ARTIFACT = new Artifact ("Google.Cast", "4.7.0.1", "15.0", ComponentGroup.Google, csprojName: "Cast");
2222
Artifact GOOGLE_MAPS_ARTIFACT = new Artifact ("Google.Maps", "9.2.0.8", "15.0", ComponentGroup.Google, csprojName: "Maps");
2323
Artifact GOOGLE_UMP_ARTIFACT = new Artifact ("Google.UserMessagingPlatform", "1.1.0.1", "15.0", ComponentGroup.Google, csprojName: "UserMessagingPlatform");
24-
Artifact GOOGLE_PLACES_ARTIFACT = new Artifact ("Google.Places", "7.4.0.2", "15.0", ComponentGroup.Google, csprojName: "Places");
24+
Artifact GOOGLE_PLACES_ARTIFACT = new Artifact ("Google.Places", "7.4.0.3", "15.0", ComponentGroup.Google, csprojName: "Places");
2525
Artifact GOOGLE_APP_CHECK_CORE_ARTIFACT = new Artifact ("Google.AppCheckCore", "11.2.0.0", "15.0", ComponentGroup.Google, csprojName: "AppCheckCore");
2626
Artifact GOOGLE_SIGN_IN_ARTIFACT = new Artifact ("Google.SignIn", "9.0.0.0", "15.0", ComponentGroup.Google, csprojName: "SignIn");
2727
Artifact GOOGLE_TAG_MANAGER_ARTIFACT = new Artifact ("Google.TagManager", "9.2.0.0", "15.0", ComponentGroup.Google, csprojName: "TagManager");
@@ -225,8 +225,10 @@ void SetArtifactsPodSpecs ()
225225
GOOGLE_UMP_ARTIFACT.PodSpecs = new [] {
226226
PodSpec.Create ("GoogleUserMessagingPlatform", "1.1.0")
227227
};
228+
// The xcframework is fetched by GooglePlacesDownload() in custom_externals_download.cake
229+
// rather than by a XamarinBuildDownload item in the .targets file.
228230
GOOGLE_PLACES_ARTIFACT.PodSpecs = new [] {
229-
PodSpec.Create ("GooglePlaces", "7.4.0")
231+
PodSpec.Create ("GooglePlaces", "7.4.0", frameworkSource: FrameworkSource.Custom)
230232
};
231233
GOOGLE_SIGN_IN_ARTIFACT.PodSpecs = new [] {
232234
PodSpec.Create ("GoogleSignIn", "9.0.0", frameworkSource: FrameworkSource.Pods),

custom_externals_download.cake

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
class ExternalDownloadSource
22
{
3+
// Most of these archives live under the Firebase analytics path, but Google publishes
4+
// other SDKs under different hosts/paths, so the prefix is overridable.
5+
const string DefaultUrlPrefix = "https://dl.google.com/firebase/ios/analytics";
6+
37
public string Id { get; }
48
public string Version { get; }
59
public string ArchiveKey { get; }
10+
public string UrlPrefix { get; }
611

7-
public ExternalDownloadSource (string id, string version, string archiveKey)
12+
public ExternalDownloadSource (string id, string version, string archiveKey, string urlPrefix = DefaultUrlPrefix)
813
{
914
Id = id;
1015
Version = version;
1116
ArchiveKey = archiveKey;
17+
UrlPrefix = urlPrefix;
1218
}
1319

1420
public string ArchiveFileName => $"{Id}-{Version}.tar.gz";
1521
public string ExtractionRootName => $"{Id}-{Version}";
16-
public string Url => $"https://dl.google.com/firebase/ios/analytics/{ArchiveKey}/{ArchiveFileName}";
22+
public string Url => $"{UrlPrefix}/{ArchiveKey}/{ArchiveFileName}";
1723
}
1824

1925
// *.tar.gz URLs can be found in the podspecs (e.g., CocoaPods Specs repo paths), such as:
2026
// FirebaseAnalytics: https://github.com/CocoaPods/Specs/tree/master/Specs/e/2/1/FirebaseAnalytics
2127
// GoogleAppMeasurement: https://github.com/CocoaPods/Specs/tree/master/Specs/e/3/b/GoogleAppMeasurement
28+
// GooglePlaces: https://github.com/CocoaPods/Specs/tree/master/Specs/c/3/2/GooglePlaces
2229
var ExternalDownloads = new Dictionary<string, ExternalDownloadSource> {
2330
{ "FirebaseAnalytics", new ExternalDownloadSource ("FirebaseAnalytics", "12.10.0", "3c185b45848d98d8") },
2431
{ "GoogleAppMeasurement", new ExternalDownloadSource ("GoogleAppMeasurement", "12.10.0", "5f5e4d8cb469941e") },
32+
{ "GooglePlaces", new ExternalDownloadSource ("GooglePlaces", "7.4.0", "3e8dc2602895d53405d075ff4eb569bff93ff1af97e69915d1e657c07ef28dd8", "https://dl.google.com/dl/geosdk") },
2533
};
2634

2735
FilePath GetArchivePath (ExternalDownloadSource source, DirectoryPath externalsPath) =>
@@ -97,6 +105,27 @@ void FirebaseAnalyticsDownload ()
97105
});
98106
}
99107

108+
void GooglePlacesDownload ()
109+
{
110+
var source = ExternalDownloads["GooglePlaces"];
111+
112+
DownloadAndExtract (
113+
source,
114+
() => DirectoryExists (new DirectoryPath ("./externals/GooglePlaces.xcframework")),
115+
(extractionRoot, externalsPath, deleteSettings) => {
116+
var frameworkSource = extractionRoot.Combine ("Frameworks").Combine ("GooglePlaces.xcframework");
117+
var frameworkDestination = externalsPath.Combine ("GooglePlaces.xcframework");
118+
119+
if (!DirectoryExists (frameworkSource))
120+
throw new Exception ($"Expected GooglePlaces.xcframework at {frameworkSource} after extraction.");
121+
122+
if (DirectoryExists (frameworkDestination))
123+
DeleteDirectory (frameworkDestination, deleteSettings);
124+
125+
CopyDirectory (frameworkSource, frameworkDestination);
126+
});
127+
}
128+
100129
void GoogleAppMeasurementDownload ()
101130
{
102131
var source = ExternalDownloads["GoogleAppMeasurement"];
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<!--
3+
Transitive consumers get exactly the same logic as direct ones. Importing the build/ copy keeps
4+
$(MSBuildThisFileDirectory) resolving to build/, which is where GooglePlaces.bundle is packed,
5+
so the bundle only has to ship once.
6+
-->
7+
<Import Project="$(MSBuildThisFileDirectory)../build/AdamE.Google.iOS.Places.targets" />
8+
</Project>

source/Google/Places/Places.csproj

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
<Nullable>enable</Nullable>
55
<ImplicitUsings>true</ImplicitUsings>
66
<IsBindingProject>true</IsBindingProject>
7-
<NoBindingEmbedding>false</NoBindingEmbedding>
7+
<NoBindingEmbedding>true</NoBindingEmbedding>
88
<SupportedOSPlatformVersion>15.0</SupportedOSPlatformVersion>
99
<RootNamespace>Google.Places</RootNamespace>
1010
<AssemblyName>Google.Places</AssemblyName>
11-
<AssemblyVersion>7.4.0.2</AssemblyVersion>
12-
<FileVersion>7.4.0.2</FileVersion>
11+
<AssemblyVersion>7.4.0.3</AssemblyVersion>
12+
<FileVersion>7.4.0.3</FileVersion>
1313
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
1414
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1515
<ProcessEnums>true</ProcessEnums>
@@ -26,7 +26,7 @@
2626
<PackageProjectUrl>https://github.com/AdamEssenmacher/GoogleApisForiOSComponents</PackageProjectUrl>
2727
<PackageLicenseFile>License.md</PackageLicenseFile>
2828
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
29-
<PackageVersion>7.4.0.2</PackageVersion>
29+
<PackageVersion>7.4.0.3</PackageVersion>
3030
</PropertyGroup>
3131
<ItemGroup>
3232
<Compile Include="..\..\AssemblyInfo.cs" />
@@ -36,15 +36,30 @@
3636
</ItemGroup>
3737
<ItemGroup>
3838
<None Include="Places.targets" Pack="True" PackagePath="build/AdamE.Google.iOS.Places.targets" />
39-
<None Include="Places.targets" Pack="True" PackagePath="buildTransitive/AdamE.Google.iOS.Places.targets" />
39+
<None Include="Places.buildTransitive.targets" Pack="True" PackagePath="buildTransitive/AdamE.Google.iOS.Places.targets" />
4040
<None Include="License.md" Pack="True" PackagePath="License.md" />
4141
<None Include="../../../icons/googleiosplaces_128x128.png" Pack="True" PackagePath="googleiosplaces_128x128.png" />
4242
</ItemGroup>
4343
<ItemGroup>
44-
<ObjcBindingApiDefinition Include="Enums.cs" />
45-
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
44+
<!--
45+
GooglePlaces.xcframework is static, so the SDK does not copy its internal Resources into
46+
consuming apps. Ship a standalone copy of the bundle next to the build/ targets file; the
47+
targets file turns it into BundleResource items rooted at the app bundle.
48+
-->
49+
<None Include="..\..\..\externals\GooglePlaces.xcframework\ios-arm64\GooglePlaces.framework\Resources\GooglePlaces.bundle\**\*" Pack="True" PackagePath="build\GooglePlaces.bundle\%(RecursiveDir)%(Filename)%(Extension)" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<!-- Metadata mirrors what Places.targets declared before the package carried the xcframework. -->
53+
<NativeReference Include="..\..\..\externals\GooglePlaces.xcframework">
54+
<Kind>Framework</Kind>
55+
<SmartLink>True</SmartLink>
56+
<ForceLoad>True</ForceLoad>
57+
<Frameworks>CoreGraphics CoreLocation QuartzCore Security UIKit</Frameworks>
58+
<LinkerFlags>-ObjC</LinkerFlags>
59+
</NativeReference>
4660
</ItemGroup>
4761
<ItemGroup>
48-
<PackageReference Include="Xamarin.Build.Download" Version="0.11.4" PrivateAssets="None" />
62+
<ObjcBindingApiDefinition Include="Enums.cs" />
63+
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
4964
</ItemGroup>
5065
</Project>

0 commit comments

Comments
 (0)