"sharpie pod bind" and simulator architecture

aminegamineg Member

Hello,
I have a library that I am binding for Xamarin.
My library have multiple dependencies.
I used "sharpie pod bind" command to create the .frameworks used as native references.

My problem is that the the .framework generated by the command "sharpie pod bind" contain only devices architectures, and does not include simulator.
Is there a way to run "sharpie pod bind" for the simulator architecture ?
Otherwise, is there a way to know what commands are executed when running "sharpie pod bind"

Answers

  • I have the same question

  • ashwindmkashwindmk Member ✭✭

    Exactly, please someone specify how to get universal build using 'sharpie pod bind'. Please do not answer only with hyper-links. If not possible then please let us know.

  • ashwindmkashwindmk Member ✭✭
    edited September 2018

    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.

  • DavidConliskDavidConlisk GBMember ✭✭

    Thanks @ashwindmk your instructions were a big help.

Sign In or Register to comment.