Alamofire not working (Swift/Xcode 8) - ios

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/

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.

Using MapboxNavigation iOS with Xcode 10

Is there any possibility to use MapboxNavigation (version 0.21 or 0.22) iOS with Xcode 10. On its Github and CocoaPods site is stated, that it can only be used with Xcode 9, but a few issues on Github mention the (successful) use of Xcode 10 with MapboxNavigation.
However, I tried to install MapboxNavigation via CocoaPods using Xcode 10 and get a bunch of errors:
/Users/Paul_Obernolte/Library/Developer/Xcode/DerivedData/pq-app-v2-gynuaxsohvqddqegrvemywowchkr/Build/Products/Debug-iphonesimulator/MapboxDirections.swift/Swift Compatibility Header/MapboxDirections-Swift.h:171:9: error: 'MapboxDirections/MapboxDirections.h' file not found
#import <MapboxDirections/MapboxDirections.h>
^
<unknown>:0: error: could not build Objective-C module 'MapboxDirections'
Is there any workaround to avoid this errors using Xcode 10?
Edit: Here is my Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
EXPO_CPP_HEADER_DIR = 'ExpoKit'
target 'pq-app-v2' do
pod 'MapboxDirections.swift', '~> 0.23'
pod 'MapboxMobileEvents',
:git => 'https://github.com/mapbox/mapbox-events-ios.git',
:commit => "79d29f1df5a9187481f5c9ac8fa13430d1f04139"
pod 'MapboxNavigation', '~> 0.21.0'
... (more Pods)
end
I need to download MapboxMobileEvents separately because of this issue: https://github.com/mapbox/mapbox-events-ios/pull/85
target 'pq-app-v2' do
use_frameworks!
... (more Pods)
end
change code in pod file if "use_frameworks!" is commented than put it uncommented as above.

SpriteKit NSTimeInterval renamed

I'm trying to use SpriteKit in my project but after I install it and open the project I get 28 errors. I tried to rename the 'NSTimeInterval' to 'TimeInterval' but it didn't work. I'm using Xcode 9.3
This is my Podfile:
platform :ios, '9.0'
target 'Aaa' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Aaa
pod 'SpriteKit-Spring'
end
I get these errors (27 are the same - 'NSTimeInterval' has been renamed to 'TimeInterval'):
Error list screenshot
Solution:
In the Podfile have this line:
pod 'SpriteKit-Spring', :git => 'https://github.com/ataugeron/SpriteKit-Spring/'
SpriteKit-Spring hasn't been updated to Swift 4, at least not the released pod. See https://github.com/ataugeron/SpriteKit-Spring/issues/12 for a workaround.

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, :(

Reactive Cocoa for Swift 3.0

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

Resources