Cannot build with XCFramework in plugin
ddfreiling opened this issue · comments
Environment
Provide version numbers for the following components (information can be retrieved by running tns info
in your project folder or by inspecting the package.json
of the project):
- CLI: 6.3.3
- Cross-platform modules: 6.3.2
- iOS Runtime: 6.3.0
- Android Runtime (if applicable):
- Plugin(s): https://github.com/Notalib/nativescript-webview-ext/tree/ba57098ef56a846720febeb164324944a523a8b9
Describe the bug
A project with a plugin which includes a .XCFramework in its /platforms/ios can prepare just fine, but when you try to build it, it fails because of the strip-dynamic-framework-architectures.sh
script, which does not seem to support XCFrameworks.
To Reproduce
tns create mydemo --ng
tns plugin add @nota/nativescript-webview-ext@xcframework
tns build ios
Expected behavior
Expect that tns build
does not try to strip out architectures from an .XCFramework from a plugin. https://github.com/NativeScript/ios-runtime/blob/master/build/project-template/internal/strip-dynamic-framework-architectures.sh should probably be updated to support .XCFramework libraries.
Sample project
See repro. Plugin source at https://github.com/Notalib/nativescript-webview-ext/tree/ba57098ef56a846720febeb164324944a523a8b9
Additional context
I added some debug logging to strip-dynamic-framework-architectures.sh and got this output. It seems it's trying to use lipo to remove the only architecture of a non-fat Framework inside an XCFramework.
==========================================
strip-dynamic-frameworks
- with path: /Users/b044554/code/tns-plugins/nativescript-webview-ext/demo/platforms/ios/build/Debug-iphonesimulator/demo.app/Frameworks
- valid archs: i386 x86_64
==========================================
Stripping frameworks in /Users/b044554/code/tns-plugins/nativescript-webview-ext/demo/platforms/ios/build/Debug-iphonesimulator/demo.app/Frameworks
- skip ./NotaWebViewExt.xcframework/ios-x86_64-simulator/NotaWebViewExt.framework/_CodeSignature/CodeResources
- get arch for ./NotaWebViewExt.xcframework/ios-x86_64-simulator/NotaWebViewExt.framework/NotaWebViewExt
- got Non-fat file: ./NotaWebViewExt.xcframework/ios-x86_64-simulator/NotaWebViewExt.framework/NotaWebViewExt is architecture: x86_64
- skip ./NotaWebViewExt.xcframework/ios-x86_64-simulator/NotaWebViewExt.framework/Headers/NotaWebViewExt-Swift.h
- skip ./NotaWebViewExt.xcframework/ios-x86_64-simulator/NotaWebViewExt.framework/Headers/NotaWebViewExt.h
- skip ./NotaWebViewExt.xcframework/ios-x86_64-simulator/NotaWebViewExt.framework/Modules/NotaWebViewExt.swiftmodule/x86_64-apple-ios-simulator.swiftinterface
- skip ./NotaWebViewExt.xcframework/ios-x86_64-simulator/NotaWebViewExt.framework/Modules/NotaWebViewExt.swiftmodule/x86_64-apple-ios-simulator.swiftdoc
- skip ./NotaWebViewExt.xcframework/ios-x86_64-simulator/NotaWebViewExt.framework/Modules/NotaWebViewExt.swiftmodule/x86_64.swiftdoc
- skip ./NotaWebViewExt.xcframework/ios-x86_64-simulator/NotaWebViewExt.framework/Modules/NotaWebViewExt.swiftmodule/x86_64.swiftinterface
- skip ./NotaWebViewExt.xcframework/ios-x86_64-simulator/NotaWebViewExt.framework/Modules/module.modulemap
- skip ./NotaWebViewExt.xcframework/ios-x86_64-simulator/NotaWebViewExt.framework/Info.plist
- skip ./NotaWebViewExt.xcframework/ios-arm64/NotaWebViewExt.framework/_CodeSignature/CodeResources
- get arch for ./NotaWebViewExt.xcframework/ios-arm64/NotaWebViewExt.framework/NotaWebViewExt
- got Non-fat file: ./NotaWebViewExt.xcframework/ios-arm64/NotaWebViewExt.framework/NotaWebViewExt is architecture: arm64
- remove arch arm64 in ./NotaWebViewExt.xcframework/ios-arm64/NotaWebViewExt.framework/NotaWebViewExt
fatal error: lipo: input file (./NotaWebViewExt.xcframework/ios-arm64/NotaWebViewExt.framework/NotaWebViewExt) must be a fat file when the -remove option is specified
Command PhaseScriptExecution failed with a nonzero exit code
Hi @ddfreiling, I tried to reproduce the issue, but it seems not reproducible with Xcode 11.3. What is your version (please check with xcodebuild -version
). I got the following output of the strip script:
Stripping frameworks in /Users/bektchiev/work/_scratch/mydemo/platforms/ios/build/Debug-iphonesimulator/mydemo.app/Frameworks
Architectures of ./NotaWebViewExt.framework/NotaWebViewExt: x86_64
Architectures of ./NativeScript.framework/NativeScript: i386 x86_64 armv7 arm64
Stripped ./NativeScript.framework/NativeScript of architectures: armv7 arm64
Code Signing ./NativeScript.framework/NativeScript with Identity -
/usr/bin/codesign --force --sign - --preserve-metadata=identifier,entitlements ./NativeScript.framework/NativeScript
./NativeScript.framework/NativeScript: replacing existing signature
Architectures of ./TNSWidgets.framework/TNSWidgets: i386 x86_64 armv7 arm64
Stripped ./TNSWidgets.framework/TNSWidgets of architectures: armv7 arm64
Code Signing ./TNSWidgets.framework/TNSWidgets with Identity -
/usr/bin/codesign --force --sign - --preserve-metadata=identifier,entitlements ./TNSWidgets.framework/TNSWidgets
./TNSWidgets.framework/TNSWidgets: replacing existing signature
~/work/_scratch/mydemo/platforms/ios
As you can see the .xcframework
bundle isn't copied by Xcode into the .app/Frameworks
directory but only the relevant platform's .framework
. Maybe its something that Apple have changed in the latest Xcode version...
I've verified that the plugin version is correct and contains the .XCFramework in ./node_modules/@nota/nativescript-webview-ext/platforms/ios/NotaWebViewExt.xcframework