Could Sharpie create fully fat framework/library for a pod?

tuyenvtuyenv VNUniversity ✭✭✭
edited June 2017 in Xamarin.iOS

Hi,

I tried to create binding for a library which is published with its source code in a pod.

I used sharpie pod commands, but the output library is just for device, not including library for simulator.

Is that a bug or do I need to pass in any other arguments?

Regards.

Answers

  • What is the answer to this?

  • tuyenvtuyenv VNUniversity ✭✭✭

    No one answered, sadly.

  • karanthakkarkaranthakkar USMember ✭✭

    i recently working with with sharpie pod

    when you creating any sharpie that will release multiple .a files, which actually library files to support different architectures of devices i.e. x86, 64 (for simulator) or ARM7, ARMV7 and ARM64.

    you have to merge this file into one library file with use of makefile.ios
    here is the link that will demonstrate how to create use makefile
    https://stackoverflow.com/questions/28428051/how-to-create-a-static-library-using-makefile-ios-in-rubber-band-project

  • tuyenvtuyenv VNUniversity ✭✭✭
    Actually, we only able to do this in simple cases. In more advanced libs like Mapbox, Braintree, sharpie is to help to generate the ApiDefintions at most. But the latest version it always error.
  • ashwindmkashwindmk Member ✭✭

    I solved this problem by creating Release-iphoneos framework and Release-iphonesimulator framework and then merged them using lipo.

    Most answers would end here, but I will give you the steps as well :)

    Here is the solution:

    1. sharpie pod init ios YourPodName

    Sharpie will create a dummy iOS app 'ObjectiveSharpieIntegration' with your pod as dependency.
    
    This will create a podfile, podfile.lock and Pods directory within the directory where you have run your command.
    

    2. sharpie pod bind

    This command will only create Release-iphoneos framework within build directory. 
    
    In order to create Release-iphonesimulator framework, you need to follow steps 3 and 4.
    

    3. Open Pods/Pods.xcodeproj in XCode

    3.1. Go to project navigator and select top-level Pods.
    
    3.2. Select your pod in targets and go to Build Settings.
    
    3.3. Add Valid Architectures: arm64, armv7, armv7s, x86_64, i386
    
    3.4. Set Build Active Architectures Only to 'NO".
    

    4. Build Release-iphonesimulator framework

    4.1. Product > Scheme > Manage Schemes... > Select your pod.
    
    4.2. Product > Scheme > Edit Scheme... > Change Build Configuration to Release. Close
    
    4.3. Select any latest simulator for building the framework and then Product > Build.
    
    Now you will find Release-iphonesimulator in your build directory.
    
    The last step is to create universal library as follows.
    

    5. Merge the frameworks into a single universal-framework

    5.1. Create a new directory within build directory as Release-universal.
    
    5.2. If your pod builds are frameworks then copy and paste the Release-iphoneos framework in Release-universal directory and then delete YourPodName.framework/YourPodName file. Else if your pod builds are static binary (.a) files then copy and paste the build/Release-iphoneos/YourPodName directory in build/Release-universal/.
    
    5.4. For framework: 
      lipo -create [path to Release-iphoneos framework]  [path to Release-iphonesimulator framework]  -output  [destination path to universal-framework]
    
      For example: lipo -create Release-iphoneos/MyTestAppEx/MyTestAppEx.framework/MyTestAppEx  Release-iphonesimulator/MyTestAppEx/MyTestAppEx.framework/MyTestAppEx  -output Release-universal/MyTestAppEx.framework/MyTestAppEx
    
      For fat static binary:
      lipo -create [path to Release-iphoneos binary]  [path to Release-iphonesimulator binary]  -output  [destination path to fat-static-binary]
    
      For example: lipo -create Release-iphoneos/MyTestAppEx/MyTestAppEx.a  Release-iphonesimulator/MyTestAppEx/MyTestAppEx.a  -output Release-universal/MyTestAppEx/MyTestAppEx.a
    
      Done!
    

    6. Verification

    If you want to check the supported architectures in your newly created universal files, then run the command:
    
      lipo -info YourPodName.a
    
      OR
    
      lipo -info YourPodName.frmaework/YourPodName
    

    Hope this helps someone. :)

    Let me know if you still have any doubts.

Sign In or Register to comment.