Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

SwiftModule and -Swift.h ObjC compatibility header not copied to framework #175

Closed
xsacha opened this issue Sep 14, 2017 · 7 comments
Closed

Comments

@xsacha
Copy link

xsacha commented Sep 14, 2017

When building a framework that contains swift code, the generated framework is missing critical files.
When adding the swift code, a Foo-Swift.h file is generated so that Objective-C can call Swift functions. This is usually included in the framework.
Also, the Foo.swiftmodule file is usually included in the framework so you can use the Swift functions directly.

Location of these generated files, which are correctly generated by CMake:
_builds/ios-toolchain/bin/Release/Foo_0_0_0_0.swiftmodule/arm.swiftdoc
_builds/ios-toolchain/bin/Release/Foo_0_0_0_0.swiftmodule/arm.swiftmodule
_builds/ios-toolchain/bin/Release/Foo_0_0_0_0.swiftmodule/arm64.swiftdoc
_builds/ios-toolchain/bin/Release/Foo_0_0_0_0.swiftmodule/arm64.swiftmodule

This folder is meant to go in to the Modules/ directory of the generated Framework.

_builds/ios-toolchain/Foo/Bar.build/Release-iphoneos/Bar.build/DerivedSources/Foo_0_0_0_0-Swift.h

This file is meant to go in to the Headers/ directory of the generated Framework.

I am not sure how to do this myself.

@ruslo
Copy link
Owner

ruslo commented Sep 14, 2017

As I said before, I haven't worked with Swift so can't give any advice here.

@xsacha
Copy link
Author

xsacha commented Sep 24, 2017

@ruslo That's fine (regarding Swift usage). However, could you give me some pointers in how to find the name of these folders?
I know how to find _builds/ios-toolchain/bin/Release but not sure how to find the name Foo_0_0_0_0 (That is, the soname with version).

Also unsure of how to work out the directory _builds/ios-toolchain/Foo/Bar.build/Release-iphoneos/Bar.build/DerivedSources

If I can get some variable name for these, I could fix the create_framework.py script.

So I guess the main things I would need is:
How to find the version: eg. 0_0_0_0
How to find what Bar.build/Release-iphoneos directory is. (This is supplied as -emit-objc-header-path by CMake on the compile/link line).

@ruslo
Copy link
Owner

ruslo commented Sep 24, 2017

I really don't know what all this is about :) The right solution would be to implement all this stuff in CMake itself and see what should go where.

@xsacha
Copy link
Author

xsacha commented Sep 24, 2017

It already is in CMake and those are the generated files.
Only Polly does iOS frameworks properly (?) though so I just wanted to know how to calculate those directories so I can copy the relevant files to the framework.

@ruslo
Copy link
Owner

ruslo commented Sep 25, 2017

The right solution would be to implement all this stuff in CMake itself and see what should go where

Actually I think iOS framework creation is fixed in CMake. I see iOS mentioned here:

I've tried simple example and it looks good. Need to try something with complex structure.

@xsacha you can post your question to CMake bugtracker in this case.

@headupinclouds +cc

@ruslo
Copy link
Owner

ruslo commented Sep 25, 2017

Need to try something with complex structure.

Works fine.

Don't use --framework - use CMake FRAMEWORK instead. Closing.

@ruslo ruslo closed this as completed Sep 25, 2017
@xsacha
Copy link
Author

xsacha commented Sep 25, 2017

This is great news, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants