{"action":"created","issue":{"url":"https://api.github.com/repos/appcelerator/titanium_mobile/issues/10218","repository_url":"https://api.github.com/repos/appcelerator/titanium_mobile","labels_url":"https://api.github.com/repos/appcelerator/titanium_mobile/issues/10218/labels{/name}","comments_url":"https://api.github.com/repos/appcelerator/titanium_mobile/issues/10218/comments","events_url":"https://api.github.com/repos/appcelerator/titanium_mobile/issues/10218/events","html_url":"https://github.com/appcelerator/titanium_mobile/pull/10218","id":345518849,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA0NjM0OTkz","number":10218,"title":"[TIMOB-25927] Add Swift support for native modules, move SDK-core into \"TitaniumKit.framework\"","user":{"login":"hansemannn","id":10667698,"node_id":"MDQ6VXNlcjEwNjY3Njk4","avatar_url":"https://avatars0.githubusercontent.com/u/10667698?v=4","gravatar_id":"","url":"https://api.github.com/users/hansemannn","html_url":"https://github.com/hansemannn","followers_url":"https://api.github.com/users/hansemannn/followers","following_url":"https://api.github.com/users/hansemannn/following{/other_user}","gists_url":"https://api.github.com/users/hansemannn/gists{/gist_id}","starred_url":"https://api.github.com/users/hansemannn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hansemannn/subscriptions","organizations_url":"https://api.github.com/users/hansemannn/orgs","repos_url":"https://api.github.com/users/hansemannn/repos","events_url":"https://api.github.com/users/hansemannn/events{/privacy}","received_events_url":"https://api.github.com/users/hansemannn/received_events","type":"User","site_admin":false},"labels":[{"id":319882702,"node_id":"MDU6TGFiZWwzMTk4ODI3MDI=","url":"https://api.github.com/repos/appcelerator/titanium_mobile/labels/feature%20%F0%9F%9A%80","name":"feature 🚀","color":"0e8a16","default":false},{"id":319881804,"node_id":"MDU6TGFiZWwzMTk4ODE4MDQ=","url":"https://api.github.com/repos/appcelerator/titanium_mobile/labels/ios","name":"ios","color":"1d76db","default":false},{"id":771521575,"node_id":"MDU6TGFiZWw3NzE1MjE1NzU=","url":"https://api.github.com/repos/appcelerator/titanium_mobile/labels/no%20tests","name":"no tests","color":"d93f0b","default":false}],"state":"open","locked":false,"assignee":{"login":"hansemannn","id":10667698,"node_id":"MDQ6VXNlcjEwNjY3Njk4","avatar_url":"https://avatars0.githubusercontent.com/u/10667698?v=4","gravatar_id":"","url":"https://api.github.com/users/hansemannn","html_url":"https://github.com/hansemannn","followers_url":"https://api.github.com/users/hansemannn/followers","following_url":"https://api.github.com/users/hansemannn/following{/other_user}","gists_url":"https://api.github.com/users/hansemannn/gists{/gist_id}","starred_url":"https://api.github.com/users/hansemannn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hansemannn/subscriptions","organizations_url":"https://api.github.com/users/hansemannn/orgs","repos_url":"https://api.github.com/users/hansemannn/repos","events_url":"https://api.github.com/users/hansemannn/events{/privacy}","received_events_url":"https://api.github.com/users/hansemannn/received_events","type":"User","site_admin":false},"assignees":[{"login":"hansemannn","id":10667698,"node_id":"MDQ6VXNlcjEwNjY3Njk4","avatar_url":"https://avatars0.githubusercontent.com/u/10667698?v=4","gravatar_id":"","url":"https://api.github.com/users/hansemannn","html_url":"https://github.com/hansemannn","followers_url":"https://api.github.com/users/hansemannn/followers","following_url":"https://api.github.com/users/hansemannn/following{/other_user}","gists_url":"https://api.github.com/users/hansemannn/gists{/gist_id}","starred_url":"https://api.github.com/users/hansemannn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hansemannn/subscriptions","organizations_url":"https://api.github.com/users/hansemannn/orgs","repos_url":"https://api.github.com/users/hansemannn/repos","events_url":"https://api.github.com/users/hansemannn/events{/privacy}","received_events_url":"https://api.github.com/users/hansemannn/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/appcelerator/titanium_mobile/milestones/18","html_url":"https://github.com/appcelerator/titanium_mobile/milestone/18","labels_url":"https://api.github.com/repos/appcelerator/titanium_mobile/milestones/18/labels","id":2949858,"node_id":"MDk6TWlsZXN0b25lMjk0OTg1OA==","number":18,"title":"8.0.0","description":"","creator":{"login":"sgtcoolguy","id":3252,"node_id":"MDQ6VXNlcjMyNTI=","avatar_url":"https://avatars0.githubusercontent.com/u/3252?v=4","gravatar_id":"","url":"https://api.github.com/users/sgtcoolguy","html_url":"https://github.com/sgtcoolguy","followers_url":"https://api.github.com/users/sgtcoolguy/followers","following_url":"https://api.github.com/users/sgtcoolguy/following{/other_user}","gists_url":"https://api.github.com/users/sgtcoolguy/gists{/gist_id}","starred_url":"https://api.github.com/users/sgtcoolguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgtcoolguy/subscriptions","organizations_url":"https://api.github.com/users/sgtcoolguy/orgs","repos_url":"https://api.github.com/users/sgtcoolguy/repos","events_url":"https://api.github.com/users/sgtcoolguy/events{/privacy}","received_events_url":"https://api.github.com/users/sgtcoolguy/received_events","type":"User","site_admin":false},"open_issues":11,"closed_issues":10,"state":"open","created_at":"2017-11-30T20:32:53Z","updated_at":"2018-07-30T18:25:58Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2018-07-29T10:12:54Z","updated_at":"2018-08-02T15:30:33Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/appcelerator/titanium_mobile/pulls/10218","html_url":"https://github.com/appcelerator/titanium_mobile/pull/10218","diff_url":"https://github.com/appcelerator/titanium_mobile/pull/10218.diff","patch_url":"https://github.com/appcelerator/titanium_mobile/pull/10218.patch"},"body":"**JIRA:** https://jira.appcelerator.org/browse/TIMOB-25927\r\n\r\n---\r\n\r\n> ✅This change will **not** cause a breaking change for native iOS modules, so no recompiling required for existing Obj-C based modules. But that's so 2017!\r\n\r\n🗓 Scheduled for Q3/Q4 and SDK 8.0.0\r\n\r\n---\r\n\r\n### Overview\r\n\r\nReplaces the Titanium iOS Core with framework based alternative that is required if we want to deal with native modules that use Swift libraries, as we cannot bake Swift frameworks into static libraries and Swift frameworks do not allow non modular imports. Especially not with our (currently) hacky solution that attempts to reference symlinks from the application data directory. The following tasks represent the base of this effort.\r\n\r\n### Docs\r\n\r\nThis PR is introducing [Jazzy](https://github.com/realm/jazzy) to generate apidocs for TitaniumKit. We are currently at 23 % docs-coverage, which can be improved (😙). See the docs [here](http://titaniumkit.hans-knoechel.de/).\r\n\r\n### Playground\r\n\r\nYou can downloaded a recent packaged version of this PR [here](https://www.dropbox.com/s/d3qpnzjwni87ee8/mobilesdk-8.0.0-osx.zip?dl=1) and try around with Swift modules:\r\n```sh\r\nti create -t module --name ti.test --id ti.test --code-base swift\r\n```\r\nYou can also test [this](https://github.com/hansemannn/titanium-swift-module-example) module \"ti.test\" that is created via the CLI and can be packaged and ran by Titanium. Due to one open issue (see below: embedded binaries), the module does not work inside a fresh build, only with moving the module-framework from \"Frameworks\" to \"Embedded Frameworks\", since we have a (modern) dynamic framework, oh yeah!\r\n\r\n### Reviewers\r\n\r\n- [sgtcoolguy](https://github.com/sgtcoolguy) - Overall review and integration in the Titanium ecosystem\r\n- [cb1kenobi](https://github.com/cb1kenobi) - All CLI-related changes, especially to the module template generation and the app-, module-build.\r\n- [janvennemann](https://github.com/janvennemann) - Native framework structure and docs generation / meta-tooling\r\n- [vijaysingh-axway](https://github.com/vijaysingh-axway) - iOS code changes, e.g. moved classes, `TiSharedConfig` replacement for injected constants and class-extensions\r\n\r\n### SDK Tasks\r\n\r\n- [x] Create universal TitaniumKit.framework\r\n- [x] Move SDK-core to TitaniumKit.framework\r\n- [x] ~~Remove Kroll Thread (use Main Thread)~~ merged via own PR (#10196)\r\n- [x] ~~Remove TiCore (use native JSCore)~~ merged via own PR (#9798)\r\n- [x] Reference TitaniumKit as a target dependency of the core\r\n- [x] Integrate TitaniumKit into the build pipeline\r\n- [x] Create .podspec for usage with CococaPods\r\n- [x] Be able to recompile core-framework if compiler flags change (e.g. `IS_XCODE_*` and `USE_TI_UIIOSBLURVIEW`). Can we use `OTHER_C_FLAG=$(inherited) -DISXCODE_*`? Update: I got it working by [using the concept of class extensions](https://github.com/appcelerator/titanium_mobile/pull/10218/commits/332a50cdaf50f6a01e802ba30b910b17539d7567) to solve this very clean. During review, we should make sure to not miss any remaining preprocessor statements. The only ones still there seem to be internally now, like image-debugging and `DEBUG` statements.\r\n\r\n### Module / CLI Tasks\r\n\r\n- [x] Create framework based module template (embedded Swift framework)\r\n- [x] Reference TitaniumKit locally\r\n- [x] Test common Module API's (String, Number, Array, Dictionary, Date, id/Any)\r\n- [x] Update the Scons-CLI to copy TitaniumKit files into the packaged SDK\r\n- [x] Update the Build-CLI to copy TitaniumKit files into generated project build directory\r\n- [x] Update module build\r\n  - [x] Compile (universal) framework instead of static library\r\n  - [x] Package framework instead of static library\r\n  - [x] Link framework based modules in SDK core (update _build.js `validateModules` step)\r\n  - [x] Keep backwards compatibility for Obj-C based modules (which still need to be recompiled)\r\n  - [x] Update templates to include a Swift module template. Prompt to choose between Swift and ObjC-module\r\n  - [x] Be able to link TitaniumKit into module projects without actually linking the framework?\r\n  - [x] Symlink TitaniumKit core-source to generated `include/` directory in packaged SDK to actually allow retain backwards compatibility\r\n  - [x] Fix Swift-based modules from not being copied to the actual app (the .framework is not available)\r\n  - [x] Link Swift framework-dependencies to the \"Embedded Frameworks\" section automatically (needs an update to the framework-manager from @janvennemann to 1) check `modules/iphone/<module>/<version>/<name>.framework` to be embedded and move it to the correct section and 2) not require our infamous `ti.swiftsupport` hook)\r\n- [x] Incremental build seems to be broken, we need to see where it falls through (**EDIT**: Turned to be a side-effect of #10181, fixed in 10223)\r\n\r\n### Misc / Future Tasks\r\n\r\n- [x] Clean up linting once everything is relatively stable\r\n- [x] Investigate support for dropping TitaniumKit into native apps to use Ti-JavaScript in these. **Update**: Investigated and actually working, but developers cannot use `Ti.UI.*` API's, since that namespace requires the API's from the non-core project, that cannot be put into a framework so far, because of the usage-based preprocessor statements (e.g. `USE_TI_UILISTVIEW`). Maybe something for later majors if requested, but recent frameworks failed with this concept, so we should rather focus on hardening the cross-platform idea\r\n- [ ] Update Obj-C module template to use TitaniumKit as well (not necessarily required, could be moved to the next feature version)\r\n"},"comment":{"url":"https://api.github.com/repos/appcelerator/titanium_mobile/issues/comments/409968108","html_url":"https://github.com/appcelerator/titanium_mobile/pull/10218#issuecomment-409968108","issue_url":"https://api.github.com/repos/appcelerator/titanium_mobile/issues/10218","id":409968108,"node_id":"MDEyOklzc3VlQ29tbWVudDQwOTk2ODEwOA==","user":{"login":"hansemannn","id":10667698,"node_id":"MDQ6VXNlcjEwNjY3Njk4","avatar_url":"https://avatars0.githubusercontent.com/u/10667698?v=4","gravatar_id":"","url":"https://api.github.com/users/hansemannn","html_url":"https://github.com/hansemannn","followers_url":"https://api.github.com/users/hansemannn/followers","following_url":"https://api.github.com/users/hansemannn/following{/other_user}","gists_url":"https://api.github.com/users/hansemannn/gists{/gist_id}","starred_url":"https://api.github.com/users/hansemannn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hansemannn/subscriptions","organizations_url":"https://api.github.com/users/hansemannn/orgs","repos_url":"https://api.github.com/users/hansemannn/repos","events_url":"https://api.github.com/users/hansemannn/events{/privacy}","received_events_url":"https://api.github.com/users/hansemannn/received_events","type":"User","site_admin":false},"created_at":"2018-08-02T15:30:33Z","updated_at":"2018-08-02T15:30:33Z","author_association":"CONTRIBUTOR","body":"> It looks like this moves some of the core to a new framework named TitaniumKit. We distribute that framework as source? Can it be pre-built in our scons build to speed up app builds? Would it not make a difference?\r\n\r\nInitially, I was worrying that having a prepackaged framework could lead to issues because of the preprocessor macros. But as I moved them all out (only leaving the developer-related ones), that is not an issue anymore. Having faster clean builds is a good argument to do it, also that we would need to copy the framework-project into the build folder like we do right now. On incremental builds, the framework is already picked up and performs great. No benchmarking done, yet, but likely soon.\r\n\r\n> This model is actually moving much more towards what we did on Windows where we have a TitaniumKit base library that the Windows impl extends. Effectively the entire API is declared in TitaniumKit and then windows provides actual implementations. I think Matt Langstons goal was to eventually move this way and have TitaniumKit be the common base for each platform. Interesting that this does move us closer that way (though I assume it'd be quite a huge undertaking and change to continue towards that, and not sure if that'd mean we'd need to use C++ everywhere versus Obj-C, etc.).\r\n\r\nIt did not have too much in common with the initial C++ based TitaniumKit. Personally, I was never a fan of having a C++ layer, since it's simply to hard to maintain, especially in regards to community contributions. So it's really just the name (see details below) and the idea of a centralized place to precompile common API's.\r\n\r\n> Are there (eventual) plans to break out each API namespace to their own frameworks as well? i.e. Media, Network, Filesystem, etc.\r\n\r\nYes! Definitely a goal, but especially for `UI` and `Media` very critical because of the preprocessor macros that cannot be used if they are prepackaged. Without them, the app size grows and apps may be rejected (like when compiling camera-api's in Ti.Media although not using them).\r\n\r\n> How did you decide what actually went in to TitaniumKit itself? It appears to be a mix of the Kroll stuff, Ti.API, common UI code, Ti.App, Ti.Blob, TiFile. In other words it is not at all clear what needed to go in there or how it's divided. Trial and error?\r\n \r\nIt really was a trial and error. I only moved the `Kroll*` classes over and noticed the dependencies that would need to go as well. After all, I think it was a good idea, because it allows us to use Titanium in native apps as well (simply by using `TiApp` as the main entry point and inherit from there).\r\n\r\n> The naming has me a little confused when comparing to Windows, as there [TitaniumKit](https://github.com/appcelerator/titanium_mobile_windows/tree/master/Source/TitaniumKit) is used to effectively outline the full API with no implementation and [Titanium](https://github.com/appcelerator/titanium_mobile_windows/tree/master/Source/Titanium) is the \"core\" impl.\r\n\r\nThe naming really just was because we are Titanium and frameworks in iOS are usually suffixed `Kit`, like `UIKit`, `ARKit`, `IGListKit`, ... . I thought naming it `TitaniumCoreKit` or `TitaniumCore`, but that made me think of TiCore again, which I am trying to forget asap 😄.\r\n\r\n> But in that case, basically the circular dependencies between Blob and File forced us to move both to the very core Other than those two we had the core runtime class that registered all the APIs/native modules./etc. Sort of the equivalent of KrollBridge on iOS?\r\n \r\nI am not sure I can follow on this one. The circular dependencies did not seem to be an issue as far as I'm concerned.\r\n"}}
{"actor":{"display_login":"hansemannn"}}