error: no such module 'RealmSwift'
import RealmSwift
While building a project from Xcode, it's working fine. Building it from Jenkins,gives me the above mentioned error.
** BUILD FAILED **
The following build commands failed:
CompileSwift normal arm64
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)
Build step 'Xcode' marked build as failure
Finished: FAILURE
My Pod file looks like below
target 'MyProject' do
use_frameworks!
# Pods for MyProject
pod 'Google/Analytics'
pod 'GoogleTagManager','~> 3.15.0'
pod 'RealmSwift','~> 2.1'
target 'MyProjectTests' do
# Pods for testing
end
target 'MyProjectUITests' do
# Pods for testing
end
end
You may not have versioned your Pods directory.
You can either remove Pods from your .gitignore, or add a pod install command inside each jenkins script.
Related
I tried doing a clean build, uninstalling/reinstalling pods, not too sure where to go to next.
I never received this error before, but I first got it when I tried integrating Firebase into my project. I made sure to add all of the correct pods, I then went ahead and added a few other Firebase pods, just in case. I'm not sure if it has anything to do with this, but here is what my pods file looks like.
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'Effortflex' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
use_modular_headers!
# Pods for Effortflex
pod 'RealmSwift'
pod 'IQKeyboardManagerSwift'
pod 'Firebase'
pod 'Firebase/Analytics'
pod 'Firebase/Auth'
pod 'Firebase/Core'
pod 'Firebase/Firestore'
pod 'FirebaseFirestoreSwift'
end
Here is a sample of the error...
/Users/owner1/Library/Developer/Xcode/DerivedData/Effortflex-bmtqbbukvlosxpbraqoiwplpcfyj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/nanopb.build/Objects-normal/x86_64/pb_encode.o
duplicate symbol '_pb_encode_fixed32' in:
/Users/owner1/Library/Developer/Xcode/DerivedData/Effortflex-bmtqbbukvlosxpbraqoiwplpcfyj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/nanopb.build/Objects-normal/x86_64/pb_encode 2.o
/Users/owner1/Library/Developer/Xcode/DerivedData/Effortflex-bmtqbbukvlosxpbraqoiwplpcfyj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/nanopb.build/Objects-normal/x86_64/pb_encode.o
ld: 34 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any help would be greatly apprecaited!
Something that helped me was to the following -
In terminal navigate to your project folder
Run 'pod deintegrate'
Run 'pod install'
After that my project was able to compile. Hope that works for you!
I have a pod project, containing an example that demonstrates the usage of the pod. The bitcode enabled setting is set to yes, both on the example and Pod targets. The following is the Podfile of the example:
use_frameworks!
platform :ios, '10.0'
target 'MyPod_Example' do
pod 'MyPod', :path => '../'
target 'MyPod_Tests' do
inherit! :search_paths
end
end
The example app runs well on the Simulator, but while trying to run it on an iPhone 6S, I get the following build error:
ld: -bundle and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
clang: error: linker command failed with exit code 1 (use -v to see invocation).
How do I fix this?
Another project that I have that has the same pod, but downloads the pod from its repo works fine on iPhone, with bitcode enabled. The following shows the Podfile structure of the app that works:
source '<my pod spec repo>'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
target 'MyPodTest' do
use_frameworks!
# Pods for MyPodTest
pod 'MyPod'
target 'MyPodTestTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyPodTestUITests' do
inherit! :search_paths
# Pods for testing
end
end
The -bitcode_bundle flag being passed to ld is described in the error message ("Xcode setting ENABLE_BITCODE=YES"), but the -bundle flag is not, which can make this confusing and hard to debug.
If you look at the lines preceding this error, you will likely see two important ones:
WriteAuxiliaryFile /Users/YOURUSER/Library/Developer/Xcode/DerivedData/YOURPROJECT-xxxxx/Build/Intermediates.noindex/YOURPROJECT.build/Release-SDK/TARGET.build/DerivedSources/TARGET_vers.c (in target 'TARGET' from project 'YOURPROJECT')
CompileC /Users/YOURUSER/Library/Developer/Xcode/DerivedData/YOURPROJECT-xxxxx/Build/Intermediates.noindex/YOURPROJECT.build/Release-SD/TARGET.build/Objects-normal/arm64/TARGET_vers.o /Users/YOURUSER/Library/Developer/Xcode/DerivedData/YOURPROJECT-xxxxx/Build/Intermediates.noindex/YOURPROJECT.build/Release-SDK/TARGET.build/DerivedSources/TARGET_vers.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'TARGET' from project 'YOURPROJECT')
These two lines are the real meat of your problem. Your bundle, which formerly had no binary files in it (only PNGs, XIBs, and other resources), now has a binary file. One that was created by Xcode. Because this binary was created as part of a resource bundle target, it's compiled as a CFBundleExecutable using the -bundle flag, which is incompatible with ENABLE_BITCODE. Instead of disabling bitcode, though, you should prevent this binary from being generated in the first place.
This binary is being created by Apple Generic Versioning. To get rid of it, go to your build settings tab (on your resource bundle target), click the "all" button to see all settings, then search for "versioning system". Change this from "Apple Generic" to "None". Resource bundles do not properly support versioning.
This is what I see when trying to run tests under test target in my iOS App:
ld: framework not found AFNetworking for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is how my podfile looks like:
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, "8.2"
def pods
pod 'AFNetworking'
pod 'Fabric'
pod 'Crashlytics'
pod 'MagicalRecord'
pod 'SDWebImage'
pod 'SVProgressHUD'
end
target 'MySoberRoomMate' do
pods
end
inhibit_all_warnings!
I am new on IOS development and did not have the required reputation to add comment so that I am posting answer.
I did a little work with pod file and i think the pods for the test target is not added in pod file so that the compiler showing the error.
do some thing like this in the pod file for the test target
target 'TestTarget' do
pods
end
add your test target name in place of 'TestTarget'
Hope it works.
I have added Braintree with other lib using pods. My build is failed because it can't find library for Braintree. Here's what I have:
ld: library not found for -lBraintree
clang error: linker command failed with exit code 1 (use -v to see
invocation)
Things I've tried:
Used .xcworkspace instead of .xcodeproj
Set build active architecture NO
Removed any red lib.a
This is what my project looks like:
I don't see a -lBraintree flag in the last picture yet it shows here -ObjC -ObjC -l"AdIdAccessLibrary" -l"Braintree" -l"DI... why?
Podfile
target 'MyProject' do
pod 'Braintree', '3.9.3'
pod 'Google/Analytics', '~> 1.0.0'
pod 'GoogleIDFASupport'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.1'
pod 'GoogleMaps'
end
target 'MyProjectTests' do
end
I get linking error when trying to compile iOS project from terminal with Xcode 7.1.1:
xcodebuild -project MyProject.xcodeproj -configuration Debug -target MyProject build
As result I receive next error:
ld: framework not found AFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is my pod file:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target "MyProject" do
pod "AFNetworking", "~> 2.0"
pod 'GoogleMaps'
pod 'MONActivityIndicatorView'
pod 'NYXImagesKit'
pod 'MagicalRecord'
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
pod 'Countly'
end
xcodeproj 'MyProject'
I also tried adding link_with but get the same error. How to fix the problem above?
You need to build using the workspace generated by CocoaPods:
xcodebuild -workspace MyProject.xcworkspace -configuration Debug -scheme MyProject build
If you build just the project, xcodebuild does not see the dependency on the Pods project. Note that you have to use a scheme when building a workspace rather than a target. This means if you are building on a build server you will need to mark your scheme as shared in the scheme editor.