Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realm on the Apple Watch with a Swift project is not feasible #5203

Closed
jlaws opened this issue Aug 5, 2017 · 17 comments
Closed

Realm on the Apple Watch with a Swift project is not feasible #5203

jlaws opened this issue Aug 5, 2017 · 17 comments
Labels

Comments

@jlaws
Copy link

jlaws commented Aug 5, 2017

Goals

Using Realm on the Apple Watch with a Swift project is not feasible. You are limited to 50MB for your watch bundle, with the system and all the Swift libraries taking up 30MB of that, then Realm adding another 15MB. This leaves ~5MB for the actual application, including all assets.

Expected Results

It would be great to have a lightweight version of Realm that uses less than 5MB of space in a bundle. Even if it was readonly and require a pre-populated Realm database file. Not sure what other functionality could be trimmed to reduce the code size.

@jpsim
Copy link
Contributor

jpsim commented Aug 7, 2017

You're absolutely right. It'd be interesting to measure the binary size reduction from avoiding the sync components, as I've started in #4851.

@jlaws
Copy link
Author

jlaws commented Aug 7, 2017

Thanks for the update. Looks like #4851 is on hold, do you have an ETA for it?

@jpsim
Copy link
Contributor

jpsim commented Aug 7, 2017

No.

@jlaws
Copy link
Author

jlaws commented Aug 7, 2017

Does the environment variable, REALM_DISABLE_SYNC=TRUE, work so I can at least test the theory to see how much we would save?

@jpsim
Copy link
Contributor

jpsim commented Aug 7, 2017

No, there are major changes required to the build system to avoid adding sync components contribute to binary size.

@bdash
Copy link
Contributor

bdash commented Aug 7, 2017

I'm curious how you've determined that Realm contributes 15MB to the application size. By my analysis, Realm should contribute 7MB. I found this figure by stripping out the simulator architecture and bitcode slice from the watchOS frameworks in our most recent release. That leaves me with a Realm.framework that's around 5.7MB and a RealmSwift.framework that's around 1.2MB.

@jpsim
Copy link
Contributor

jpsim commented Aug 7, 2017

Bitcode is unfortunately counted in the size limit in iTunesConnect.

@bdash
Copy link
Contributor

bdash commented Aug 7, 2017

That's hilarious, and makes no sense at all 😞

@jlaws
Copy link
Author

jlaws commented Aug 7, 2017

Sorry for the poor research, looks like this was already brought up a year ago
#3430

Looks like Realm w/ Swift on the watch is not happening anytime soon.

@jlaws
Copy link
Author

jlaws commented Aug 7, 2017

Is it worth putting something in the FAQ or elsewhere in the docs so that developers are aware about the issue?

@jpsim
Copy link
Contributor

jpsim commented Aug 7, 2017

Ideally we'd add the rough numbers from the bitcode overhead to the size section of our FAQ, and point readers to a radar detailing how iTunesConnect shouldn't incorporate the bitcode weight in its size limit.

@jlaws would you be interested in filing such a radar?

@jlaws
Copy link
Author

jlaws commented Aug 7, 2017

FYI I am getting 18MB used by Realm/RealmSwift for submission to Apple.

You will probably be better off with the radar, coming from a larger organization, but I can file one as well so they know more people are concerned about it.

@jpsim
Copy link
Contributor

jpsim commented Aug 7, 2017

FYI I am getting 18MB used by Realm/RealmSwift for submission to Apple.

That's a bit surprising. My measurements indicate that Realm.framework & RealmSwift.framework should contribute ~26MB to a watch app with armv7k & bitcode slices:

$ curl -O https://github.com/realm/realm-cocoa/releases/download/v2.9.1/Carthage.framework.zip
$ unzip Carthage.framework.zip
$ cd Carthage/Build/watchOS
$ lipo -thin armv7k Realm.framework/Realm -o Realm.armv7k
$ lipo -thin armv7k RealmSwift.framework/RealmSwift -o RealmSwift.armv7k
$ size Realm.armv7k
23M  Realm.armv7k
$ size RealmSwift.armv7k
2.8M  RealmSwift.armv7k

You will probably be better off with the radar, coming from a larger organization, but I can file one as well so they know more people are concerned about it.

Past radars don't indicate that filers from Realm have had more success than filers from outside Realm. However, if you file one, I'd be happy to duplicate it if you cross-post it to Open Radar if you think it will help it get more visibility.

@jpsim
Copy link
Contributor

jpsim commented Aug 7, 2017

Interestingly enough, if I attempt to measure the size of just the bitcode from Realm frameworks for the watchOS platform, I get closer to the 18MB figure you obtained.

$ xcrun bitcode_strip -r Realm.armv7k -o Realm.nobitcode
$ xcrun bitcode_strip -r RealmSwift.armv7k -o RealmSwift.nobitcode
$ size Realm.nobitcode 
5.4M  Realm.nobitcode
$ size RealmSwift.nobitcode
1.2M  RealmSwift.nobitcode

Where 23 + 2.8 - 5.4 - 1.2 == 19.2. I really don't understand how the 18MB is being measured.

@ewerx
Copy link

ewerx commented Sep 26, 2017

I had been sneaking in just under the 50MB limit with Xcode 8 (I would get a warning on submission but it would pass) but after switching to Xcode 9 and updating the project to Swift 3.2 (no other changes) I can no longer submit my app (58MB). Is my only option to rewrite my watchOS app to work without Realm?

@ewerx
Copy link

ewerx commented Sep 27, 2017

From Apple (Sep 19, 2017):

Well, the problem is not yet solved but we understand it better now. The actual size of the Swift code and Swift runtime libraries are not the problem. As I mentioned earlier, the Swift libraries in AppStore submissions include embedded bitcode that takes up a lot of space. That bitcode is not included in the final app -- it is only in the submissions to the AppStore. The problem is that the check for the 50 MB limit is calculating the size based on the content in a submission instead of the final app size, so that Swift apps for watchOS are severely constrained in size. I expect this to be fixed soon but I can't give a specific timeline.

https://forums.developer.apple.com/message/261450#261450

@bdash
Copy link
Contributor

bdash commented Sep 27, 2017

I'm very happy to hear that Apple is finally making progress on that issue!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants