Swift Version NativeScript - ios

Using NativeScript how can I run a project under iOS? I get these messages when I run tns run iOS --bundle
Webpack compilation complete. Watching for file changes.
Webpack build done!
Copying template files...
Platform ios successfully added. v4.2.0
Executing before-shouldPrepare hook from /Users/Zian/Documents/Projects/NativeScript/Hybrid/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Preparing project...
Executing before-prepareJSApp hook from /Users/Zian/Documents/Projects/NativeScript/Hybrid/hooks/before-prepareJSApp/nativescript-dev-webpack.js
Installing pods...
Analyzing dependencies
Downloading dependencies
Installing Socket.IO-Client-Swift (11.1.3)
Installing StarscreamSocketIO (8.0.7)
Installing Toaster (2.0.4)
[!] Unable to determine Swift version for the following pods:
- `Socket.IO-Client-Swift` does not specify a Swift version and none of the targets (`Hybrid`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
- `StarscreamSocketIO` does not specify a Swift version and none of the targets (`Hybrid`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
- `Toaster` does not specify a Swift version and none of the targets (`Hybrid`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
Unable to apply changes on device: 21FFE2BB-EB0D-48E3-A7AD-28CA08DD21E5. Error is: Command pod failed with exit code 1 Error output:
[!] Automatically assigning platform `ios` with version `8.0` on target `Hybrid` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
Can someone help me out?

Just had these same errors and found out downgrading from cocoapods 1.6.0 to 1.5.3 fixed it for me.
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.5.3

The problem here seems to be Toaster (2.0.4), which appears to have been developed for Swift 3.
I did this in order to resolve the issue:
go to the main folder for the nativescript project
In your bash shell, do:
% export SWIFT_VERSION=3
Then do your usual:
% tns build ios --bundle
Then open the project in Xcode:
% cd platforms/ios
% Open *.workspace
You'll get a warning about a build error in the pods project and may need to set your development team, but it should work.

The problem is with Cocoapods 1.6.x which have different behavior when it comes up to SWIFT_VERSION. Previously it was possible to set the SWIFT_VERSION in post_install hook of the Podfile, but now the pod install command fails before even getting to post_install.
The best solution is to use Cocoapod which already has SWIFT_VERSION set, i.e. in case you face the error, try to contact the Pod author.
Meanwhile, as a workaround, you can add a pre_install script in your <path to App_Resources/iOS/Podfile file with the following content:
pre_install do |installer|
installer.analysis_result.specifications.each do |s|
if s.name == 'Socket.IO-Client-Swift' || s.name == 'Starscream' || s.name == 'StarscreamSocketIO' || s.name == 'Toaster'
s.swift_version = '4.2'
end
end
end
For each of the Pods you can set different Swift version based on their requirements.

I have it fixed with #K Brown's answer.
Was having these errors when running tns run ios --bundle
for Socket.IO-Client-Swift, StarscreamSocketIO and Toaster when both v1.6.0 and v1.5.3 of Cocoapods installed:
- `<package name>` does not specify a Swift version and none of the targets
(`<project name>`) integrating it have the `SWIFT_VERSION` attribute set.
Please contact the author or set the `SWIFT_VERSION` attribute in at least one
of the targets that integrate this pod.
Below are the commands used:
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.5.3
rm -Rf platforms
tns install
tns run ios --bundle

Here is the real fix ! You can't stick with Cocoapods 1.5.3 forever...
Downgrading to 1.5.3 isn't a proper workaround and will not be sustainable in the future. In fact, this error is due to a new behavior introduced in Cocoapods 1.6.0 version, which force developers to set a Swift version to their projects. The goal is in fact to make library developers specify a Swift version in their podspec, so that library users don't have to do this manually (thanks to post_install scripts for example). You can see my discussion about this with a Cocoapods maintainer here. I do agree that this behavior is a bit misleading, as we try to set the Swift version in post_install script but an error is returned before…
In fact, as I have been told by the maintainer, the correct fix to this issue is to set a Swift version at project level (and therefore not at Pod level). To do this, just add a new User Defined Setting in Build Settings, with key SWIFT_VERSION and value 4.0 (for example, as whatever value should work here if you also set the version at Pod level with post_install script).
Long story short, the fix is to add this key/value :
Note that as you're using NativeScript, you may want to set the Swift version by running command export SWIFT_VERSION=4 in your project folder, before building.

Related

Cocoapods could not find comatible versions for pod "Capacitor"

I have update the Xcode to latest version 12.5 and after that I was getting below error for capacitor
switch must be exhaustive xcode
Then to resolve this error I ran the below command and it got resolved
npm install #capacitor/ios#latest
Then I was trying to sync the ios project it has started to give the following error now
Cocoapods could not find compatible versions for pod "Capacitor": In
Podfile: capacitor (from '.../../node_modules/capacitor/ios) Specs
satisfying the 'Capacitor (from '.../../node_modules/#capacitor/ios')'
dependency were found, but they required a higher minimum deployment
target
to solve this error I have tried below commands on root level and ios/App folder level also
pod install --repo-update
But this doesn't seems to resolve the error.
The app is build using ionic framework

CocoaPods could not find compatible versions for pod "CordovaPlugins"

I've run into an issue with my Ionic app, noticing since Capacitor was being updated. I do have Cordova plugins installed and have followed the instructions as per the Ionic documentation when installing these into the app.
I have tried removing and updating Cocoapods, Pod install etc and nothing seems to solve this problem.
The error shows as follows:
[!] CocoaPods could not find compatible versions for pod "CordovaPlugins":
In Podfile:
CordovaPlugins (from ../capacitor-cordova-ios-plugins)
Specs satisfying the CordovaPlugins (from ../capacitor-cordova-ios-plugins) dependency were found, but they required a higher minimum deployment target.
Any ideas on how to fix this?
Thanks in advance!

iOS carthage with MQTT framework

I have a application which is written in objective c and using pods to set dependency and target iOS version is 7.0. Due to some license conflict i want to use MQTT with dynamic linking with help of Carthage. So I followed following steps
Remove pod 'MQTTClient' from pod file and run the pod update.
It removed MQTTClient and keep others pods intact like afnetworking etc.
then I create Cartfile in project directory.
Add Github "ckrey/MQTT-Client-Framework" in Cartfile.
Run command carthage bootstrap --no-build --platform "iOS"
then run carthage build --no-skip-current --platform "iOS" gives always error Skipped building project due to the error:
Dependency "project" has no shared framework schemes for any
of the platforms: iOS
I have following question
Q1 As I understand, we can use both Carthage and cocoapod in same project.
Q2 how to resolve error mention in step6.
You can use Cocoapods and Carthage in the same project.
On step #6 make sure you are specifying the download as a 'binary'

GoogleMaps SDK 1.10.21020.0 Update iOS

Just trying to update my GoogleMaps SDK version for an iOS application. I'm running Xcode 7.1 and following the directions at https://developers.google.com/maps/documentation/ios-sdk/start. Unfortunately I cannot seem to run the following:
pod install
in the terminal. I have tried to add the '$(inherited)' flag into my project, deleting and recreating my Podfile, updating pod, etc. but nothing seems to let me update the SDK. Below is the code the terminal spits out after I run the pod install command:
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Using GoogleMaps (1.10.1)
Generating Pods project
Integrating client project
Sending stats
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total
pod installed.
[!] CocoaPods was not able to update the `master` repo. If this is an unexpected issue and persists you can inspect it running `pod repo update --verbose`
[!] The `projectName [Debug]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `projectName [Release]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
You have not updated the gems. Try sudo gem install cocoapods
then clean the project cmd + shift + k. Then in your Framework Search Path (in build settings) use $inherited. then install a podfile and mention all the dependencies you need. This procedure might help you

Cannot compile Cocoapods with XCode/Obj-C – "Pods-prefix.pch.dia: No such file or directory"

I am using XCode 4.5.1 and iOS 6.0 base SDK.
Here is the error I am receiving:
i686-apple-darwin11-llvm-gcc-4.2: /Users/fahim/Library/Developer/Xcode/DerivedData/Currenthiphop-emodxxwwaiojlcboaxuodksuwuww/Build/Intermediates/PrecompiledHeaders/Pods-prefix-evibdktwbatdnbabmrlnderfsxxi/Pods-prefix.pch.dia: No such file or directory
There is only 1 file in the Pods-prefix-xxx directory:
Pods-prefix.pch.pth.hash-criteria
Here is my Podfile:
platform :ios
pod 'LibComponentLogging-Core'
pod 'LibComponentLogging-LogFile'
pod 'LibComponentLogging-qlog'
pod 'LibComponentLogging-pods'
pod 'Facebook-iOS-SDK'
pod 'RestKit'
Any help is appreciated. Thank you!
I actually found this solution right here that details opening up Xcode using normal means (Finder or the Dock), as opposed to using the open <Workspace>.xcworkspace command. I've always used Xcode from my dock, whereas the other developer (who couldn't build the project and was getting the error you were) was using the open command from the command line. Once he opened Xcode from the Dock, and manually browsed to open the project that way, he could build it successfully.
If you are using CocoaPods 0.18.0, this might be cause by CocoaPods and is fixed in https://github.com/CocoaPods/CocoaPods/issues/956
Extra quote in "$(inherited)" was the cause (https://github.com/CocoaPods/CocoaPods/blob/master/lib/cocoapods/generator/xcconfig.rb#L150). It should not be quoted. If you remove them from the xcconfig the project will build again. You may want to check your xcconfig and see if there are extra quote.
This issue can be caused by a few different factors but in my case and the case of some colleagues, this resolved the missing pch.dia
Uninstall CocoaPods and install 0.17.1
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 0.17.1 --verbose
Lock your Kiwi version to 2.05 if Kiwi is one of your pods:
target :KiwiUnitTest, :exclusive => true do
pod 'Kiwi', '2.0.5'
Clean your Xcode project including Derived Data. Close down Xcode, re-open the project and build.

Resources