splitio / ios-client

iOS SDK client for Split Software
https://split.io
Other
11 stars 18 forks source link

Not able to generate .xcframework #401

Closed jbatra-umeey closed 1 year ago

jbatra-umeey commented 1 year ago

Hello,

I tried gen_static_xcframework script but its failing with the below error

GenerateDSYMFile /Users/XXX/Downloads/ios-client-master\ 3/SplitXcFramework/device/Build/Products/Release-iphoneos/Split_Split.bundle.dSYM /Users/XXX/Downloads/ios-client-master\ 3/SplitXcFramework/device/Build/Products/Release-iphoneos/Split_Split.bundle/Split_Split (in target 'Split_Split' from project 'Split')
    cd /Users/XXX/Downloads/ios-client-master\ 3
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/XXX/Downloads/ios-client-master\ 3/SplitXcFramework/device/Build/Products/Release-iphoneos/Split_Split.bundle/Split_Split -o /Users/XXX/Downloads/ios-client-master\ 3/SplitXcFramework/device/Build/Products/Release-iphoneos/Split_Split.bundle.dSYM

** BUILD FAILED **

The following build commands failed:
    CompileSwift normal arm64 (in target 'Splitlib' from project 'Split')
    CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'Splitlib' from project 'Split')
(2 failures)
Creating XCFramework from /Users/XXX/Downloads/ios-client-master 3/SplitXcFramework/simulator and /Users/XXX/Downloads/ios-client-master 3/SplitXcFramework/device into /Users/XXX/Downloads/ios-client-master 3/SplitXcFramework/SplitXcFramework.xcframework
2022-11-25 19:17:03.507 xcodebuild[28135:443914] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-11-25 19:17:03.507 xcodebuild[28135:443914] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
error: invalid argument '3/SplitXcFramework/simulator/Build/Products/Release-iphonesimulator/libSplitlib.a'.
Removing intermediate folders
Generating zip file from xcframework /Users/XXX/Downloads/ios-client-master 3/SplitXcFramework/split-ios-.zip from /Users/XXX/Downloads/ios-client-master 3/SplitXcFramework/SplitXcFramework.xcframework
/Users/XXX/Documents/jb-ios-splitIO-upstream/jb-ios-splitio-upstream/scripts/gen_static_xcframework: line 50: cd: /Users/XXX/Downloads/ios-client-master: No such file or directory
    zip warning: name not matched: SplitXcFramework.xcframework

zip error: Nothing to do! (try: zip -r split-ios-.zip . -i SplitXcFramework.xcframework)
/Users/XXX/Documents/jb-ios-splitIO-upstream/jb-ios-splitio-upstream/scripts/gen_static_xcframework: line 52: cd: /Users/XXX/Downloads/ios-client-master: No such file or directory
Computing package checksum
error: Unexpected argument '3/SplitXcFramework/split-ios-.zip'
Usage: swift package compute-checksum [<options>] <path>
  See 'package compute-checksum -help' for more information.
Checking release type 
/Users/XXX/Documents/jb-ios-splitIO-upstream/jb-ios-splitio-upstream/scripts/gen_static_xcframework: line 58: [: -eq: unary operator expected
Update swift package
agustinona commented 1 year ago

Hi @jbatra-umeey,

gen_static_xcframework is not meant to be run locally, and is currently unused and needs to be updated. May I ask what's your use case for this?

jbatra-umeey commented 1 year ago

@agustinona , I have an older project which is still using .xcframework and we do not plan to move to SPM anytime soon. Hence, to maintain consistency, we want to use a .xcframework of SplitIO

I also tried a couple of other options

https://github.com/darrarski/xcframework-maker https://github.com/mstfy/spm-to-xcframework

Here, I get an issue with JFBCrypt "No such Module"

jbatra-umeey commented 1 year ago

@agustinona Can you please suggest the right way to generate .xcframework of SplitIO

valllllll2000 commented 1 year ago

I am having the same issue, if I add Split via Cocoapods, no problem, but our SDK needs to also needs .xcframework and in this case I get the same error: JFBCrypt "No such Module" that @jbatra-umeey is having. This is blocking the release of our SDK, is there a workaround? A bit more background: when I integrate your SDK either via SPM or cocoapods all works fine even in the example app we have inside the SDK project. Once I build the .Xcframework of my library, if I try to integrate it into a third party app via cocoapods, adding my lib + split all works fine but when I add the framework manually as described here: https://www.simpleswiftguide.com/how-to-add-xcframework-to-xcode-project/, the build fails and then even if I add Split with SPM, I still get the error with JFBCrypt

jbatra-umeey commented 1 year ago

@valllllll2000 adding another useful link https://mustafa-ysf.medium.com/creating-xcframework-from-swift-package-e8af6f44501f. Try to follow these steps and see if you can generate the framework

jbatra-umeey commented 1 year ago

@agustinona I think instead of using JFBCrypt https://github.com/jayfuerstenberg/JFCommon/issues?q=swift (pretty old repo) We can consider using https://github.com/felipeflorencio/BCryptSwift

@valllllll2000 , I was able to generate the .xcframework. Attaching it for your reference.

Few pre-requisites:

Split.xcframework.zip

valllllll2000 commented 1 year ago

@jbatra-umeey thanks, that's really helpful unfortunately it does not work, the commands in that tutorial do not work for me.

How exactly did you replace JFBCrypt by https://github.com/360Learning/BcryptSwift, did you use cocoapods or added the files by hand. I tried to add them by hand but it does not work as the naming is different.

Also what do you mean by .xcframework of swiftier instead of SPM? you mean adding the swiftier dependency using also and .xcframework?

I tried using your xcframework just to check if it would work for my project but it doesn't work as my other framework, the one that needs the Split dependency, was built with a later swift version.

jbatra-umeey commented 1 year ago

@valllllll2000 , I have attached the updated source files with swift support of JFBCrypt. You may skip the .xcframework version of Swiftier

Split.zip

./spm-to-xcframework YourPackageName --path path_to_your_package --output path_to_output

spm-to-xcframework.zip

valllllll2000 commented 1 year ago

thanks @jbatra-umeey that was really helpful! I ended up just adding the code to my project to avoid having to deal with 2 frameworks but your project really helped me to understand which classes to keep and which ones to not and how to replace the JBCrypt by the newer swift library

agustinona commented 1 year ago

Hi @jbatra-umeey and @valllllll2000 ,

I'm sorry I wasn't able to get back to you earlier. We currently do not support XCFramework as a way of distributing our SDK., so it needs to be generated locally as I see you have already done.

We plan to support XCFramework in the future. There is no current timeline for that but you can check the repo's changelogs for its release.

Kratikavmp commented 1 year ago

Hi @jbatra-umeey and @valllllll2000 , The attached version of XCFramework is giving "unable to install" error while running my project on device,

Kratikavmp commented 1 year ago

What exactly is the script used to generate the XCFramework ?

agustinona commented 1 year ago

@jbatra-umeey @valllllll2000 @Kratikavmp

We have released v2.19.1 which should make it easier to generate an xcframework, and have cleaned up the scripts that were causing issues. You can use this script as a starting point to generate the xcframework: https://github.com/splitio/ios-client/blob/2.19.1/scripts/generate_xcframework

agustinona commented 1 year ago

@jbatra-umeey @valllllll2000 @Kratikavmp This issue has been inactive for a while now and has been addressed in a recent release, so I'm closing it now.