MobileNativeFoundation/rules_xcodeproj

Bug: iOS extension scheme requires running main application first to reflect code changes

seshness opened this issue ยท 4 comments

Description

๐Ÿ‘‹ I have an iOS application with a share extension using rules_xcodeproj.

When I make code changes to my application and run the share extension scheme in Xcode to start MobileSafari in a simulator, I don't see my changes reflected.

Reproduction steps

I created a couple of minimal repos to repro what I'm seeing:

Behaviour Project generation method Repository
Expected Vanilla Xcode https://github.com/seshness/SampleSharingApp
Unexpected Bazel + rules_xcodeproj https://github.com/seshness/SampleSharingAppBazel

In the Vanilla Xcode case, I can

  1. Open the Xcode project.
  2. Make a change to ShareViewController.swift, eg. change the alert text.
  3. Run the ShareExtension scheme with Safari in a simulator.
  4. See the updated text when triggering the share action from a share sheet.

In the Bazel + rules_xcodeproj case, I need to

  1. Open the Xcode project (generated with bazel run //:xcodeproj).
  2. Make a change to ShareViewController.swift.
  3. Run the iOSApp scheme for the iOS application. Let the app launch on the Simulator.
  4. Run the ShareExt scheme with Safari in a simulator.
  5. See the updated text when triggering the share action from a share sheet.

Expected behavior

I would like running the extension's scheme only to be sufficient to see code changes to the extension.

rules_xcodeproj version

1.18.0

Xcode version

15.3 (15E204a)

Bazel version

7.1.1

rules_apple version

3.4.0

rules_swift version

1.17.0

Additional information

I tried comparing the two generated schemes:

  1. Vanilla Xcode: SampleSharingApp.xcodeproj/xcshareddata/xcschemes/ShareExtension.xcscheme
  2. Bazel + rules_xcodeproj: SampleSharingAppBazel.xcodeproj/xcshareddata/xcschemes/ShareExt.xcscheme

and noticed Vanilla Xcode sets askForAppToLaunch = "Yes" whereas the Bazel-generated scheme suspiciously does not.

Does changing the scheme to match fix it? I think it wouldn't, since I think it's related to copying outputs. I'm also surprised that d44b4ed didn't fix this. We are probably doing something else wrong, possibly order related, between the host extension and the app.

Changing the scheme to include askForAppToLaunch = "Yes" does not fix it :(

Thanks for the pointer! I'll try poking at the copy outputs phase.

I think I found a significant difference between the vanilla Xcode project & Bazel project. In the vanilla Xcode version there's a 'Target Dependency' in the main application for the extension. In the Bazel-generated project there's a BazelDependencies Target Dependency but no extension.

If I add the extension manually in Xcode and attempt to launch in the simulator, I see an error:

Simulator device failed to install the application. An application bundle was not found at the provided path. Provide a valid path to the desired application bundle.

The path to the bundle uses Debug-iphoneos instead of Debug-iphonesimulator ๐Ÿค”

I saved the log output to this gist: https://gist.github.com/seshness/c83f895b7c97c572fea5df454bcdd708#file-investigation_02-md

What constructs paths for the Xcode launch action?

After #3005, I got the same error as you related to Debug-iphoneos. I tracked it down to a bug in Xcode when SUPPORTED_PLATFORMS of the extension doesn't include both simulator and device platforms. I'll get a fix for that soon.