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

fix: Consume Cocoa SDK as .xcframework #1002

Merged
merged 25 commits into from
Oct 13, 2022
Merged

Conversation

bitsandfoxes
Copy link
Contributor

@bitsandfoxes bitsandfoxes commented Oct 5, 2022

Currently, we build the Cocoa SDK and then copy the device and simulator .framework directories into the Plugins/iOS folder. They get excluded from Unity through the .meta files because, for the generated XCode project, we set the SDK up ourselves.

On the M1 the Carthage build artifacts are named slightly different which breaks our hardcoded paths within the .xcframework.

Since we're currently setting the .frameworks up to be ignored anyway and we manually copy them to the generated Xcode project, the idea here is:

  • Copy whole the generated .xcframework instead of the individual .framework into the plugins folder
  • Append ~ to it so Unity ignores it (and does not copy the frameworks from within during XCode generation)
  • Set up the missing linking to the framework within the Xcode project
  • Update package snapshot test

@bitsandfoxes bitsandfoxes marked this pull request as ready for review October 13, 2022 09:33
@bitsandfoxes bitsandfoxes requested a review from vaind as a code owner October 13, 2022 09:33
Comment on lines +162 to +163
<Message Importance="High" Text="Creating xcconfig file to enable Bitcode." />
<WriteLinesToFile File="$(SentryCocoaRoot)unity.xcconfig" Lines="ENABLE_BITCODE = YES" Overwrite="true" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Cocoa builds with Bitcode disabled by default. Unity Xcode projects have Bitcode enabled by default. Bitcode has been deprecated but while we wait for Unity to update the generation we build the Cocoa SDK with a temporary config file to enable it.

Comment on lines +29 to +30
# Override the generated GUID as part of the .bcsymbolmap
$snapshotContent = $snapshotContent -replace "BCSymbolMaps\/.+?(\.)","BCSymbolMaps/*."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Filtering here, since Bitcode is now part of the .xcframework and the Guid changes with every build.

Copy link
Collaborator

@vaind vaind left a comment

Choose a reason for hiding this comment

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

LGTM

<Exec WorkingDirectory="$(SentryCocoaRoot)" Command="carthage build --use-xcframeworks --no-skip-current --platform iOS"></Exec>
<!-- Workaround to enable building the Cocoa SDK with Bitcode enabled -->
<Message Importance="High" Text="Creating xcconfig file to enable Bitcode." />
<WriteLinesToFile File="$(SentryCocoaRoot)unity.xcconfig" Lines="ENABLE_BITCODE = YES" Overwrite="true" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens if we have it enabled here and users want to disable it (in Unity) - would everything work normally? Just checking because nothing coming from xcode would surprise me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I did test that and Xcode just rolls with it.

@bitsandfoxes bitsandfoxes merged commit 4503677 into main Oct 13, 2022
@bitsandfoxes bitsandfoxes deleted the feat/ios/xcframework branch October 13, 2022 15:39
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.

3 participants