Bytedance-UnionAD icon indicating copy to clipboard operation
Bytedance-UnionAD copied to clipboard

[Feature] Add support for Apple Silicon (M1)

Open xoridius opened this issue 2 years ago • 5 comments

Is your feature request related to a problem? Please describe. | 提出这个建议是因为遇到了什么问题?

All shipped frameworks break iOS Simulator builds on Apple Silicon (M1 macs).

Describe the solution you'd like. | 描述你期望的解决方案。

I want to be able to run apps with Bytedance SDKs in iOS simulator on M1 macs. XCFrameworks are required to include the arm64 slice for iOS devices and the macOS simulator for Macs running on Apple silicon.

Additional context | 额外信息

Migration process:

  1. Recompile libraries as XCFrameworks with arm64-simulator slice.
  2. Remove deprecated EXCLUDED_ARCHS[1] and VALID_ARCHS[2] build configuration overrides from podspecs (remove all uses of spec.pod_target_xcconfig and spec.user_target_xcconfig).

Simplified example of building framework target as XCFramework:

# archive framework for device targets
xcodebuild archive -project 'Project.xcodeproj' -scheme 'FrameworkDemo' -configuration Release -destination 'generic/platform=iOS' -archivePath 'archive/FrameworkDemo-iphoneos.xcarchive' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

# archive framework for simulator targets (code signing not required)
xcodebuild archive -project 'Project.xcodeproj' -scheme 'FrameworkDemo' -configuration Release -destination 'generic/platform=iOS Simulator' -archivePath 'archive/FrameworkDemo-iphonesimulator.xcarchive' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED="NO"

# build XCFramework
xcodebuild -create-xcframework \
-framework archive/FrameworkDemo-iphoneos.xcarchive/Products/Library/Frameworks/FrameworkDemo.framework \
-framework archive/FrameworkDemo-iphonesimulator.xcarchive/Products/Library/Frameworks/FrameworkDemo.framework \
-output archive/FrameworkDemo.xcframework

References:

  • WWDC19 XCFramework announcement https://www.wwdcnotes.com/notes/wwdc19/416/

  • Create an XCFramework https://help.apple.com/xcode/mac/current/#/dev544efab96

  • Supporting XCFrameworks by PSPDFKit https://pspdfkit.com/blog/2020/supporting-xcframeworks/, https://pspdfkit.com/blog/2021/advances-in-xcframeworks/

  • XCFramework example project https://github.com/bielikb/xcframeworks

  • Cocoapods podspec examples with binary XCFrameworks: FirebaseAnalytics UnityAds PSPDFKit OneSignal FBSDKCoreKit

  • TN3117: Resolving architecture build errors on Apple silicon https://developer.apple.com/documentation/technotes/tn3117-resolving-build-errors-for-apple-silicon

    "Only use the EXCLUDED_ARCHS build setting on targets where the final released app is not using the target’s functionality on a specific architecture, such as a Mac app that only supports a legacy feature on Intel-based Mac computers ... Do not use EXCLUDED_ARCHS with pre-compiled libraries that are not updated with support for the iOS, watchOS, or tvOS simulators on Apple silicon."

  • VALID_ARCHS flag has been deprecated since Xcode 12 (September 2020) https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes

  • VALID_ARCHS issues https://github.com/search?q=VALID_ARCHS&type=issues

  • Cocoapods docs: "user_target_xcconfig attribute is not recommended as Pods should not pollute the build settings of the user project and this can cause conflicts." https://guides.cocoapods.org/syntax/podspec.html#user_target_xcconfig

xoridius avatar Jun 05 '22 02:06 xoridius

M1 has been out almost 2 years now, we need XCFramework to support it.

ddaddy avatar Jun 09 '22 15:06 ddaddy

Related issues: #152 #144 #63

xoridius avatar Jun 14 '22 16:06 xoridius

Any update on this? If you don't have an Apple Silicon Mac to compile the .xcframework there are now even cloud services you can use. It just needs compiling as an .xcframework and then we can use it.

ddaddy avatar Jul 09 '22 09:07 ddaddy

We just dropped the SDK ¯_(ツ)_/¯

xoridius avatar Aug 08 '22 01:08 xoridius

This issue also affects the implementation of other frameworks. We hope this issue will be resolved soon.

dazy1030 avatar Oct 01 '22 18:10 dazy1030

Please prioritize this issue. The development experience with the bytedance SDK on Apple Silicon Macs is unbearable.

vadimbelyaev avatar Jan 30 '23 18:01 vadimbelyaev

For the authors: https://developer.apple.com/documentation/technotes/tn3117-resolving-build-errors-for-apple-silicon#Update-pre-compiled-libraries-from-vendors

ikesyo avatar Feb 17 '23 01:02 ikesyo

Looks like xcframework including arm64 simulator is finally supported since 5.1.0.6.

  • https://github.com/bytedance/Bytedance-UnionAD/pull/190

ikesyo avatar May 16 '23 04:05 ikesyo

Thank you for your feed back. We have supported xcframework including arm64 simulator since 5.1.0.0.

zry-bd avatar May 19 '23 06:05 zry-bd