Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: Build _only_ a staticlib. #2285

Merged
merged 3 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

* iOS
* Avoid building a dynamic library ([#2285](https://github.com/mozilla/glean/pull/2285)).
Note: v51.8.1 and 51.8.2 are **not** working on iOS and will break the build due to accidentally including a link to a dynamic library.

# v51.8.2 (2022-11-17)

[Full changelog](https://github.com/mozilla/glean/compare/v51.8.1...v51.8.2)
Expand Down
6 changes: 3 additions & 3 deletions build-scripts/xc-universal-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ for arch in $ARCHS; do

# Intel iOS simulator
export CFLAGS_x86_64_apple_ios="-target x86_64-apple-ios"
$HOME/.cargo/bin/cargo build -p $FFI_TARGET --lib $RELFLAG --target x86_64-apple-ios
$HOME/.cargo/bin/cargo rustc -p $FFI_TARGET --lib --crate-type staticlib $RELFLAG --target x86_64-apple-ios
;;

arm64)
if [ $IS_SIMULATOR -eq 0 ]; then
# Hardware iOS targets
$HOME/.cargo/bin/cargo build -p $FFI_TARGET --lib $RELFLAG --target aarch64-apple-ios
$HOME/.cargo/bin/cargo rustc -p $FFI_TARGET --lib --crate-type staticlib $RELFLAG --target aarch64-apple-ios
else
# M1 iOS simulator -- currently in Nightly only and requires to build `libstd`
$HOME/.cargo/bin/cargo build -p $FFI_TARGET --lib $RELFLAG --target aarch64-apple-ios-sim
$HOME/.cargo/bin/cargo rustc -p $FFI_TARGET --lib --crate-type staticlib $RELFLAG --target aarch64-apple-ios-sim
fi
esac
done
2 changes: 1 addition & 1 deletion glean-core/bundle-android/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name = "glean-bundle-android"
version = "1.0.0"
authors = ["The Glean Team <glean-team@mozilla.com>"]
edition = "2018"
description = "Static/Dynamic library build of glean-ffi, for use in Android builds"
description = "Dynamic library build of glean-ffi, for use in Android builds"
repository = "https://github.com/mozilla/glean"
license = "MPL-2.0"

Expand Down
8 changes: 4 additions & 4 deletions samples/ios/app/glean-sample-app.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
BFDA7AD02371CE4900575C7B /* ViewControllerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFDA7ACF2371CE4900575C7B /* ViewControllerTest.swift */; };
BFDA7AD22371D2BA00575C7B /* MockServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFDA7AD12371D2BA00575C7B /* MockServer.swift */; };
BFED6B2C238C1638006E2BC4 /* DeletionRequestPingTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFED6B2B238C1638006E2BC4 /* DeletionRequestPingTest.swift */; };
CD70CF8C2850D3F400FC2014 /* Glean.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD70CF8B2850D3F400FC2014 /* Glean.xcframework */; };
CD70CF8E2850D4B700FC2014 /* Swifter in Frameworks */ = {isa = PBXBuildFile; productRef = CD70CF8D2850D4B700FC2014 /* Swifter */; };
CD70CF902850D4BA00FC2014 /* Gzip in Frameworks */ = {isa = PBXBuildFile; productRef = CD70CF8F2850D4BA00FC2014 /* Gzip */; };
CD802A47292E5AC800D46BE9 /* Glean.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD70CF8B2850D3F400FC2014 /* Glean.xcframework */; };
CD802A48292E5AC800D46BE9 /* Glean.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CD70CF8B2850D3F400FC2014 /* Glean.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we need to embed this framework in the app now? Is this something downstream consumers will need to do as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the sample app, without embedding it it wouldn't work on my test device.
Other users consume it as a Swift package through glean-swift, which does the right thing already.
Only our sample app uses the bare xcframework, and those need to be embedded to run on actual hardware.

CD99D84625F131D600BD5339 /* EventPingTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD99D84525F131D600BD5339 /* EventPingTest.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -49,6 +50,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
CD802A48292E5AC800D46BE9 /* Glean.xcframework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -79,7 +81,6 @@
BFDA7AD12371D2BA00575C7B /* MockServer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockServer.swift; sourceTree = "<group>"; };
BFE1E7D523435A600067A12A /* sdk_generator.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = sdk_generator.sh; sourceTree = "<group>"; };
BFED6B2B238C1638006E2BC4 /* DeletionRequestPingTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeletionRequestPingTest.swift; sourceTree = "<group>"; };
CD70CF8A2850D3DE00FC2014 /* app */ = {isa = PBXFileReference; lastKnownFileType = folder; name = app; sourceTree = "<group>"; };
CD70CF8B2850D3F400FC2014 /* Glean.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Glean.xcframework; path = ../../../build/archives/Glean.xcframework; sourceTree = "<group>"; };
CD99D84525F131D600BD5339 /* EventPingTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventPingTest.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand All @@ -89,7 +90,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
CD70CF8C2850D3F400FC2014 /* Glean.xcframework in Frameworks */,
CD802A47292E5AC800D46BE9 /* Glean.xcframework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -124,7 +125,6 @@
isa = PBXGroup;
children = (
CD70CF8B2850D3F400FC2014 /* Glean.xcframework */,
CD70CF8A2850D3DE00FC2014 /* app */,
BF6F41C4234346A000E222A8 /* metrics.yaml */,
BF8966592371C82E0097B7F2 /* pings.yaml */,
BFE1E7D523435A600067A12A /* sdk_generator.sh */,
Expand Down