Skip to content

Conversation

chkuang-g
Copy link
Collaborator

@chkuang-g chkuang-g commented Apr 1, 2022

For more context b/196153528

A couple of changes:

  1. Change Link Framework Statically setting default value to true
  2. Add a workaround to properly link Swift Standard Library if any pod is using Swift Framework and Link Framework Statically is true. This workaround is turned OFF by default. It basically does the following
    a. Add a dummy.swift file to Xcode project
    b. Set SWIFT_VERSION build property. If Xcode project has multiple targets (generated by Unity 2019.3+), then also enable CLANG_ENABLE_MODULES and ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES

Change the default value of "Link Framework statically" in iOS Resolver
settings to TRUE since it is very likely that some pod frameworks
includes pre-built static libraries, and can cause unexpected crash
in runtime if the app is build with with multiple targets
(Unity 2019.3+).
The Xcode project generate from Unity may not be able to link Swift
Standard Libaries properly if
1. Some pods include Swift frameworks
2. Podfile sets to link frameworks statically

The workround attempts to fix this by
1. Add a Dummy.swift file to the Xcode project.
2. Enable `CLANG_ENABLE_MODULES` and `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES`
   build settings.
3. Change `SWIFT_VERSION` to the value specified in iOS Resolver
   settings. Default to "5".

This workaround is turned OFF by default.
@chkuang-g chkuang-g self-assigned this Apr 1, 2022
@chkuang-g
Copy link
Collaborator Author

chkuang-g commented Apr 1, 2022

Test with Analytics testapp, FirebaseAnalytics 8.8.0 (.unitypackage. This depends on a pod containing static library) and Facebook Unity SDK (this depends on a pod containing Swift Framework). and Xcode 13.2.

Due to that Facebook SDK always append use_frameworks! at the end of Podfile, which will be duplicated with use_frameworks! :linkage => :static added by EDM4U, I would need to manually move that line, run pod install under Xcode project folder before building Xcode app.

Verified in the following Unity versions

Unity Version Checked
2018.4.36
2019.4.30
2020.3.18
2021.2.17 Unable Build, not related to EDM4U
2022.1.0 Unable Build, not related to EDM4U

The Xcode project generate from Unity may not be able to link Swift
Standard Libaries properly if
1. Some pods include Swift frameworks
2. Podfile sets to link frameworks statically

The workround attempts to fix this by
1. Add a Dummy.swift file to the Xcode project.
2. Enable `CLANG_ENABLE_MODULES` and `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES`
   build settings.
3. Change `SWIFT_VERSION` to the value specified in iOS Resolver
   settings. Default to "5".

This workaround is turned OFF by default.
@chkuang-g chkuang-g merged commit 4d58f41 into master Apr 4, 2022
@chkuang-g chkuang-g deleted the patch/swift-framework branch April 4, 2022 18:17
@googlesamples googlesamples locked and limited conversation to collaborators May 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants