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

Bitcode support for iOS frameworks #1202

Closed
anupcowkur opened this issue Dec 29, 2017 · 22 comments
Closed

Bitcode support for iOS frameworks #1202

anupcowkur opened this issue Dec 29, 2017 · 22 comments

Comments

@anupcowkur
Copy link

Hi. Is there a way to generate an iOS framework that has bitcode enabled from the gradle plugin?
Currently ./gradlew build generates iOS frameworks for simulator and device but they don't seem to be bitcode enabled.

@olonho
Copy link
Contributor

olonho commented Dec 29, 2017

Not yet. Why do you need that functionality?

@anupcowkur
Copy link
Author

We have a large iOS project that uses bitcode. Xcode requires that if you enable bitcode, all your framework dependencies must also be built with bitcode.

@siuying
Copy link

siuying commented Jan 2, 2018

On watchOS/tvOS that’s required. It is also likely in future this would be expanded to iOS.

@anupcowkur
Copy link
Author

Bitcode is required to be enabled only in WatchOS but if you have optionally enabled bitcode in your regular app, it is required that all frameworks that are included are also bitcode enabled.

@olonho
Copy link
Contributor

olonho commented Jan 12, 2018

Well, currently we cannot provide bitcode compatible with what Apple needs, so maybe just avoid using bitcode in the meantime.

@kylejbrock
Copy link

Is it a technical limitation that would live past 1.0?

@oleksandr-yefremov
Copy link

oleksandr-yefremov commented Mar 6, 2018

Bitcode is required to be enabled only in WatchOS

This part of statement is not correct. Both tvOS and watchOS require bitcode enabled now.

See https://developer.apple.com/tvos/submit/

When compiling your tvOS app and any third-party libraries, Bitcode must be enabled

So to summarize. Without bitcode you cannot develop any tvOS and watchOS frameworks/apps.
You can build an iOS application, but only as long as Apple does not make it required everywhere.
You can theoretically build an iOS framework with K/N, but you will have to make people disable bitcode in their apps, which is sometimes a blocker.

I completely understand that enabling bitcode is a complex feature, partially because Apple does whatever they want with LLVM. Same issue discussion in rust is open for 1,5 years already and with no ETA. However, IMO, K/N is in better position than Rust, because for Rust iOS support is a low-prio "good to have" feature, whereas K/N is devoted to client side from the beginning. My team is investigating now, whether we could ditch our 2 codebases on Java for Android/AndroidTV and Swift on iOS/tvOS to build one single K/N code and test base for all platforms. Everything looks too good to be true 😄 Except if there is no ETA for bitcode (even in 6 months from now), we won't be able to ship it to customers who use bitcode for a long time now and the whole idea falls apart. K/N FTW! 🏎

(edit): I updated the comment to remove incorrect claim and clarify framework case, sorry about that.

@mouse4d
Copy link

mouse4d commented Mar 6, 2018

I totally agree with @oleksandr-yefremov! We start a new SKD project that is 90% business logic, so we're starting it in Kotlin, with the expectations that it will advance quickly and it will support Bitcode and Dynamic Library in the next time (6 months is good enough). Will be a real blow if it doesn't, but we're willing to take the risk.

@alastaircoote
Copy link

It appears that Rust has recently added support for outputting Bitcode: rust-lang/rust#48896, in case that work provides any useful pointers for Kotlin Native.

@AxelDelmas
Copy link

Is there any news on this topic? We're also considering K/N but support for iOS bitcode is also a blocking point for us. Thanks

@ankushg
Copy link

ankushg commented Sep 26, 2018

Created a ticket on YouTrack for this since it seems like things are more frequently responded to by Jetbrains over there: https://youtrack.jetbrains.com/issue/KT-27147

@simonbengtsson
Copy link

Does this mean bitcode is supported now? 😲

https://github.com/JetBrains/kotlin-native/blob/master/FAQ.md#q-how-do-i-enable-bitcode-for-my-kotlin-framework

6cb4d0c af769d9

@olonho
Copy link
Contributor

olonho commented Oct 26, 2018

Not exactly bitcode, what we support is adding markers showing Apple tools that produced code is aware about bitcode and could be used with it. So please try and let us know about your results.

@KaiJSchaefer
Copy link

Have someone any experience with this compiler option "-Xembed-bitcode"? Does apple reject apps with this marker ?

@webfrea-k
Copy link

We've just uploaded iOS app to iTunes Connect using -Xembed-bitcode without any problems. If your iOS project has ENABLE_BITCODE flag set, and any of the included frameworks does not provide bitcode, the archive operation will fail (and you cannot upload it to iTunes).

ps: iOS Framework that we are using was built from kotlin-native project with -xembed-bitcode marker.

@ddnn55
Copy link

ddnn55 commented Apr 30, 2019

@webfrea-k you uploaded to AppStore connect... Was the app approved and did you publish it in the App Store?

@webfrea-k
Copy link

@gimlids no, we did not send it to approval. It was just for testing if technicality speaking app is compliant with AppStore. We were concerned if upload will fail due to some internal bitcode checking mechanism.

@amrox
Copy link

amrox commented Jun 15, 2019

I'm confused - is bitcode working or not?

I did a quick and dirty test and it seemed to be working. I created a dummy Kotlin Native framework:

$(HOME)/lib/kotlin-native-macos-1.3.31/bin/kotlinc-native -produce framework -target ios_arm32  -Xembed-bitcode -o armv7/KLib lib.kt
$(HOME)/lib/kotlin-native-macos-1.3.31/bin/kotlinc-native -produce framework -target ios_arm64  -Xembed-bitcode -o arm64/KLib lib.kt
cp -R arm64/* universal
rm universal/KLib.framework/KLib
lipo armv7/KLib.framework/KLib arm64/KLib.framework/KLib -create -output universal/KLib.framework/KLib

Then I added the framework to a new app, archived it, and exported it with the "Rebuild from Bitcode" option using my enterprise cert. It seems to work fine.

Screenshot 2019-06-15 07 58 32

I've been searching for an alternative to C++ for sharing code between iOS and Android libraries, however lack of iOS bitcode support originally turned me away. If it is working, Kotlin/Native seems like an exciting option :)

@fluidsonic
Copy link

I've uploaded an iOS app to the App Store with the Bitcode option selected - there was no error or warning. Yet after processing there is no "Download dSYM" link. Doesn't that indicate that the binaries haven't been rebuilt?

@evant
Copy link

evant commented Jun 17, 2019

Not exactly bitcode, what we support is adding markers showing Apple tools that produced code is aware about bitcode and could be used with it. So please try and let us know about your results.

So my understanding is iOS and tvOS would be supported, watchOS would not.

@SvyatoslavScherbina
Copy link
Collaborator

Not exactly bitcode, what we support is adding markers showing Apple tools that produced code is aware about bitcode and could be used with it.

This will become false with 1.3.50, which is going to include real bitcode support.

So my understanding is iOS and tvOS would be supported, watchOS would not.

Please note that "bitcode support" is not exactly the same as "watchOS support". The latter would also require other efforts.

@SvyatoslavScherbina
Copy link
Collaborator

Fixed in 1.3.50.

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

No branches or pull requests