Is there a way to decrease size of static libraries included in project?

We’ve just managed to compile our project in Xcode including a library that we’d added. I didn’t notice at first that the size of this static library was 23.1MB, while the Android version of the same library was only 172KB.  

This has increased the size of our app by 50%, and I’m looking to see if there is something I can do to reduce the size of the final project.  

We also use Gremlin’s Chartboost plugin, and having looked at the static libs for that, I’ve noticed they are 28MB (the actual CB lib rather than Gremlin’s plugin lib). However adding Chartboost to a simulator project only added 0.9MB, so I’m assuming that Corona SDK does something with plugin libs to reduce the size they have on the final build?

Is there a simple setting in Xcode that will strip the libs down? I’ve tried turning on Dead Code Stripping, than knocked off about 2MB, and “Strip Debug Symbols During Copy” is already set to Yes for release builds.

Could it be something to do with architectures? I have armv7, armv7s and arm64 set at the moment. Tried with only armv7 architecture, and the size was the same.

Is anyone from Corona around to help?

Please help.

Can you guys bump this post sometime next week please.  With all of the changes Apple has been making to the submission process and iOS 8’s release, our engineers are really slammed right now.  I asked about this a couple of days ago, but with is being in kind of an emergency mode right now, I can’t realistically expect to get a response.  Lets try early next week when things have hopefully calmed down from the Apple issues.

Thanks

Rob

Ok, thanks for the response Rob. Luckily we’ve made the call to remove the custom plugin which means we can build the games with the simulator for today’s submission. We’ll need to revert back to enterprise builds next week though so please chase it for us then.

We feel your pain with the Apple changes.

Static libraries are not indicative of compiled app binary sizes, but given the size of your static libraries, it’s inevitable that they’d make your app much larger.

Unfortunately, there’s not much that can be done w/o source-level access.

I’m surprised that limiting the architectures doesn’t reduce binary size. If you are an expert in Apple’s cmd-line tools, you can ‘lipo’ to see what architecture slices are present.

If you are a black belt in Xcode/linker/compiler kung fu, then you can try turning on dead-code stripping. This is not for the faint of heart.

And if you try this, then beware! You will need to “trick” the compiler/linker so that it does not dead-code strip the original plugin, just any dead-code that’s in the plugin itself. (I haven’t done this in a long time, so I’m not sure what the right way to do this against Apple’s latest compiler.)

Is there a simple setting in Xcode that will strip the libs down? I’ve tried turning on Dead Code Stripping, than knocked off about 2MB , and “Strip Debug Symbols During Copy” is already set to Yes for release builds.

I tried that (after backing up the project), it didn’t have much effect.

As I mentioned in my original post, what I find confusing is that when I build using Corona SDK and include the Chartboost plugin it only adds 0.9MB to my project. Yet the static library files for the chartboost plugin are about 28MB in size (libchartboostLibrary.a is 187KB and libChartboost.a is 27.9MB). That makes me think that Corona must do something when building that reduces the size dramatically. 

I’m no expert in Xcode by any means, so it’s entirely possible that I haven’t set the architectures correctly or missed a setting somewhere.

As I said in my reply, the static library size will not help u understand the final binary size. It has nothing special to do with Corona. The size change is all dependent on linker magic.

Thought I should update this post to say that I found the true cause of the inflated app size.  

The “Copy Bundle Resources” build phase was adding a duplicate of every single file in my Corona folder, which was just shy of 40MB.  

I’m still not 100% sure why it started happening. When you open the Enterprise template project in Xcode, it has the Corona folder as a yellow “group” folder rather than a blue “folder reference”. My project was the same, but I must have triggered something to make it include every file in the copy phase. In case anyone else has the same problem, here’s what I did to fix it:

  • Remove the folder from the Xcode project completely (make sure you have a copy of it somewhere so you don’t lose all your work).
  • Drag the copy of the Corona folder back into Xcode, and select “Create folder references for any added folder” and deselect “Copy items into destination group’s folder (if needed)”.
  • Select the app target icon and go to “build phases”.
  • Open the “Copy Bundle Resources” section. If your Corona project folder is shown in there then remove it using the “-” button.
  • Clean project and build/archive/whatever.

Is anyone from Corona around to help?

Please help.

Can you guys bump this post sometime next week please.  With all of the changes Apple has been making to the submission process and iOS 8’s release, our engineers are really slammed right now.  I asked about this a couple of days ago, but with is being in kind of an emergency mode right now, I can’t realistically expect to get a response.  Lets try early next week when things have hopefully calmed down from the Apple issues.

Thanks

Rob

Ok, thanks for the response Rob. Luckily we’ve made the call to remove the custom plugin which means we can build the games with the simulator for today’s submission. We’ll need to revert back to enterprise builds next week though so please chase it for us then.

We feel your pain with the Apple changes.

Static libraries are not indicative of compiled app binary sizes, but given the size of your static libraries, it’s inevitable that they’d make your app much larger.

Unfortunately, there’s not much that can be done w/o source-level access.

I’m surprised that limiting the architectures doesn’t reduce binary size. If you are an expert in Apple’s cmd-line tools, you can ‘lipo’ to see what architecture slices are present.

If you are a black belt in Xcode/linker/compiler kung fu, then you can try turning on dead-code stripping. This is not for the faint of heart.

And if you try this, then beware! You will need to “trick” the compiler/linker so that it does not dead-code strip the original plugin, just any dead-code that’s in the plugin itself. (I haven’t done this in a long time, so I’m not sure what the right way to do this against Apple’s latest compiler.)

Is there a simple setting in Xcode that will strip the libs down? I’ve tried turning on Dead Code Stripping, than knocked off about 2MB , and “Strip Debug Symbols During Copy” is already set to Yes for release builds.

I tried that (after backing up the project), it didn’t have much effect.

As I mentioned in my original post, what I find confusing is that when I build using Corona SDK and include the Chartboost plugin it only adds 0.9MB to my project. Yet the static library files for the chartboost plugin are about 28MB in size (libchartboostLibrary.a is 187KB and libChartboost.a is 27.9MB). That makes me think that Corona must do something when building that reduces the size dramatically. 

I’m no expert in Xcode by any means, so it’s entirely possible that I haven’t set the architectures correctly or missed a setting somewhere.

As I said in my reply, the static library size will not help u understand the final binary size. It has nothing special to do with Corona. The size change is all dependent on linker magic.

Thought I should update this post to say that I found the true cause of the inflated app size.  

The “Copy Bundle Resources” build phase was adding a duplicate of every single file in my Corona folder, which was just shy of 40MB.  

I’m still not 100% sure why it started happening. When you open the Enterprise template project in Xcode, it has the Corona folder as a yellow “group” folder rather than a blue “folder reference”. My project was the same, but I must have triggered something to make it include every file in the copy phase. In case anyone else has the same problem, here’s what I did to fix it:

  • Remove the folder from the Xcode project completely (make sure you have a copy of it somewhere so you don’t lose all your work).
  • Drag the copy of the Corona folder back into Xcode, and select “Create folder references for any added folder” and deselect “Copy items into destination group’s folder (if needed)”.
  • Select the app target icon and go to “build phases”.
  • Open the “Copy Bundle Resources” section. If your Corona project folder is shown in there then remove it using the “-” button.
  • Clean project and build/archive/whatever.