Nativescript Algolia iOS Build Fail - nativescript

I am trying to build nativescript-algolia but it fails on iOS. This is the error I am getting:
[!] Unable to determine Swift version for the following pods:
- `AlgoliaSearch-Client-Swift` does not specify a Swift version
and none of the targets (`appname`) 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.
I have tried everything I have seen from Googling this problem. I just can't seem to set the Swift Version correctly.

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.

Create a file named Podfile in App_Resources/iOS and add the following lines,
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

With the help from the plugin creator I was able to fix this by downgrading my Cocoapods version.
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.5.3
References:
https://github.com/arpit2438735/nativescript-algolia/issues/19#issuecomment-472847392
Swift Version NativeScript

Related

How to fix "Bus error 10" after update to Xcode 10.2

I updated Xcode to new stable 10.2v. I tried to build my project and it was successful. When I'm trying to archive the project (workspace), I'm getting errors like on screenshot below:
What I've tried so far:
Update cocoa pods to latest version -> COCOAPODS: 1.7.0.beta.3
Clean DeliveredData folder
Reinstall Xcode
Remove repository, clone it again and install pods
Totally remove all pods from project and add them back
Temporary Workaround
For me it was only the Cache framework. Until they have fixed it, you can manually set SWIFT_OPTIMIZATION_LEVEL to -Onone for the configuration you want to use for archiving.
CocoaPods
You could even use your Podfile if you don't want Cococapods to overwrite the settings every time you run pod install
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if target.name == 'Cache'
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone'
end
end
end
end
Note that this is specifically checking for the Cache framework. If you have problems with other frameworks you might want to change or extend this condition.
While Lukas' answer of disabling optimization on the Cache pod works, I followed Alex's link to the issue in their GitHub repo and found there is an open pull request with a pretty simple code change that fixes it. I unlocked the file and made the change locally.
Here's the PR: https://github.com/hyperoslo/Cache/pull/236
Apply this diff: https://github.com/hyperoslo/Cache/pull/236/commits/560f00a9a9549db161ca70d96eed74fc580b03e3#diff-9e53dc1370d4f7c9cdaaa103d26ff096
Which, to repeat here, is in the file MD5.swift change the safe_add function to be:
func safe_add(_ x: Int32, _ y: Int32) -> Int32 {
return x &+ y
}
(Disclaimer: I do not claim to know the correctness of the change, but it seems the delay merging the PR is due to figuring out who is currently maintaining the repo.)
The answer is here: https://github.com/hyperoslo/Cache/issues/238
We are waiting for the owners of this repo to make any sign of life...

IBDesignables, no suitable image found, required code signature missing

I recently made some changes to Assets.xcassets and this caused absolute chaos for XCode. I ended up with multiple errors of this kind: Failed to render and update auto layout status for *MyViewController* (6jf-cd-DYU) dlopen (AFramework.framework, 1): no suitable image found. Did find: Aframework.framwork: required code signature missing for 'Aframework.framework' in both .storyboard and .xib files.
Aframework is a placeholder for multiple Pod frameworks I have as dependencies. These worked fine before I modified xcassets.
I tried everything I could find related to this but I've gotten nowhere: Cleaned Derived Data, ran clean/build, removed all XCode cache folders, reinstalled XCode entirely, Refresh all views etc. It compiles and runs fine, everything works in the app (and no images or resources are missing), but all my Storyboards are blank (all white), which makes it pretty hard to work.
I also tried pod deintegrate, removed the xcworkspace-file and reinstalling pods (since the error points to a Pod framework). I also revoked and re-issued all my certificates through XCode since it points to code signing as a problem.
EDIT: I Completely reinstalled OSX and cloned the repo from Git from a working configuration. No change. This must be something other than the xcassets-theory, because even if I check out commits from weeks ago (where I know for sure this wasn't a problem) I still get the error. Maybe something was updated by Apple between now and the last time it worked. I've given up and moved on for now. I'll just click through the views in the explorer on the left side instead of inside the storyboard. Hopefully someone somewhere figures this out at some point.
This issue looks like Cocoapods bug and caused by CODE_SIGNING_ALLOWED and CODE_SIGNING_REQUIRED keys in settings of Pods.
Adding this code in the end of pod file will fix an issue (don't forget do then pod install):
# Workaround for Cocoapods v.1.5 issue #7606
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
end
It turns out this was related to cocoapods. 1.5 has issues with XCode 9.3 it seems. I downgraded to cocoapods 1.4 and the issue went away. Please see this thread on GitHub.
Edit: This issue has been fixed. The latest version of CocoaPods no longer suffers from this problem, so all you have to do is update.
Just adding a complete version of Igor's answer
Please don't downgrade cocoapods. Instead modify pod files as bellow.
#Replace 9.0 with your project ios version
platform :ios, '9.0'
target 'YourProject' do
frameworks
use_frameworks!
pod 'Alamofire', '~> 4.7'
pod 'AlamofireObjectMapper', '~> 5.0'
pod 'SDWebImage', '~> 4.0'
end
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
end

Xcode - #IBDesignables - Required code signing missing for X.framework

I know similar questions has been asked before but nothing seems to work for me.
Im using CocoaPods and installing framework "X". This can be anything that can be edited directly in the Storyboard. Two examples are "MBCircularProgressBar" and "UICircularProgressRing".
Im adding it to a UIView and getting this error instantly. It messes up my storbyboard but the app is running fine.
I'm using the newest version of Xcode, newest MAC OS.
What have i tried?
Deleted everything in DerivedData for Xcode
Clean, build, refresh views ++
Removing the problem pods and reinstalling/trying a different one
Disabled "Automatic code signing" in "General" and set it manually to my company
Error at the moment shows :
Main.storyboard: error: IB Designables: Failed to render and update auto layout status for Dashboard_UsageVC (mqT-RZ-029): dlopen(MBCircularProgressBar.framework, 1): no suitable image found. Did find:
MBCircularProgressBar.framework: required code signature missing for 'MBCircularProgressBar.framework'
UPDATE 23.04.2018 - Still not solved
Still having this problem. I have gone to the extreme and fully reset my MAC. Reinstalled everything. Same problem. Even when downgrading CocoaPods to 1.4.0 and Xcode to previous version. To avoid pulling all my hair out Im now finishing the rest of the app where nothing special is needed and hoping for a magic solution for this closer to app release.
It has been fixed with Cocoapods 1.5.2 (and probably 1.5.1 but I have upgrade directly from 1.5.0 to 1.5.2).
UPDATE
I may have spoken too fast.
The error re-appears after a few builds.
However, this workaround seems to work (applies to Cocoapods 1.5.x) until the bug fix is merged:
clean your project
close Xcode and delete DerivedData
open Podfile in your project , and add this:
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
end
then in command line do a:
pod update or pod install
Sources:
https://github.com/CocoaPods/CocoaPods/issues/7606#issuecomment-381279098
https://github.com/evgenyneu/Cosmos/issues/105
https://github.com/Skyscanner/SkyFloatingLabelTextField/issues/201#issuecomment-381915911
Same bug for me.
For me, it cames after installing the last version cocoapods 1.5.0. So I downgraded it to 1.4.0 and the bug disappear.
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.4.0
Hoped it will helped you too.
This works fine for me.When I downgrade cocoapods to 1.4.0,the problem disapper.
I am using DownloadButton.

CocoaPods 'pod lib create' not generating Podfile

I've previously (and successfully) been able to create a Pod before running:
"pod lib create os-nsthreading"
But since updated to 1.0.1 the script seems to fail in creating Podfile, thus not creating the required .workspace file:
What language do you want to use?? [ Swift / ObjC ]> ObjC
Would you like to include a demo application with your library? [ Yes / No ]
> Yes
Which testing frameworks will you use? [ Specta / Kiwi / None ]
> None
Would you like to do view based testing? [ Yes / No ]
> No
What is your class prefix?
> OS
Running pod install on your new library.
[!] No `Podfile' found in the project directory.
I've attempted to update CocoaPods again - but still to no avail - my first thought was permissions, but it seems to create the project files okay...
Any point in the right direction would be much appreciated.
Workaround, (it does appear to create the Podfile infact) just re-run the 'pod install' and it completes the job....
Authors suggest to use last available build of cocoapods prerelease version if you are using Xcode 8 and Swift 3 project. Currently it's a 1.1.0.rc.2 version.
For downloading prerelease version run gem install cocoapods --pre in terminal.
Hope it helps!
Artem

How to install ConvenienceKit Framework via Podfile Swift

I've tried multiple methods and Xcode versions to install this method and use it but every time when i use import ConvenienceKit it always fails by saying "No such module ConvenienceKit"
https://github.com/MakeSchool/ConvenienceKit
it can be installed by using use_frameworks! in the Podfile and pod 'ConvenienceKit'. Everything installs fine, just doesn't work.
What am i missing ?
To use pods use have to work in a 'workspace' with the the pod that you are using. If you are using a workspace and it is sill not working you can try the following:
Check to see if there is a update for CocoaPods
Check to see if there is a update for Xcode
Uninstall Xcode and re install it.
Hope this works.

Resources