[TIMOB-23570] Hyperloop: iOS - Support use_frameworks flag in Cocoapods
GitHub Issue | n/a |
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-09-18T15:14:32.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Hyperloop 2.2.0 |
Components | Hyperloop, iOS |
Labels | hyperloop, notable, swift |
Reporter | Ron Piwetz |
Assignee | Jan Vennemann |
Created | 2016-06-22T15:35:36.000+0000 |
Updated | 2017-10-19T22:43:37.000+0000 |
Description
When use_frameworks! is included in Podfile, linking fails due to the framework being looked for in the wrong location. Even if the framework is placed in the expected location, the app will crash upon execution. Details provided below.
I discovered this issue while trying to use a swift Cocoapod, but it is easily reproduced using the Hyperloop_Sample app as well. I will describe steps to reproduce for both cases.
1. For Hyperloop_Sample, simply add use_frameworks!
to the beginning of Podfile and change the platform to 8.0 (frameworks only supported in iOS 8+). Change the min-ios-ver to 8.0 in tiapp.xml as well. As expected, instead of creating static libraries, frameworks for each pod are created instead. These can be seen inside of build/Release-iphonesimulator
. The first issue comes during linking. The framework is expected to be at build/iphone/build/Products/Debug-iphonesimulator
as seen in the attached build log (see Sample.log), search for GLCalendarView to see the expected location of the framework on line 4466. I then tried manually copying the 3 frameworks from build/Release-iphonesimulator
to build/iphone/build/Products/Debug-iphonesimulator
which allows the app to be built, but when it runs on the simulator, immediately crashes, see the attached crash log (Sample.crash). I'm not real sure what the problem is, just that the error is "Library not loaded" for reason "image not found".
2. Next, I created a new project, enabled hyperloop, then tried to use a swift cocoapod. Swift pods require use of use_frameworks!
, so without this issue being resolved, we will be unable to use any swift pods. I've attached my Podfile (see Podfile). I tried building without referencing the pod in the Podfile, just to test, and while the app builds, it crashes as well, see (swift.crash).
Attachments
Hey there! Please follow TIMOB-23530 for further discussions, we already a PR in place for the GA.
[~hansknoechel] are we sure that the new ticket covers the scenario in this ticket?
Nope it doesn't, I just realized that today. Sorry for closing! And thank you [~rpiwetz] for noticing. We might want to open this one again and handle the issue here. Thanks again!
[~bimmel] May want to mention this somewhere as a known issue so that people know the current hyperloop module is not able to use swiftpods.
[~hansknoechel] How does the timeframe for Hyperloop 2.0 align w/ the timeline for Appcelerator 6.0?
A short status update about the current progress on this ticket: I was successfully able to prepare the Hyperloop build pipeline for Swift Pods by integrating a script from CocoaPods which embeds the Frameworks into the Xcode project and copies them over to their required destination. Currently there are two blockers for this ticket: * TIMOB-24163: If the framework requires Swift only classes/structs, the metabase generation fails. For example Alamofire requires the Swift-only struct URL * TIMOB-24180: Swift files that have references to each other can not be processed because the Swift metabase parser currently parses them file by file. Both issues can be resolved by using [SourceKit](https://github.com/apple/swift/tree/master/tools/SourceKit) but require a complete rewrite of the Swift metabase parser.
[~hansknoechel], to speed this up i would suggest to split the support for dynamic framework in two parts. In a first step we only support frameworks which expose an Objective-C interface. I have a PoC for that running and it requires no changes to the Swift metabase parser. After that we can focus on bringing support for pure Swift frameworks with the metabase parser rewrite. Thoughts?
PR: https://github.com/appcelerator/hyperloop.next/pull/159 This is the first iteration for support of dynamic frameworks with the
use_framework!
flag in CocoaPods. It is currently limited to frameworks that expose an Objective-C interface header, so not all Swift Pods are supported yet. To achieve that we first need to rewrite the Swift Metabase parser and evaluate a few other technical challenges. I'll create a few additional tickets dedicated to that soon and link them to this one.[~hknoechel], updated the PR with the latest changes which means it now also resolves TIMOB-23853. Breakdown of important changes: - Allows usage of
use_frameworks!
flag in CocoaPods - Support of Swift frameworks if they provide an Objective-C interface header - Hyperloop now automatically picks up all frameworks from modules and the project'splatform/ios
folder. No manual configuration needed anymore for frameworks inappc.js
.[~ewieber], follow these steps to verify. They use they hyperloop-examples project.
Add the
use_frameworks!
flag to the Podfile as well aspod 'AWSS3'
Add the following code to
app/controllers/index.js
*Expected behavior* The app should launch successfully. The above code is executed upon opening and makes sure the AWSS3 APIs are available, which come from a dynamic frameworks. The other third-party examples in the app should still work as expected.
Verified. The use_frameworks! flag can be used in podfile without issue. Tested using the flag with dynamic frameworks and ensuring that their inclusion did not break other third-party frameworks in the project.