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

XCFramework missing ARM64 symbols for Simulator #864

Closed
1 of 2 tasks
pikzelz opened this issue Jul 22, 2021 · 6 comments · Fixed by #865
Closed
1 of 2 tasks

XCFramework missing ARM64 symbols for Simulator #864

pikzelz opened this issue Jul 22, 2021 · 6 comments · Fixed by #865
Labels
M1 M-SPM Package manager: Swift Package Manager, Swift, iOS and macOS O-iOS 📱 Operating system: iOS

Comments

@pikzelz
Copy link

pikzelz commented Jul 22, 2021

The xcframework is missing the required symbols for building iOS apps in the simulator when on M1 (arm64). They are present for macOS. Just not for iOS

To Reproduce
Steps to reproduce the behavior:

  1. Add the package through SPM
  2. Try to build for emulator
  3. See the following error:
Undefined symbol: _OBJC_CLASS_$_TSMessage

Expected behavior
Would expect to also build on the simulator

Environment (please complete the following information):

  • OS: macOS 11.4 (iOS 14)
  • Hardware: M1
  • Themis version: 0.13.11 (however xcframework is 0.13.10)
  • Installation way:
    • via package manager
    • built from source
@vixentael
Copy link
Contributor

Hi @pikzelz! Thank you for reporting.

Could you please take a look on the similar issue – #863. Does it feel the same? We are gathering evidence to understand what slice is missing :)

Also, could you please try to build the app on iOS device — does it work on device, but doesn't on Sim?

cc @ilammy @julepka

@vixentael vixentael added M-SPM Package manager: Swift Package Manager, Swift, iOS and macOS M1 O-iOS 📱 Operating system: iOS labels Jul 22, 2021
@pikzelz
Copy link
Author

pikzelz commented Jul 22, 2021

Hi @vixentael,

Thanks. I checked out the issue, but they seem to not be related. I've been able to build a working xcframework with modifying a build script I used in the past to create an xcframework.

What I also did was add the OpenSSL framework through SwiftPM instead of using the Carthage variant. This properly embeds OpenSSL within the .xcframework. I'm now able to run Themis within the simulator (haven't tested on device yet).

I also made sure that I removed ARM64 from the excluded architecture section in Xcode on the iOS target.

I used the following script to build the xcframework from xcode as an aggregate target:

#!/usr/bin/env bash

FWNAME="themis"
OUTPUT_DIR="./Release"
BUILD_DIR="${OUTPUT_DIR}/build"
COMMON=" -configuration Release -derivedDataPath ${BUILD_DIR} -quiet BUILD_LIBRARY_FOR_DISTRIBUTION=YES "

#iOS Devices
xcodebuild build \
    $COMMON \
    -scheme "Themis (iOS)" \
    -sdk iphoneos \
    -destination 'generic/platform=iOS'

rm -rf "${OUTPUT_DIR}/iphoneos"
mkdir -p "${OUTPUT_DIR}/iphoneos"
ditto "${BUILD_DIR}/Build/Products/Release-iphoneos/${FWNAME}.framework" "${OUTPUT_DIR}/iphoneos/${FWNAME}.framework"
rm -rf "${BUILD_DIR}"

#iOS Simulator
xcodebuild build \
    $COMMON \
    -scheme "Themis (iOS)" \
    -sdk iphonesimulator \
    -destination 'generic/platform=iOS Simulator' \
    ONLY_ACTIVE_ARCH=NO

rm -rf "${OUTPUT_DIR}/iphonesimulator"
mkdir -p "${OUTPUT_DIR}/iphonesimulator"
ditto "${BUILD_DIR}/Build/Products/Release-iphonesimulator/${FWNAME}.framework" "${OUTPUT_DIR}/iphonesimulator/${FWNAME}.framework"
rm -rf "${BUILD_DIR}"

#macOS
xcodebuild build \
    $COMMON \
    -scheme "Themis (macOS)" \
    -destination 'generic/platform=macOS' \
    ONLY_ACTIVE_ARCH=NO

rm -rf "${OUTPUT_DIR}/macosx"
mkdir -p "${OUTPUT_DIR}/macosx/${FWNAME}.framework"
ditto "${BUILD_DIR}/Build/Products/Release/${FWNAME}.framework" "${OUTPUT_DIR}/macosx/${FWNAME}.framework"
rm -rf "${BUILD_DIR}"

xcodebuild -quiet -create-xcframework \
    -framework "${OUTPUT_DIR}/iphoneos/${FWNAME}.framework" \
    -framework "${OUTPUT_DIR}/iphonesimulator/${FWNAME}.framework" \
    -framework "${OUTPUT_DIR}/macosx/${FWNAME}.framework" \
    -output "${OUTPUT_DIR}/Frameworks/${FWNAME}.xcframework"
    
rm -rf "${OUTPUT_DIR}/iphoneos"
rm -rf "${OUTPUT_DIR}/iphonesimulator"
rm -rf "${OUTPUT_DIR}/macosx"

@vixentael
Copy link
Contributor

vixentael commented Jul 23, 2021

thank you @pikzelz! This is super helpful. We will make sure on adding macOS slice and publish a hotfix soon.

cc @julepka

@julepka
Copy link
Contributor

julepka commented Jul 26, 2021

@pikzelz Thanks for your help with this issue!
Can you try the recent hotfix 0.13.12 and let us know if it works well for you?
Thanks in advance!

@pikzelz
Copy link
Author

pikzelz commented Jul 26, 2021

@julepka Thanks! This works now. Can throw my local XCFramework away again!

@vixentael
Copy link
Contributor

💃 💃 💃 💃 💃

great job @julepka @pikzelz!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M1 M-SPM Package manager: Swift Package Manager, Swift, iOS and macOS O-iOS 📱 Operating system: iOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants