Skip to content

Support Swift files in the .xcodeproj#1128

Merged
tdermendjiev merged 6 commits intomasterfrom
swift-files-support
Apr 19, 2019
Merged

Support Swift files in the .xcodeproj#1128
tdermendjiev merged 6 commits intomasterfrom
swift-files-support

Conversation

@tdermendjiev
Copy link
Copy Markdown
Contributor

@tdermendjiev tdermendjiev commented Apr 17, 2019

*Redirect LD to nsld.sh so we can hook between compiling and linking and generate metadata there (we need appname-Swift.h to be created (and a modulemap for it) so the metadata-generator finds it)
*Set Swift language version
*Set Strip swift symbols to NO
*Add ObjC bridging header so the Swift classes are added to the generated appname-Swift.h

PR Checklist

What is the current behavior?

Swift files cannot be added to an .xcodeproj and accessed by the NativeScript runtime for several reasons:

  • Swift symbols are stripped
  • Swift language version is undefined in the project settings
  • No metadata is generated for the Swift symbols accessible from the ObjC runtime

What is the new behavior?

After all source files are compiled nsld.sh creates a modulemap pointing to the appname-Swift.h where the generated interface for the Swift classes is. As the modulemap's directory is added in the HEADER_SEARCH_PATHS the metadata-generator (called from nsld.sh) will find the header and generate metadata for it. Finally the linking is executed.

This way all Swift symbols accessible from the ObjC runtime are now accessible from NativeScript.

Implements: #1131

@tdermendjiev tdermendjiev requested a review from mbektchiev April 17, 2019 11:35
@tdermendjiev tdermendjiev self-assigned this Apr 17, 2019
@cla-bot cla-bot Bot added the cla: yes label Apr 17, 2019
Comment thread build/project-template/__PROJECT_NAME__.xcodeproj/project.pbxproj Outdated
Comment thread build/project-template/__PROJECT_NAME__.xcodeproj/project.pbxproj Outdated
Comment thread build/project-template/__PROJECT_NAME__.xcodeproj/project.pbxproj Outdated
Comment thread build/project-template/internal/main.m Outdated
Comment thread build/project-template/internal/nsld.sh Outdated
Comment thread build/project-template/internal/nsld.sh Outdated
*Redirect LD to nsld.sh so we can hook between compiling and linking and generate metadata there (we need <appname>-Swift.h to be created (and a modulemap for it) so the metadata-generator finds it)
*Set Swift language version
*Set Strip swift symbols to NO
*Add ObjC bridging header so the Swift classes are added to the generated   <appname>-Swift.h
Comment thread build/project-template/__PROJECT_NAME__.xcodeproj/project.pbxproj Outdated
Comment thread build/project-template/__PROJECT_NAME__.xcodeproj/project.pbxproj Outdated
Comment thread build/project-template/__PROJECT_NAME__.xcodeproj/project.pbxproj
Comment thread build/project-template/__PROJECT_NAME__.xcodeproj/project.pbxproj
Comment thread build/project-template/internal/nativescript-pre-build Outdated
Comment thread build/project-template/internal/nsld.sh Outdated
Comment thread build/project-template/internal/nsld.sh Outdated
Comment thread build/project-template/internal/nsld.sh Outdated
@mbektchiev mbektchiev self-requested a review April 18, 2019 13:33
@tdermendjiev tdermendjiev merged commit 9ed612b into master Apr 19, 2019
@vtrifonov vtrifonov deleted the swift-files-support branch August 9, 2019 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants