简体   繁体   中英

How to use SwiftUI in framework

I'm using SwiftUI inside my binary framework, I added SwiftUI.framework as Optional in Embedded Binaries and use @available so it compiles just fine with deployment target iOS 9. However I cannot use it with xcodebuild , my commands:

xcodebuild clean archive \
    -project "${PROJECT_NAME}.xcodeproj" \
    -scheme ${1} \
    -configuration ${CONFIGURATION} \
    -destination "${2}" \
    -archivePath "${3}" \
    SKIP_INSTALL=NO \
    OBJROOT="${OBJROOT}/DependentBuilds" \
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcpretty

error message:

use of undeclared type 'View'

use of unresolved identifier 'UIHostingController'

P/s: -weak_framework SwiftUI in Other Linker Flags also didn't work

SwiftUI doesn't have 32 bit header, so adding architecture flag where the error is fix the issue

#if (arch(x86_64) || arch(arm64))
//...
#endif

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM