Do I still need CocoaPod installation? - ios

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.

Related

libPhonenumber (from Google) on iOS in a Kotlin Native project

I've been struggling to solve a problem.
I'm building a cross platform app (iOS and Android) using Kotlin Multiplatform (KMP) where I need a library from Google (https://github.com/google/libphonenumber).
For Android, I can point to a Maven repo (https://repo1.maven.org/maven2/com/googlecode/libphonenumber/libphonenumber/8.12.6/).
For iOS, I can use a ObjC port of libPhonenumber via Cocoapods.(https://cocoapods.org/pods/libPhoneNumber-ios).
But, I can't use Kotlin's (cocoapod plugin) to properly recognize the Pod. The plugin appears to fail to build.
Here's the details of my setup:
Xcode v11.5
IntelliJ IDEA v2020.1.2
Cocoapods v1.9.1
Gradle 6.0.1
Sample repo (https://github.com/touchlab/kotlin-native)
NOTE: Within the repo, I'm using ./samples/cocoapods
modify ./samples/cocoapods/kotlin-library/build.gradle.kts
commented out AFNetworking, remove AFNetworking pod
pod("AFNetworking", "~> 3.2.0")
add a new pod
pod("libPhoneNumber-iOS")
modify ./samples/cocoapods/kotlin-library/gradle.properties
change this line:
kotlin.native.home=../../../dist
to this:
#kotlin.native.home=../../../dist
in Terminal in this folder: ./samples/cocoapods/kotlin-library/
./gradlew podspec
This creates a podspec file (libPhoneNumber-iOS.def) in ./samples/cocoapods/kotlin-library/build/cocoapods/defs/
cd from kotlin-library to ios-app folder
cd ../ios-app/
Pod install using the command:
pod install
You'll see something like:
Downloading dependencies
Installing kotlin_library (1.0)
Installing libPhoneNumber-iOS (0.9.15)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.
When I build the sample 'ios-app' target: simulator in Xcode, I get the error:
fatal error: module 'libPhoneNumber' not found
I have tried other libPhoneNumber pods, such as:
libPhoneNumberSwift
LTPhoneNumberField
Both fail to build using Kotlin's cocoapods plugin, but work as a Pod without Kotlin's cocoapod plugin.
What am I missing?
This particular problem seems to be caused by the dash in the pod's name. There was already an issue reported on GitHub. For now, it's recommended to workaround this problem by re-naming the module. Changing your kotlin-library/build.gradle.kts like
pod("libPhoneNumber-iOS", moduleName = "libPhoneNumber_iOS")
should help. Please give it a try and tell here or on GH if it works.
I have obtained excellent results by adding the unchanged Javascript version of libphonenumber using JavaScriptCore in IOS. The only part of the library not available yet in Javascript is the geocoder.
I used the concept explained here: https://www.appcoda.com/javascriptcore-swift .
Performance is great and there is no porting involved. Always the latest version available.

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

Instaling without cocoapods

https://github.com/IBM-Swift/Swift-SMTP
Im sorry if this is a dumb question but I am trying to install this inside my app and there is no documentation on how to add it. I always use cocoapods but it seems this can't be used for this project. Could anyone help me I need this functionality
That particular project/repo uses Swift Package Manager, so in Terminal cd into the project root:
$ swift package generate-xcodeproj
This will create an .xcodeproject which you'll then open and build. Once you've done that just drag the built framework into the project you'd like to include it in and use the import:
import SwiftSMTP

Xcode showing error 'No such module' even though I've installed Cocoapods and installed pod file of Dialogflow

I've been making a chatbot using Dialogflow formerly Api.AI but now encountering error while integrating the project to my app written in Swift in Xcode. I'd installed cocoapods using terminal "sudo gem install cocoapods" and using this version of Dialogflow to create the podfile.
All gone well but now when I'm importing inside Xcode in my app's AppDelegate.swift file using import ApiAI or import AI Xcode is showing me error that No such module. Please refer to image.
And on GitHub this library which is written in Swift, showing that it has depreciated and asking me to refer to API.AI's Apple Client library which is in Obj-C and unfortunately I've no expertise in Obj-C.
After installing a pod using Cocoa Pods, you must from that point forward open the workspace rather that the project file. The icons will appear differently in your project like so:
In the image you provided is clearly showing that you have opened the project file not the workspace one.
Go to Pods Build settings and set Build Active Architecture Only to NO. This always helps while using pods. After that clean the project once and then build.
After installing pod you should clean project (shift + command + k) and then builds (command + b) in it a few times. Repeat it a few times if it is not still working.
Hope this help!

SocketIO manual installation for iOS app swift 4 xcode 9

I am having difficulty installing SocketIO for my Swift 4/Xcode 9 app. I have tried Swift Package Manager and Carthage and both did not work. Separate threads for those issues. I do not want to use Cocoapods.
Is there a way to manually install the libraries? I can drag and drop the Source files successfully however I don't know how to add the SocketIO and Starscream frameworks from the Git downloaded files. I can figure out how to link the binaries and that stuff myself, just want to know where I can physically extract the two frameworks from in the downloaded file.
Did you check in your project folder, the Carthage folder then Build folder then iOS folder and same with the Checkout folder?

Resources