bytedance / Bytedance-UnionAD

MIT License
170 stars 54 forks source link

[Feature] 默认标题 Swift Package Manager #152

Closed ddaddy closed 1 year ago

ddaddy commented 2 years ago

Can we get Swift Package Manager support or xcframework? I do not use CocoaPods and tried the manual installation, but it will not compile on an M1 Mac with the error: Building for iOS, but the linked and embedded framework 'BURelyAdSDK.framework' was built for iOS + iOS Simulator.

Using SPM or providing .xcframework would fix this issue.

charleyzhu commented 2 years ago

need to

ddaddy commented 2 years ago

Come on, we really need xcframework as we cannot use it without.

hberenger commented 1 year ago

Indeed SPM and xcframework support is essential.

Up to recently, it was possible to forge a xcframework manually from the Bytedance-UnionAD FAT frameworks, using either a tool such as xcframework-maker, or a mix of lipo / xcodebuild -create-xcframework commands as in the following example :

# (inspired from https://gist.github.com/KaQuMiQ/5c02a27c736188e75d750c630cb9eb90)
# assuming that the fat framework `BUAdSDK.framework` containing code for arch `i386`, `x86_64`,
# `armv7` and `arm64` lies in "."

mkdir ./arm64
mkdir ./x86_64

cp -R BUAdSDK.framework arm64/
xcrun lipo -remove i386 -remove armv7 -remove x86_64 ./arm64/BUAdSDK.framework/BUAdSDK -o ./arm64/BUAdSDK.framework/BUAdSDK

cp -R BUAdSDK.framework x86_64/
xcrun lipo -remove i386 -remove armv7 -remove arm64 ./x86_64/BUAdSDK.framework/BUAdSDK -o ./x86_64/BUAdSDK.framework/BUAdSDK

xcodebuild -create-xcframework -framework ./arm64/BUAdSDK.framework -framework ./x86_64/BUAdSDK.framework -output BUAdSDK.xcframework

rm -rf ./arm64
rm -rf ./x86_64

(🔝 the above might be of interest for you @ddaddy and @charleyzhu)

Unfortunately, from my tests, this trick:

Since version 4.2.0.2, xcodebuild -create-xcframework now fails with this kind of error:

error: unable to find any architecture information in the binary at 'arm64/BUAdSDK.framework/BUAdSDK': Unknown header: 0xb17c0de

This issue is hardly documented ; from the comments on this Audience network issue, it seems it may come from LLVM LTO compilation options... Maybe you recently added a -flto flag to your compilations options ? If so, could you disable them (that's what Facebook finally did) ?

Of course, the best solution would be to provide natively full xcframework support, as most other Ad Networks already do (possibly including support for M1 simulator build, as expected by this other issue).

Thank you !

zry-bd commented 1 year ago

Thank you for your feedback. We have supported Swift Package Manager from 5.2.0.6(release version, SPM version is 5.2.0-release.6) or 5.3.0.2(beta version, SPM version is 5.3.0-beta.2). Follow the details here.