Module 'SocketIO' was not compiled with library evolution support; using it means binary compatibility for framework can't be guaranteed - ios

When I install SocketIO in my Framework project using Swift Package Manager the build is successful but there is a warning "Module 'SocketIO' was not compiled with library evolution support; using it means binary compatibility for 'framework name' can't be guaranteed".
Note: I enabled Build Libraries for Distribution to YES in both project target. Socket IO framework I installed in my framework project using Swift Package Manager.(Using cocoa pods xcframework generation is not working for SocketIO).
Eventually I have to generate XCFramework out of this framework project, even If I generate XCFramework with the warning the final .xcframework is not support when I import it any project. Xcode says "Fail to load module SocketIO"
Can any one help me on this? I tried many possibilities from last one week.
Thanks in advance.

I have the same problem. I think, that we have to wait for Xcode 11.4 and Swift 5.2 release. Then, we can try to create Package.swift for our xcframework and list all dependencies there e.g. SocketIO.
The client app will fetch this manifest and resolve all dependencies.

Related

Do I still need CocoaPod installation?

I am new to XCode and Swift. Trying to create a simple project that uses MQTT protocol. For that, there is a Swift library CocoaMQTT and there are directions on how to integrate it in an XCode project:
Installation
To integrate CocoaMQTT into your Xcode project using CocoaPods,
you need to modify you Podfile like the followings:
use_frameworks!
target 'Example' do
pod 'CocoaMQTT' end
Then, run the following command:
$ pod install
At last, import "CocoaMQTT" to your project:
import CocoaMQTT
The directives above are not straight forward to me as for a newbie, and I followed another way by importing the CocoaMQTT package through the XCode main menu: File -> Add Packages. Once the package was downloaded, I saw that the package (and the other dependencies) were automatically added to my project in the file navigator:
Question: do I still need to do CocoaPad installation as described above, or importing the package as I did is the new and sufficient way to integrate the library into the project? The Podfile that is mentioned in the instructions cannot be modified in XCode.
[Swift package] is the new and sufficient way
Correct. The library is now installed in your project and there is no further work to do.
In general, Swift packages supersede Cocoapods. Wherever possible, if a library offers a Swift package installation, you'll probably want to use that rather than Cocoapods.
In this particular case, you should file an issue on the documentation. They have added Swift Package as an alternative way of installing this library but they have forgotten to add that information to the instructions in the Readme.

What is the best practice to include third party ios sdk framework in react-native module library?

I am trying to include ios sdk framework in my react-native module library. I turned always embed swift standard library to Yes in build setting. Everything compiles fine.
Then I include the node module in an app using npm i react-native-my-framework, open sampleapp.xcworkspace and build in XCode, I get an error MyFramework/MyFramework-Swift.h not found. I tried following permutation combinations:
Put MyFramework to Frameworks, Library and Embedded Contents. and tried some other combination of build settings.
Set the framework search path in the library project - $(PROJECT_DIR)/../node_modules/react-native-my-framework/ios/
I manually included libMyFramework.a to Libraries group.
But I am still facing the same issue. What am I missing here?
Also, MyFramework is not on Cocoa pods
Update:
Now MyFramework is available on Cocoapods

Migrating from Cocoapods to Swift Package Manager but import module failed

recently I'm refactoring a project which uses Cocoapods to manage dependencies (a lot of dependencies...), since Xcode 11 integrated Swift Package Manager, I want to migrate progressively some dependencies to SPM staring from the framework Alamofire.
After I removed the Alamofire from the Podfile (delete and run pod install) and added it into SPM,
I got the error No such module 'Alamofire'.
I've already tried to clean build and removed derived data but none of them can fix it.
Did anyone have this problem too?
After few days searching, I found out this https://stackoverflow.com/a/57312755/863020.
Seems that SPM could be only used for Debug and Release configurations, if we want to use it with more configurations then we should write a pre-action. And it is also a known issue on Xcode so I would not use SPM for now :(
UPDATED on dec. 12
So I come back to my question after the new release of Xcode 11.3, it fixed this issue and now I can build the project with custom build configuration :)

Module compiled with Swift 4.2.1 cannot be imported by the Swift 5.0 compiler

I am trying to implement integration of third party app into project as per instruciton https://github.com/Paytm-Payments/Paytm_iOS_App_Kit/tree/master/Swift/BitCodeDisabled/PaytmNativeSDK
I see the following error in build
Module compiled with Swift 4.2.1 cannot be imported by the Swift 5.0
compiler
I have tried toolchains https://medium.com/xcblog/switching-swift-versions-inside-xcode-using-toolchains-755b28831c43
The error changes to Reason: Incompatible library version: PaytmNativeSDK requires version 1.0.0 or later, but libswiftCore.dylib provides version 0.0.0
How do i setup XCode or the Library to make it work . There is no chance of the vendor updating the library for Swift 5.0 and make it available on POD.
For Carthage users: After upgrading to Xcode 10.2, I ran into this same issue with a framework that I had been importing using Carthage.
I resolved it by rebuilding the framework:
carthage update --no-use-binaries --platform iOS
The correct solution is download Xcode 10.1, and wait for Apple patch the bug fix.
Don't waste time on fix third-party bug.
The problem of my project is we are using Alamofire which is failed to update by Carthage.
The provider of this library should rebuild it with BUILD_LIBRARY_FOR_DISTRIBUTION = YES; (available in Xcode 11.3 in Build Settings -> Build Options). Already asked to do it in the corresponding GitHub issue. After that PaytmNativeSDK will be compatible with every next Swift version.
It looks like the issue has been fixed in 804152caae76245d96548eb74ea87a6150239407.
I wanted to use Swift 4.2 (which Xcode 10.2 should still support, I've set it in Swift Language Version), but it still gave me an error about the Swift 5.0 compiler. So after trying to clear everything like build folder, derived data and stuff, I came to the conclusion that it does not work on Xcode 10.2.
I reverted back to Xcode 10.1 which you can download here. This works. So until Apple fixes this bug I am forced to stay on Xcode 10.1.
The developers of the framework need to provide an update, which is built in Xcode 10.2.
Explanation for framework developers:
Even if you created the framework in Xcode 10.2 or with the default version used by CI, your users may still encounter such an error. You should make sure that Xcode 10.2 is your default command line tool. You can check it in terminal with the command xcodebuild -version.
Default version can be adjusted in Xcode -> Preferences -> Locations -> Command Line Tools.
This will happen if you have external libraries in your project thats still built using 4.2 compiler, whereas the new Xcode tries building your project in 5.0 compiler.
In my case, I had few libraries imported using Carthage. Luckily the libraries that I have used have released an updates in the past few days making it compatible with Swift 5.0 compilers. If those external libraries haven't updated it to support Swift 5.0 you may be out of luck for now.
On the way you might still face few issues and here are some best practices to avoid further issues.
Remove the cartfile.resolved and Carthage folder completely
Ensure you remove any copy of the libraries added to your project earlier.
Remove the embedded libraries and Linked frameworks and libraries from your Targets> Yourapp > General .
Product > Clean build folder
Update the Cart file and fetch the new sources using the Carthage update command
Now import the libraries back to your project.
Hopefully it works.
My problem with Carthage was related to the xcode phase that copys binaries in
"carthage copy-frameworks" phase.
I've a slightly different solution to the one commented in https://stackoverflow.com/a/55362536/721929, because that solution also updates dependencies versions in some cases.
So, I just executed "carthage build". I also include a cache clean for Carthage, to fix possible errors in subtasks (in my case, failing in git clone with "exit code 1")
rm -rf ~/Library/Caches/org.carthage.CarthageKit
carthage build --no-use-binaries --platform iOS --verbose
Just remove all the *.framework folders, fetch and generate then just Import the new framework folders to your project.
That's what helped me.
For Instance:

How to import external iOS framework in flutter plugin?

I'm doing a flutter plugin for stream video by using RTSP protocol. I had no problem develop it for Android, but in iOS things are more complex. I have to use an external library (SGPlayer) for getting the player work. I also downloaded the demo that uses this library and seems to work. This library is NOT on Cocoapods and I need to import it directly into the plugin project from my file system. the downloaded and compiled file structure of the plugin that I would like to use looks like this:
My problem is adding the ".framework" extension file correctly to the iOS project in a way that I can use it to develop the flutter plugin (iOS part).
UPDATE:
I built the project with the framework by using instructions at this link: https://github.com/flutter/flutter/issues/17978
The problem now is that while compiling the framework it change the umbrella header because, I think, it's not using the framework module.modulemap but another one. The result is that is importing just some header and implementations, and not all.
1.Place myFramework.framework to iOS plugin folder /ios ex: myPlugin/ios
2.Update iOS plugin file: myPlugin/ios/myPlugin.podspec
Adding the below line at the bottom of the file, above 'end'
s.vendored_frameworks = 'myFramework.framework'
In Terminal : cd to myPlugin/example/ios
run command
pod install
or
pod update
Now we can find the iOS plugin code by open iOS project (example/ios/Runner.xcworkspace) in XCode and go to
#Lorenzo you can pack your plugin and make private CocoaPod or Carthage repo.
Here is a good article howtos

Resources