Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28138] iOS/macOS Catalyst: Cannot build iOS-only modules

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2020-09-22T15:49:57.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.2.0
ComponentsiOS, Mac
Labelsn/a
ReporterHans Knöchel
AssigneeVijay Singh
Created2020-09-15T21:00:11.000+0000
Updated2020-09-23T18:08:00.000+0000

Description

When trying to build an iOS only module, it fails with multiple errors. The error can be reproduced in this module: https://github.com/hansemannn/titanium-widget-kit The reason may be that the module contains the iOS-only framework "WidgetKit". I unselected macOS support in the Xcode project, but the CLI still tries to build for Catalyst as well.

Comments

  1. Ewan Harris 2020-09-15

    [~hknoechel] you beat us to filing the ticket! :) Chris and I had been discussing this on a back channel. Our current thinking is I think one of the following: * Make the target support (iOS, macOS) declarable by a developer via the manifest or timodule. Marking it as not supporting a target will cause it to not build for that target * Allow the mac build to fail, just warning if it does Either would be combined with changes in the app build to detect whether a module supports the target specified by an app developer, erroring if not. As a power-user of module development which sounds more sensible to you? cc [~cwilliams]
  2. Vijay Singh 2020-09-15

    [~eharris] See https://github.com/appcelerator-modules/ti.facebook/pull/128#issuecomment-693011941 1. For above issue I think we can allow mac build fail with warning. 2. Another issue in which third party frameworks do not have simulator 'arm64' architecture, we can check "platform" folder of module and if there is any file having '.framework' extension, exclude simulator 'arm64' architecture.
  3. Hans Knöchel 2020-09-16

    @Ewan: I think it should use the setting in Xcode (the platform checkbox), which is saved in the pbxproj. I can do the "dirty work" to extract it if it helps. Is there a workaround to skip macOS compilation for now? Ti.WidgetKit is required to refresh widgets, so it's kind of a thing for us :-)
  4. Vijay Singh 2020-09-16

    https://github.com/appcelerator/titanium_mobile/pull/12093
  5. Hans Knöchel 2020-09-17

    @Vijay: Unfortunately your PR does not work so far (see logs below). Also, I would really attempt to not cause the build to ignore a build failure and instead only build what's supposed to be build. Once the check from the pbxproj is present, that should be able to guard similar to what you did now. Here is my attempt to check if macOS is enabled or not (working): https://github.com/appcelerator/titanium_mobile/compare/master...hansemannn:TIMOB-28138 I probably missed another step / next() call because it fails at the end with not finding some archs, but maybe it helps!
       [TRACE] [xcode-macos] error: While building for macOS, no library for this platform was found in '~/Library/Application Support/Titanium/mobilesdk/osx/9.2.0.v20200915121722/iphone/Frameworks/TitaniumKit.xcframework'. (in target 'TiWidgetkit' from project 'titanium-widget-kit')
       [TRACE] [xcode-macos] error: WidgetKit is not available when building for macOS. (in target 'TiWidgetkit' from project 'titanium-widget-kit')
       [ERROR] [xcode-macos] ** ARCHIVE FAILED **
       
       [WARN]  Unable to build for mac target. App including this module may fail for mac target.
       [INFO]  Creating universal library
       [INFO]  Looking for /titanium-widget-kit/ios/build/iphoneos.xcarchive/Products/Library/Frameworks/TiWidgetkit.framework
       [INFO]  Looking for /titanium-widget-kit/ios/build/iphonesimulator.xcarchive/Products/Library/Frameworks/TiWidgetkit.framework
       [INFO]  Looking for /titanium-widget-kit/ios/build/macosx.xcarchive/Products/Library/Frameworks/TiWidgetkit.framework
       [DEBUG] Searching library: /titanium-widget-kit/ios/build/macosx.xcarchive/Products/usr/local/lib/libTiWidgetkit.a
       [WARN]  The module is missing 64-bit support of macos. Ignoring mac target for this module...
       [DEBUG] Running: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -create-xcframework -framework /titanium-widget-kit/ios/build/iphoneos.xcarchive/Products/Library/Frameworks/TiWidgetkit.framework -framework /titanium-widget-kit/ios/build/iphonesimulator.xcarchive/Products/Library/Frameworks/TiWidgetkit.framework -output /titanium-widget-kit/ios/build/TiWidgetkit.xcframework
       [INFO]  Verifying universal library
       [INFO]  Looking for /titanium-widget-kit/ios/build/TiWidgetkit.xcframework/ios-arm64_armv7/TiWidgetkit.framework
       [INFO]  Looking for /titanium-widget-kit/ios/build/TiWidgetkit.xcframework/ios-armv7_arm64/TiWidgetkit.framework
       [WARN]  The module is missing 64-bit support.
       [INFO]  Looking for /titanium-widget-kit/ios/build/TiWidgetkit.xcframework/ios-arm64_i386_x86_64-simulator/TiWidgetkit.framework
       [INFO]  Looking for /titanium-widget-kit/ios/build/TiWidgetkit.xcframework/ios-i386_x86_64-simulator/TiWidgetkit.framework
       [WARN]  The module is missing ios simulator support.
       [INFO]  Looking for /titanium-widget-kit/ios/build/TiWidgetkit.xcframework/ios-arm64_x86_64-maccatalyst/TiWidgetkit.framework
       [WARN]  The module is missing maccatalyst support.
       [ERROR] There is discrepancy between the architectures specified in module manifest and compiled binary.
       [ERROR] Architectures in manifest: armv7,arm64,i386,x86_64
       [ERROR] Compiled binary architectures:
       [ERROR] Please update manifest to match module binary architectures.
       
  6. Christopher Williams 2020-09-17

    https://github.com/appcelerator/titanium_mobile/pull/12093
  7. Vijay Singh 2020-09-17

    [~hknoechel] 1. The modules which are not generating frameworks (Objc based modules), do not have option to out out from mac-target build in Xcode project. This option is available for frameworks only. I think your PR will not work for all modules. 2. In my PR, the module build is failing because the architectures mentioned in manifest file is not same as in created XCFramework. Reason is, in _buildModule.js we are using hardcoded way to read architecture. [~jvennemann] is working on parsing of Info.plist available inside .xcframework as part of PR https://github.com/appcelerator/titanium_mobile/pull/12092 . After that we can update it to use architectures from there.
  8. Hans Knöchel 2020-09-21

    It seems like *NO* modules that contain native frameworks (.framework extension) can be compiled right now. The error is:
       error: module 'XXXX' was created for incompatible target arm64-apple-ios8.0: /Users/user/Documents/mymodule/ios/platform/XXXX.framework/Modules/XXXX.swiftmodule/arm64.swiftmodule
       
    And since the module is a swift module, it cannot be compiled with Xcode 11, because it requires the ABI stability of Swift 5. Therefore all Swift based modules are blocked right now. I hope one of the pending PR's helps. If you need more concrete modules for testing, let me know and I can send it over.
  9. Vijay Singh 2020-09-21

    [~hknoechel] It should be fixed in this PR. Can you try and let me know if you still have issue? Thanks!
  10. Hans Knöchel 2020-09-22

    The module build works, the app build as well, but once the module (here: Ti.WidgetKit) is require()'d, it fails to find it for the architecture (tested both iOS Simulator and iOS device)
  11. Lokesh Choudhary 2020-09-22

    FR Passed. Closing.
  12. Hans Knöchel 2020-09-23

    One last question from my end: We get the following warning / note during the build for an iPhone XS:
        [TRACE] note: 'modules/iphone/ti.widgetkit/1.0.0/TiWidgetkit.xcframework' is missing architecture(s) required by this target (armv7), but may still be link-compatible. (in target 'MyApp' from project 'MyApp')
        [TRACE] note: 'modules/iphone/ti.widgetkit/1.0.0/TiWidgetkit.xcframework' is missing architecture(s) required by this target (armv7), but may still be link-compatible. (in target 'MyApp' from project 'MyApp')
        
    Is that fine? Should there be an improvement ticket to properly link armv7 directly?
  13. Vijay Singh 2020-09-23

    [~hknoechel] I think this should be fine. iPhone 5s and later supports arm64. iOS 14 is supported from iPhone SE. As WidgetKit framework is only supported for iOS 14+, I think Apple has dropped armv7 support from WidgetKit framework. So it is generating arm64 only for devices. We are not excluding "armv7" from binary while building module.

JSON Source