Swift Package Manager and Cocoapods together: Compiler errors in Swift Package after Cocoapod Pod addition - parse-platform

I am developing an iOS app using the ParseSwift SDK. When I set up my project I added ParseSwift via the Swift Package Manager, which worked like a charm. Server connection and saving and querying for data on the server all works and my app compiles in its current state.
To add online meeting capabilities I have been trying to add the JitsiMeet iOS SDK.
After trying to add it via Swift Package Manager, I read on the Jitsi forum that the preferred way of adding it to an existing project is via Cocoapods, and there are currently no plans of supporting the Swift Package Manager. After finding several questions about interoperability of SPM and Cocoapods here I was hoping it would be smooth sailing.
After some back and forth to make Cocoapods work with my M1, I then tried several different Podfile variants to successfully add the JitsiMeetSDK Pod to my project. These variants include:
adding or leaving out the platform part so it is assigned by Cocoapods
adding or leaving out use_frameworks!
installing with or without the post_install block (which is taken from the Jitsi documentation)
This is my Podfile:
platform :ios, '15.0'
target 'MyApp' do
use_frameworks!
pod 'JitsiMeetSDK'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
The short version is: this does not work. My app doesn't compile anymore.
Here is the strange part: while Cocoapods successfully adds the JitsiMeetSDK Pod, when I open the .xcworkspace file and try to compile it I now get tons of compiler warnings for the ParseSwift package that I added via the Swift Package Manager. These errors all concern Concurrency or features only available in iOS 15 - which should not be a problem, since I set the platform to ios, '15.0' in my Podfile.
The ParseSwift files are also annotated and do have checks for Concurrency, which is why I understand this error even less. (screenshots of compiler errors and annotations below)
Is there an order that I have to follow when it comes to adding packages (first Cocoapods, then SPM)? Or any App settings I need to change now that two package managers are in the mix? Any help is appreciated!
I am using
Xcode 13.1
Swift version 5.5.1 (arm64)
Cocoapods 1.11.2 (installed via Home-brew for M1 support)
ParseSwift SDK 2.5.0 (via SPM)
JitsiMeet SDK 4.0.0 (via Cocoapods)
Here is a screenshot of the error messages (one example of almost 300 such cases):

So, I used your Podfile with a new project and ended up with the exact same result.
Then I tried first run Cocoapods for JitsiMeetSDK, then adding the ParseSwift with SPM. Same result.
The only way I was able to make it work was by having Cocoapods install both ParseSwift and JitsiMeetSDK.
platform :ios, '15.0'
target 'TestPackageManagers (iOS)' do
use_frameworks!
pod 'JitsiMeetSDK'
pod 'ParseSwift'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
pod install ran like a charm and I was able to compile and run everything.

You mentioned you are using ParseSwift SDK 2.5.0 in Xcode 13.1. This isn't possible.
Xcode made changes related to backwards compatibility in Xcode 13.2+.
You can resolve everything easily by upgrading to Xcode 13.2+. If you look at the release notes for ParseSwift it says specifically:
Requires Xcode 13.2 or above to use async/await. Not compatible with Xcode 13.0/1, will need to upgrade to 13.2+. Still works with Xcode 11/12
Basically, ParseSwift 2.4.0+ requires Xcode 13.2+. If you want to use Xcode 13.1 or lower, you need to use ParseSwift 2.3.1 or lower. More info can be found in the PR that made the change.
You will face this same issue with any dependency that adds the async/await backwards compatibility for iOS13, so it's recommended to upgrade to Xcode 13.2+ sooner than later.
In addition, the problem isn't related to a mix of SPM and Cocoapods, these dependency managers have nothing to do with each other and you shouldn't have any issues using ParseSwift through SPM along with others in Cocoapods.

The described Concurrency errors were due to updating the ParseSwift package dependencies without updating Xcode to 13.2+ as #CoreyB pointed out.
Xcode 13.2 introduced other, unrelated bugs to my project but solved the Concurrency issue. The bugs were an Xcode 13.2 issue, and updating to Xcode 13.2.1 fixed these bugs.
After the update, I was able to add JitsiMeetSDK via Cocoapods to my existing project.
Thanks to #CoreyB and #Alex Kusmenkovsky for their helpful input!

Related

Kingfisher Swift Compiler error when Archiving

I'm using xCode 13 beta 4 and want to archive my project containing Kingfisher.
The app runs fine under iOS 15, however I get the following errors when I look to archive it. Anyone with an idea what I should do? Thanks!
If you are using Xcode 13, here is a workaround.
If you need to use Xcode 13 but cannot upgrade to v7, use the version6-xcode13 branch. However, you have to drop iOS 10 support due to an Xcode 13 bug.
pod 'Kingfisher', :git => 'https://github.com/onevcat/Kingfisher.git', :branch => 'version6-xcode13'
Having Xcode 13 upgrade, after pod update, I start getting the same issue as you, after a workaround, I found two ways:
Downgrade Kingfisher to 5.x like:
pod 'Kingfisher', '~>5.15.7'
OR
In Deployment Info, upgrade your iOS support version to 12.0
Waiting for any fix from Kingfisher, I opted for downgrading to 5.x
Using Kingfisher 7.0.0 beta version should solve it.
E.g. pod 'Kingfisher', '~> 7.0'
This script worked for me on Xcode 13
post_install do |pi|
pi.pods_project.targets.each do |t|
t.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
end
end
end

Red frameworks in xcode from CocoaPods

My frameworks in xcode are all red. I tried re-installing/updating the frameworks by using pods install and pods update. I also tried changing the path/location of the frameworks as well as re-installing xcode and even updating xcode to the newest beta version.
Have you updated cocoa pods to 1.4.0 (sudo gem install cocoapods?

Support for Kanna framework in Swift 3.0?

After migrating my project from Swift 2.2 to 3.0 I get an error message on the Kanna framework, saying that
Module file was created by an older version of the compiler. Rebuild Kanna and try again
Have I done anything wrong or does the Kanna framework not work under Swift 3.0?
To use Kanna library (CocoaPods) you need add it to your Podfile:
use_frameworks!
pod 'Kanna', git: 'https://github.com/tid-kijyun/Kanna.git', branch: 'swift3.0'
then in terminal:
rm Podfile.lock (if exist)
pod init
pod update
pod install
Take tutorial from here
There is a now a working version for Swift 3.0, using carthage. Everything is described here:
Kanna github

AlamoFire + SwiftyJSON on iOS 9.0

I have been trying to install and use AlamoFire and SwiftyJSON on iOS 9 using CocoaPods. The latest version keeps getting installed and it is not compatible with iOS 9.0.
My PodFile looks like this:
platform :ios, '9.0'
use_frameworks!
target 'Kitchology' do
pod 'Alamofire'
pod 'SwiftyJSON'
pod 'AlamofireImage'
end
I tried commenting them out and doing a pod install to remove them, then put them back in and do another pod install. Every time the latest is installed.
I do have the project itself set to iOS 9.0 and NOT iOS 9.3 for the project build on all versions.
Figured this one out. I deleted the pods by commenting them out and running pod update. Then we deleted the workspace. Then comes the main part of the solution - we deleted everything in the derived data folder. You can find this location in Xcode->Preferences Locations. Although a clean should delete this data, it obviously did not.
Now we recreate the pods again. Do a pod init, add the pods back into the Podfile and do a pod install. Open the workspace and everything was then good.
This was a problem with cached data in Xcode.

CocoaPods v0.39.0 errors with Facebook SDK v4.7

Old Cocoapods Configuration
I am using Xcode 7 Beta 4. Initially I was using Cocoapods version 0.38.2 and when I ran pod install --verbose in Terminal it said it downloaded dependencies for Bolts, FBSDKCoreKit, FBSDKLoginKit, FBSDKShareKit, FBSDKMessengerShareKit, and Pods for iOS 8.1. With this setup my app compiled successfully. Below is the Podfile and Objective-C Bridging File that I used to import the Facebook SDK (so Swift recognises its referenced methods and Objective-C classes). Note that the specific versions shown in my Podfile are also the versions that get installed even if I do not explicitly specify them at the time of this writing.
Podfile
xcodeproj '/Users/<my_username>/MyApp/MyApp.xcodeproj'
pod "FBSDKCoreKit", "~> 4.7.0";
pod "FBSDKLoginKit", "~> 4.7.0";
pod "FBSDKShareKit", "~> 4.7.0";
pod "FBSDKMessengerShareKit", "~> 1.3.1";
MyAppObjCBridging.h
#ifndef MyAppObjCBridging_h
#define MyAppObjCBridging_h
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import <FBSDKMessengerShareKit/FBSDKMessengerShareKit.h>
#import <FBSDKShareKit/FBSDKShareKit.h>
#endif
Problems encountered when updating to Cocoapods v0.39.0 (from v0.38.2)
The console showed the message "CocoaPods 0.39.0 is available. To update use: gem install cocoapods. Until we reach version 1.0 the features of CocoaPods can and will change. We strongly recommend that you use the latest version at all times.", so I installed the this latest version of Cocoapods 0.39.0 by executing sudo gem install cocoapods in Terminal.
But when I compiled my app it gave me the following errors:
/Users//MyApp/MyApp/MyAppObjCBridging.h:14:9: 'FBSDKCoreKit/FBSDKCoreKit.h' file not found
In Xcode I "Product > Clean" (CMD+SHIFT+K), but this did not make any difference. So I ran sudo gem uninstall cocoapods in Terminal (which listed 0.38.2 and 0.39.0 as the versions that were currently installed) and selected version 0.39.0 from the list to uninstall the latest version and revert back to 0.38.2. I then ran pod install --verbose. When I tried to compile my app it compiled successfully and ran in Simulator again.
Question 1
Why does it give the error that it can't find "FBSDKCoreKit/FBSDKCoreKit.h" when I use Cocoapods version 0.39.0 instead of the older version 0.38.2?
Question 2
If when using Cocoapods version 0.38.2 (the version that compiles with my app) I decided to add platform :ios, '9.0' to the first line of my Podfile (above its existing contents) and run pod install --verbose in Terminal, the Terminal messages tell me that it installs each pod target for iOS 9.0 (instead of iOS 8.1) (i.e. - Installing targetFBSDKCoreKitiOS 9.0).
When I then run my app it successfully compiles and opens in Simulator and displays some new warnings associated with iOS9, most of which I understand. However I do not understand why this one appears. Why is this warning appearing?:
ld: warning: directory not found for option '-L/Users/Ls/code/swift/FreeWifiSearch/FreeWifiSearch/build/Debug-iphoneos'
Question 3
When using Cocoapods version 0.38.2 (the version that compiles with my app), if I decided to add use_frameworks! to the first line of my Podfile, and platform :ios, '9.0' to the second line of my Podfile (above its existing contents), and then run pod install --verbose in Terminal, the Terminal messages tell me that it installs each pod target for iOS 9.0 (instead of iOS 8.1).
When I then run my app the following errors appear:
Use of unresolved identifier 'FBSDKLoginButton'
Use of unresolved identifier 'FBSDKLoginManager'
Use of unresolved identifier 'FBSDKLoginBehaviour'
Why does adding use_frameworks! to the top of my Podfile prevent me from using the Facebook SDK identifiers? (noting that when I don't have use_frameworks! at the top of my Podfile my app successfully compiles and runs in Xcode Simulator, and I can successfully retrieve a Facebook SDK Access Token and login to Facebook)
Since posting the original questions the following was performed and resulted in no compiler errors:
Updated from Xcode 7 Beta 4 to Xcode 7.1.1 by downloading latest from App Store
Added use_frameworks! and platform :ios, '9.0' to top of Podfile
Changed deployment target to iOS 9.0: Project Settings > Targets > General > Deployment Info > Deployment Target > 9.0
Updated CocoaPods to v0.39 with sudo gem install cocoapods
Reinstalled pods with pod update --verbose
Added import FBSDKLoginKit above the class containing Facebook SDK methods
Performed Clean (Shift+CMD+K) and Run (CMD+R) in Xcode to test on device
Add "${PODS_ROOT}/Headers/Public/FBSDKCoreKit/FBSDKCoreKit" in your target's Header Search Paths in Build Settings
For me it's OK now(CocoaPods 0.39, FBSDK 4.10)

Resources