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

Tyler's xcodebuild backend + fixed Xcode integration, fixed signing & --device #61

Merged
merged 20 commits into from
Jan 17, 2025

Conversation

stackotter
Copy link
Owner

In this PR

  • Tyler's xcodebuild backend which fixes cross-compilation from macOS to non-macOS Apple platforms (such as iOS). It fixes platform conditional dependencies and macros among other features.
  • Fixed Xcode integration (swift bundler generate-xcode-support got broken by some changes I made a little while ago)
  • Fixed signing for physical devices (needed to generate some basic entitlements when not provided)
  • A --device command-line option for specifying which physical iOS device to target when running/bundling
  • Smarter handling of --platform, --simulator and --device. Swift Bundler can now infer the platform from the selected device/simulator.
  • A bunch of refactoring in parts of the code-base related to device handling.

furby-tm and others added 20 commits January 16, 2025 14:20
* Add new conditional arg to determine if building with swift/xcodebuild.

Signed-off-by: furby™ <[email protected]>

* Get things minimally working.
* TODO refactor/cleanup, explore SDK generator alternative
  to remove xcodebuild - xcode dependency.

Signed-off-by: furby™ <[email protected]>

* Add xcbeautify.

Signed-off-by: furby™ <[email protected]>

* Use xcbeautify from brew.

Signed-off-by: furby™ <[email protected]>

* Fixup xcbeautify for cross-platform pretty build output.

Signed-off-by: furby™ <[email protected]>

* Fix problematic bundle path and Xcode generation.

Signed-off-by: furby™ <[email protected]>

* Use provided CLI output directory or default for xcodebuild.

Signed-off-by: furby™ <[email protected]>

* Bundling of xcodebuild products, a success.

Signed-off-by: furby™ <[email protected]>

* Automatically propagate all xcodebuild destinations.
* the simctl simulators listing actually has enough metadata
  to generate all the available xcodebuild destinations, and
  it was in json format. :)

Signed-off-by: furby™ <[email protected]>

* Migrate xcodebuild logic to XcodeBuildManager.

Signed-off-by: furby™ <[email protected]>

* Migrate OSSimulators to own file.

Signed-off-by: furby™ <[email protected]>

* Remove unused bundler extension.

Signed-off-by: furby™ <[email protected]>

* Workaround a strange compiler bug on Linux.

Signed-off-by: furby™ <[email protected]>

* Fix GraphViz dependency.

Signed-off-by: furby™ <[email protected]>

* Add --xcodebuild flag, also support xcodebuild for macOS if true.

Signed-off-by: furby™ <[email protected]>

* Fix doc comment for new --xcodebuild flag.

Signed-off-by: furby™ <[email protected]>

* Specify a -destination to xcodebuild for macOS.

Signed-off-by: furby™ <[email protected]>

* Fix a case where copying exe from xcodebuild may fail.
* In some cases, for reasons unknown, xcodebuild may generate an
  app bundle in it's built products path, and will place the executable
  inside this app bundle, this fix issues a workaround to use that path
  to copy the executable instead, only if it exists.

Signed-off-by: furby™ <[email protected]>

* Fix incorrectly adjusting rpath for pre-bundled executables.

Signed-off-by: furby™ <[email protected]>

* Support tvOS with xcodebuild, add simulator utilities.

Signed-off-by: furby™ <[email protected]>

* Sort xcodebuild destinations, to default to latest installed OS version.

Signed-off-by: furby™ <[email protected]>

* Add support for bundling projects with an xcodeproj.

Signed-off-by: furby™ <[email protected]>

* Fix stripping of first 3 chars of dynamic library names.

Signed-off-by: furby™ <[email protected]>

* Drop xcodeproj support, terminate if xcodebuild tries to build a xcodeproj.

Signed-off-by: furby™ <[email protected]>

* Add '--no-xcodebuild' flag to force swiftpm on embedded darwin platforms.

Signed-off-by: furby™ <[email protected]>

* Remove unused outputDirectory arg and misc. warnings.

Signed-off-by: furby™ <[email protected]>

* Fixup merge conflicts.

Signed-off-by: furby™ <[email protected]>

* Fix merge conflicts & strange formatting issue.

Signed-off-by: furby™ <[email protected]>

* Fix some other strange formatting issues.

Signed-off-by: furby™ <[email protected]>

* Use iterators on OS simulator listing.

Signed-off-by: furby™ <[email protected]>

* Fix resource bundles failing to copy with xcodebuilt products.

Signed-off-by: furby™ <[email protected]>

* Add reusable logic for checking whether in xcodebuild context.
* Restores the async bundle command to be immutable again, instead of mutable.

Signed-off-by: furby™ <[email protected]>

* Make '--no-xcodebuild' logic easier to understand.

Signed-off-by: furby™ <[email protected]>

* furby™ signed off

Signed-off-by: Tyler Furby <[email protected]>
Signed-off-by: furby™ <[email protected]>

* Fix superfluous `starting [config] build` msg.

Signed-off-by: furby™ <[email protected]>

* only codesign with adhoc signature on embedded.

Signed-off-by: furby™ <[email protected]>

* Add additional --Xswiftpm args to xcodebuild.

Signed-off-by: furby™ <[email protected]>

---------

Signed-off-by: furby™ <[email protected]>
Signed-off-by: Tyler Furby <[email protected]>
Will need a new metadata approach to re-enable metadata insertion
when codesigning.
Without these changes I was getting 'The application could not be
verified'. We only generate the entitlements if the user doesn't provide
their own.
Removed a bunch of Xcode simulator parsing logic that isn't necessary
now that we just build for a generic OS target.
The automatic entitlements generation was running whenever signing an
app bundle, however it should only have been happening when signing
app bundles for platforms requiring provisioning profiles.
The Xcode support files (xcschemes) interfere with the build/bundling
process because they call Swift Bundler themselves so you end up with
Swift Bundler gettings invoked by Swift Bundler but with different
arguments provided by the xcodebuild post-build action, and it all
starts getting pretty messy.
xcbeautify integration can be disabled using
SWIFT_BUNDLER_USE_XCBEAUTIFY=0.
Swift Bundler is a lot smarter with its existing --platform and
--simulator options, and its new --device option. It can now infer the
platform from the device/simulator selected, and vice versa. Even just
the --device option alone will be a big QoL improvement.

Rewrote device handling and app running in the process and it's all a
lot nicer now. Less repeated code. That being said, my Xcode destination
parsing code may cancel out all the gains of that refactoring...
Building universal binaries directly seems to be broken for all Xcode
versions available in the latest macOS runners, so for now we can just
build the x86_64 and arm64 binaries separately then combine using lipo.
@stackotter stackotter merged commit c904535 into main Jan 17, 2025
5 of 6 checks passed
@stackotter stackotter deleted the xcodebuild branch January 17, 2025 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants