Reactive Cocoa for Swift 3.0 - ios

I am updating a project from Swift 2.x to 3.0. I have ReactiveCocoa version v4.2.2 installed via Carthage. To update reactive cocoa I have updated my cart file as
github "ReactiveCocoa/ReactiveCocoa" "master"
When I run command Carthage update, it gives the following error in terminal:
No tagged versions found for github "ReactiveCocoa/ReactiveSwift"
How do I fix this?

the github link is wrong.
github "ReactiveCocoa/ReactiveSwift" "master"

Following link helped sove the issue
https://github.com/Carthage/Carthage/releases/tag/0.15.1

try this:
github "ReactiveCocoa/ReactiveCocoa" "5.0.0-alpha.1"
it's an official release for Swift 3.

Try this...
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'targetName' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'ReactiveCocoa', :git => 'https://github.com/ReactiveCocoa/ReactiveCocoa.git', :tag => '5.0.0'
pod 'Result', :git => 'https://github.com/antitypical/Result.git', :tag => '3.1.0'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end

Related

How to add a thirdparty SDK (multiple .framework files) to react native library module?

I have built a react native library module (with RN 0.63). This module depends on some thirdparty SDKs. When integrated with Android (using .aar files) it works just fine. In case of iOS, I have been able to get the library module working without the SDK (using swift hence with the bridging header). On adding the SDK, I am getting errors such as .h is not avaialble.
This is my directory My directory structure:
react-native-lib
--android
--ios
----MyCls.swift
----MyCls.m
----react-native-lib-Bridging-Header.h
----SDKS
------DEBUG
--------A.framework
--------B.framework
--------A-Debug.podspec
--------B-Debug.podspec
------THIRDPARTY
--------JSONModel.framework
--------CocoaLumberjack.framework
--------... other frameworks
--react-native-lib.podspec
--Example
--index.js
--Logger.swift
--package.json
I have a sample application in Swift which uses the SDKS folder, but I cannot seem to get RN to recognize the framework files/headers.
The last few lines of the Podspec file of react-native-lib is as follows:
...
s.dependency "React"
s.dependency 'JSONModel', '~> 1.8.0'
s.dependency 'CocoaLumberjack', '~> 3.6.1'
My example application Podfile:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
use_frameworks!
project 'example', {
'Debug' => :debug,
'Release' => :release,
}
#
def applibs
pod 'A-Debug', :configuration => ['Debug'], :path => '../node_modules/react-native-lib/ios/SDKS/DEBUG/A-Debug.podspec'
# ... A-Release, B-Debug, B-Release
# The release folders not shown in structure above.
end
target 'example' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
applibs
# Disabled Flipper because of use_frameworks!
end
I am not sure what I am doing wrong and how I can overcome this issue. There seems to be not quite a lot of articles on how such 3rd party sdk can be integrated in a library module. I have explored similar questions like this one which is still unsolved and has insufficient information.
after days of research and experimenting, I have been able to resolve the problem. It's simple enough, made difficult with lack of resources on the topic.
Primarily, I used the podspec file in my react native lib (ios folder) to add dependency on the 3rd party frameworks as follows.
react-native-lib.podspec
s.dependency 'A-Debug', '~> 1.2.3', :configurations => :debug
s.dependency 'B-Debug', '~> 2.3.4', :configurations => :debug
s.dependency 'A-Release', '~> 1.2.3', :configurations => :release
s.dependency 'B-Release', '~> 2.3.4', :configurations => :release
In my example application, the podfile works as shown above (by adding the pods in applibs). However, I encountered the 'enable bitcode' error where the compiler asked me to recompile the 3rd party libraries with bitcode enabled. I worked around it with the following post install script in the application (not library) podfile (obtained from here).
Example/ios/Podfile
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
Do a cache clean, and as an extra measure, clear node modules.
Then simply run the following in your application directory:
yarn install && cd ios && pod install && cd .. && yarn react-native start
Open your project in Xcode and import your SDK as per its documentation. Hope this saves you hours of research, experiment and debugging.

iOS action extension Cocoapods Podfile FBSDKCoreKit 'sharedApplication' is unavailable

I need the Facebook SDK in both my app and my action extension. I use Cocoapods 1.4.0, Swift 4 and Xcode 9.2. I'm having this error message coming from the FBSDKCoreKit:
'sharedApplication' is unavailable: not available on iOS (App
Extension) - Use view controller based solutions where appropriate
instead.
I've already read a lot of answers, on SOF and Github mainly. I tried a lot of suggestions. But I did not make it work.
My current Podfile:
source 'https://github.com/CocoaPods/Specs.git'
workspace 'MyApp'
use_frameworks!
platform :ios, '10.0'
inhibit_all_warnings!
def my_pods
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
end
target 'MyApp' do
my_pods
end
target 'MyAppExtension' do
my_pods
end
What I tried:
1) set Require Only App-Extension-Safe API to NO (both for my app and the extension).
2) add this to my podfile:
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
if target.name == "Pods-MyAppExtension-FBSDKCoreKit"
target.build_configurations.each do |config|
//I tried both these lines
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'AF_APP_EXTENSIONS=1']
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
end
end
end
end
only as documentation if others arrive here:
using SPM and FB SDK 11.0 AND Xcode 12.x it works
using " " AND Xcode 13.beta for iOS13 fails:
'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.
PS
it's a shame using objC in 2021... :(
and ridiculous using "SWFT" Package manager containing objC, :(

How to specify specific source for a certain pod?

Although I believe this is harmless, warnings quite irk me. So I'm using a very specific version of TwilioChatClient together with TwilioClient. These two specific versions are what Twilio have been using in their sample projects.
Anyways, the warning when installing / updating pods:
[!] Found multiple specifications for TwilioChatClient (1.0.9):
- /Users/XXX/.cocoapods/repos/master/Specs/7/d/e/TwilioChatClient/1.0.9/TwilioChatClient.podspec.json
- /Users/XXX/.cocoapods/repos/twilio/TwilioChatClient/1.0.9/TwilioChatClient.podspec
[!] Found multiple specifications for TwilioChatClient (1.0.8):
- /Users/XXX/.cocoapods/repos/master/Specs/7/d/e/TwilioChatClient/1.0.8/TwilioChatClient.podspec.json
- /Users/XXX/.cocoapods/repos/twilio/TwilioChatClient/1.0.8/TwilioChatClient.podspec
[!] Found multiple specifications for TwilioChatClient (1.0.7):
- /Users/XXX/.cocoapods/repos/master/Specs/7/d/e/TwilioChatClient/1.0.7/TwilioChatClient.podspec.json
- /Users/XXX/.cocoapods/repos/twilio/TwilioChatClient/1.0.7/TwilioChatClient.podspec
[!] Found multiple specifications for TwilioChatClient (1.0.6):
- /Users/XXX/.cocoapods/repos/master/Specs/7/d/e/TwilioChatClient/1.0.6/TwilioChatClient.podspec.json
- /Users/XXX/.cocoapods/repos/twilio/TwilioChatClient/1.0.6/TwilioChatClient.podspec
[!] Found multiple specifications for TwilioChatClient (1.0.5):
- /Users/XXX/.cocoapods/repos/master/Specs/7/d/e/TwilioChatClient/1.0.5/TwilioChatClient.podspec.json
- /Users/XXX/.cocoapods/repos/twilio/TwilioChatClient/1.0.5/TwilioChatClient.podspec
[!] Found multiple specifications for TwilioChatClient (1.0.4):
- /Users/XXX/.cocoapods/repos/master/Specs/7/d/e/TwilioChatClient/1.0.4/TwilioChatClient.podspec.json
- /Users/XXX/.cocoapods/repos/twilio/TwilioChatClient/1.0.4/TwilioChatClient.podspec
My podfile:
project 'Proj/Proj.xcodeproj'
source 'https://github.com/CocoaPods/Specs'
source 'https://github.com/twilio/cocoapod-specs'
platform :ios, '10.0'
use_frameworks!
target 'Proj' do
pod 'TwilioClient', '~>1.2' # Twilio Call Framework
pod 'TwilioChatClient', '1.0.4' # Twilio Chat Framework
target 'MobileMedTests' do
inherit! :search_paths
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.0'
end
end
end
end
target 'ProjUITests' do
end
I think specifying two kinds of sources (which are both necessary) causes these warnings. Is there a way to put the specific source right beside the pod?
In fact, your problem comes from the fact that you have added the twilio repo to your pod source with this line :
source 'https://github.com/twilio/cocoapod-specs'
So when you type pod repo, you obtain something like :
master
- Type: git (master)
- URL: https://github.com/CocoaPods/Specs.git
- Path: /Users/cyrille/.cocoapods/repos/master
twilio
- Type: git (master)
- URL: https://github.com/twilio/cocoapod-specs
- Path: /Users/cyrille/.cocoapods/repos/twilio
And when you execute pod install, cocoa pods can find a version of this lib both in master's cocoapods repo and in twilio's one... which make the warning.
To remove this warning, remove this line from your Podfile :
source 'https://github.com/twilio/cocoapod-specs'
In a terminal execute the following commands :
pod repo remove twilio
and then :
pod update
You should get the following with no more warnings :
Analyzing dependencies
Removing TwilioClient
Downloading dependencies
Installing TwilioChatClient 2.2.0 (was 1.0.4)
Installing TwilioSDK (1.2.9)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.
just wanted to give a bit of background on the warnings you saw here. We use a separate cocoapods repository during beta testing (https://github.com/twilio/cocoapod-specs) but began publishing to the global cocoapods repository soon after GA when 1.x was released.
We did not stop publishing to our existing cocoapod-specs repository for the rest of the 1.x releases because it would have been a breaking change to existing customers using the beta source line who wished to upgrade if they did not also have the global cocoapods repository declared. This is what cocoapods is warning about, that the same pod with a same version is defined in two places. The podspecs are identical, so this will not cause issues when using any of the versions of the SDK for which this warning shows up.
As of 2.x, we have been publishing chat only to the global repository so that is why the warnings stop with the 1.x series of releases.
First, You need SDK also.I installed pod on my project now. It works fine. Look up this link
http://cocoapods.org/?q=Twilio
Pod Code
project 'Proj/Proj.xcodeproj'
source 'https://github.com/CocoaPods/Specs'
source 'https://github.com/twilio/cocoapod-specs'
platform :ios, '10.0'
use_frameworks!
target 'Proj' do
pod 'TwilioSDK', '1.2.9'
pod 'TwilioChatClient'
target 'MobileMedTests' do
inherit! :search_paths
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.0'
end
end
end
end
target 'ProjUITests' do
end
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, '10.0' # (or whatever version you want)
target 'Project Name' do
pod 'TwilioSDK', '1.2.9'
pod 'TwilioChatClient'
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
end
end
end

CocoaPods - Unable to find a specification for `GoogleMaps`

I'm new to iOS, i already have Alamofire and MarqueeLabel on my Podfile and now trying to add GoogleMaps, it keeps showing this message,
[!] Unable to find a specification for `GoogleMaps`
My Podfile looks like this
# Uncomment the next line to define a global platform for your project
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'Migapixel' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'GoogleMaps'
pod 'Alamofire',
:git => 'https://github.com/Alamofire/Alamofire.git',
:branch => 'master',
:tag => '4.0.0'
pod 'MarqueeLabel/Swift',
:git => 'https://github.com/cbpowell/MarqueeLabel.git'
# Pods for Migapixel
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'NO' end end end
target 'MigapixelTests' do
inherit! :search_paths
end
target 'MigapixelUITests' do
inherit! :search_paths
# Pods for testing
end
end
i even tried this
pod 'GoogleMaps',
:git => 'https://github.com/CocoaPods/Specs.git'
What am i doing wrong?
Try removing source 'https://github.com/CocoaPods/Specs.git' and moving use_frameworks! out of the target block. Moreover you don't need to manually set the git path for both Alamofire and MarqueeLabel.
Try this:
platform :ios, '9.0'
use_frameworks!
target 'Migapixel' do
pod 'GoogleMaps'
pod 'Alamofire'
pod 'MarqueeLabel/Swift'
# Pods for Migapixel
end
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'NO' end end end
target 'MigapixelTests' do
inherit! :search_paths
end
target 'MigapixelUITests' do
inherit! :search_paths
# Pods for testing
end
Edit:
It seems that there's something wrong with your local repo.
Try cleaning and reinstalling:
pod repo remove master
pod setup
i resolved the issue like that with these step:
open terminal.
go to your project path.
type:
pod repo update
install pod again.
After trying many things Here is the fix!!
Imp: Make sure that you have these lines in your PodFile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'YOUR_APPLICATION_TARGET_NAME_HERE' do
pod 'GoogleMaps'
end
If the above is fine then you need to update the pods:
try the following steps:
Open a new terminal and run the following command in a temp directory.
pod try GoogleMaps
keep patience! It will take some time but will update the pod.
Now try to install the pod in ur project again. It should work.Else try to run the following commands in the project dir:
pod repo update
try again.
Comment in the case of any issue!!
Go to your project directory and delete pods folder and .lock file then run
pod repo update
it helps for me.

Alamofire not working (Swift/Xcode 8)

I am getting the following errors when trying to import Alamofire into my project (Cocoapods isn't working for me, so I have to manually import it).
Anyway, I'm using XCode 8 and Swift 2.3, and I'm getting these errors:
Update: I cleaned XCode, downloaded the latest version of Alamofire and restarted my computer. Now, XCode seems to be giving me conflicting errors (pictures for reference)
Thanks!
As of early September '16, you need to use the following in your Podfile:
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => '3.5.0'
Pointing to the swift2.3 branch no longer works, as that branch has been deleted. The tag '3.5.0' points to the last revision on master that supports Swift 2.3.
Use Swift 2.3 in Xcode 8
Pod file
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target 'ProjectName' do
pod 'Alamofire'
pod 'Contentful'
pod 'ContentfulDeliveryAPI'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '2.3'
end
end
end
More information about Xcode 8 + Swift 2.3 support for Alamofire:
https://github.com/Alamofire/Alamofire/pull/1313
Try updating your pod to
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => '3.5.0' (Updated)
Update: This is a good guide to follow if you're interested in keeping Xcode7 compatibility, and still be able to target iOS10/swift 2.3 for development: http://radex.io/xcode7-xcode8/

Resources