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

Provide pre-compiled universal binary #3867

Closed
1 task done
gk-brown opened this issue Feb 26, 2019 · 21 comments
Closed
1 task done

Provide pre-compiled universal binary #3867

gk-brown opened this issue Feb 26, 2019 · 21 comments

Comments

@gk-brown
Copy link

Thanks for all of the hard work you've put into the Charts framework - it's very much appreciated. Just wanted to suggest providing a pre-compiled universal binary in addition to your current CocoaPods and Carthage support. The following shell script can be used to generate a framework binary that will run in both the iOS simulator and on an actual device:

FRAMEWORK=Charts

BUILD=build
FRAMEWORK_PATH=$FRAMEWORK.framework

rm -Rf $BUILD
rm -f $FRAMEWORK.framework.tar.gz

xcodebuild archive -project $FRAMEWORK.xcodeproj -scheme $FRAMEWORK -sdk iphoneos SYMROOT=$BUILD
xcodebuild build -project $FRAMEWORK.xcodeproj -target $FRAMEWORK -sdk iphonesimulator SYMROOT=$BUILD

cp -RL $BUILD/Release-iphoneos $BUILD/Release-universal
cp -RL $BUILD/Release-iphonesimulator/$FRAMEWORK_PATH/Modules/$FRAMEWORK.swiftmodule/* $BUILD/Release-universal/$FRAMEWORK_PATH/Modules/$FRAMEWORK.swiftmodule

lipo -create $BUILD/Release-iphoneos/$FRAMEWORK_PATH/$FRAMEWORK $BUILD/Release-iphonesimulator/$FRAMEWORK_PATH/$FRAMEWORK -output $BUILD/Release-universal/$FRAMEWORK_PATH/$FRAMEWORK

tar -czv -C $BUILD/Release-universal -f $FRAMEWORK.tar.gz $FRAMEWORK_PATH $FRAMEWORK_PATH.dSYM

Place the script in the project root directory and make sure it has execute permission. See this article for more information:

https://gkbrown.org/2017/10/11/creating-a-universal-framework-in-xcode-9/

For an example that also supports tvOS, see:

https://github.com/gk-brown/Lima/blob/master/package.sh

@liuxuan30
Copy link
Member

would mind a PR for this? But I think there is already a binary in derivedData.

@gk-brown
Copy link
Author

gk-brown commented Feb 27, 2019

The framework in the DerivedData folder is not a universal binary - it won't run on both the simulator and an actual device. It would also require cloning and building the project manually.

Providing a pre-compiled universal binary would allow developers to download just the framework, instead of the entire codebase. For example, see the *.tar.gz files attached to this project release:

https://github.com/gk-brown/Lima/releases/tag/1.0.3

To use the framework, developers just need to extract the framework from the zip file and drag it to the "Embedded Binaries" section of their Xcode project.

@liuxuan30
Copy link
Member

is there any automated way to generate it? Welcome a PR. But this isn't a high priority for us

@gk-brown
Copy link
Author

Yes, running the script generates the framework bundle. I'll see if I can submit a PR.

@liuxuan30
Copy link
Member

liuxuan30 commented Mar 22, 2019

@gk-brown I mean can github or any service like travisCI has such feature? Running the script and upload it is still some kinds of manual work for us. a one click job is much preferred, though I wonder this isn't such service.

why not use carthage or pod if you don't want the source code?

While I'm writing this, I recall carthage seems to have a feature called 'pre-built framework' support. Realm seems already using it. So maybe carthage is a better choice.

@gk-brown
Copy link
Author

I provide universal binaries for my own projects because I don't want users to have to use a 3rd-party dependency management tool like CocoaPods or Carthage. They just need to drag the framework to the "Embedded Binaries" section of their Xcode project, as described here:

https://github.com/gk-brown/Lima#getting-lima

Carthage does provide support for pre-built frameworks, but you still need to build them yourself and add them to your repo. Additionally, users would have to use Carthage to consume them.

@liuxuan30
Copy link
Member

I see. what's your thought @jjatie @petester42 ?

@pmairoldi
Copy link
Collaborator

I might be a good idea now that swift is more stable from version to version. I know that for a while Apple didn’t recommend distributing precompiled frameworks. Has that changed? I would wait until swift 5 is out since it should be finally “stable”

@gk-brown
Copy link
Author

That's a good point. My earlier releases were all Objective-C, so binary compatibility was not an issue.

Swift 5 was released yesterday - I'll do some testing and update the ticket.

@jjatie
Copy link
Collaborator

jjatie commented Mar 26, 2019

Module Stability is not here yet. It is the goal for Swift 5.1

@gk-brown
Copy link
Author

You are right - just read that on the Swift blog.

Maybe Xcode 11 will provide out-of-the-box support for building frameworks, so this script will no longer be necessary.

@liuxuan30
Copy link
Member

so... we just wait for now? closing this is ok? @gk-brown

@gk-brown
Copy link
Author

Closing is fine, although I do think it would be useful to provide a pre-compiled framework once the binary compatibility issues are resolved.

@liuxuan30
Copy link
Member

sure. when the time comes.

@ghost
Copy link

ghost commented Dec 3, 2020

Hi, sorry to open this but I need to add this as .framework in my project.... done the script but when running in simulator I get XXX.xcodeproj Building for iOS Simulator, but the linked and embedded framework 'Charts.framework' was built for iOS.

I added the Release-universal to the project

Any help please?

@gk-brown
Copy link
Author

gk-brown commented Dec 3, 2020

@TGWC I ended up using the Swift package instead, which has worked well.

@ghost
Copy link

ghost commented Dec 3, 2020

how to do it ? Any tutorial ? Sorry

@gk-brown
Copy link
Author

gk-brown commented Dec 3, 2020

Unfortunately, it looks like the project maintainers still don't provide any instructions on how to use Charts as a Swift package. Maybe this will help:

https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app

@liuxuan30
Copy link
Member

liuxuan30 commented Dec 14, 2020

I think we already supported Swift Package? There is a config file already. I don't realize the issue @gk-brown
https://github.com/danielgindi/Charts/blob/master/Package.swift

@gk-brown
Copy link
Author

You do support using Charts as a Swift package. However, unlike Cocoapods and Carthage, I don't believe this is documented anywhere.

@jjatie
Copy link
Collaborator

jjatie commented Dec 14, 2020

There is now an SPM Install section, mirroring the detail common in popular iOS libraries. If you feel further instructions are required for less common use cases, please submit a PR.

@ChartsOrg ChartsOrg locked as resolved and limited conversation to collaborators Dec 14, 2020
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

4 participants