We have created a test suite swift code which we wanted to reuse in different projects.
Our plan was as follows:
We create a pod where we put different helpers and base classes, so then this pod is used in different projects. We got no problem to get it up and running on iOS simulator but faced an issue on physical device. In order to keep it simple here's small list of steps to reproduce the issue. We take an example of existing pod of https://github.com/joemasilotti/JAMTestHelper as we got exactly same error here.
I create sample application with UI tests
Run Cmd + U got success
Add Podfile with the following content:
target 'TestProjectUITests', :exclusive => true do
platform :ios, '9.0'
use_frameworks!
pod "JAMTestHelper"
end
Run pod install (I use 0.39.0 version)
Run Cmd + U got error: XCTest' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
After google search figured the solution is setting enable bit code to NO: http://take.ms/TzN8I
Run Cmd + U got green build but tests always fail.
Full log is as follows:
2016-06-13 22:10:06.682 XCTRunner[20405:6816312] Running tests...
2016-06-13 22:10:06.749 XCTRunner[20405:6816312] The bundle “TestProjectUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2016-06-13 22:10:06.749 XCTRunner[20405:6816312] (dlopen_preflight(/var/containers/Bundle/Application/6BE65B3E-8962-40CB-A6E7-D9F1ADE1D743/TestProjectUITests-Runner.app/PlugIns/TestProjectUITests.xctest/TestProjectUITests): Library not loaded: #rpath/JAMTestHelper.framework/JAMTestHelper
Referenced from: /var/containers/Bundle/Application/6BE65B3E-8962-40CB-A6E7-D9F1ADE1D743/TestProjectUITests-Runner.app/PlugIns/TestProjectUITests.xctest/TestProjectUITests
Reason: image not found)
Which Xcode version you are using ? JAMTestHelper Requires Xcode 7.2 minimum
Related
I’m having a problem with NearbyMessages in Xcode 11.2. When I add pod 'NearbyMessages' and then do pod install, when I open the xcworkspace, I get a “duplicate output file” error resulting from the Assets.car that is generated by “[CP] Copy Pods Resources” build phase:
warning: duplicate output file '/Users/.../DerivedData/NearbyDemo-elvzmjtrsxnstlemqnzociqoajhv/Build/Products/Debug-iphonesimulator/NearbyDemo.app/Assets.car' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/.../DerivedData/NearbyDemo-elvzmjtrsxnstlemqnzociqoajhv/Build/Intermediates.noindex/NearbyDemo.build/Debug-iphonesimulator/NearbyDemo.build/Script-EB8FCF95DAAD8AF429AAA51F.sh (in target 'NearbyDemo' from project 'NearbyDemo’)
I’ve searched and found old issues, e.g., Google Nearby Messages API Broke App Icon, that seem like they might be related. That post looks like it might be an earlier manifestation of the same problem with assets and NearbyMessages, but it looks like the old compiler may not have caught this error.
In Xcode 10.3, this is merely a warning:
ignoring duplicated output file: '/Users/.../DerivedData/NearbyDemo-elvzmjtrsxnstlemqnzociqoajhv/Build/Products/Debug-iphonesimulator/NearbyDemo.app/Assets.car' in shell script build phase '[CP] Copy Pods Resources'. This warning represents an extremely serious project misconfiguration and will likely cause some shell scripts in your project to be skipped entirely, leading to other build failures or missing files in the build directory. This will be a hard error in the future. (in target 'NearbyDemo’)
Does anyone know of anyway to resolve this? I can downgrade Xcode, probably letting this problem pass without a hard error, but that’s not a terribly appealing solution.
It probably isn’t relevant, but here’s my Podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'NearbyDemo' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for NearbyDemo
pod 'NearbyMessages'
end
I’m using Cocoapods 1.8.4 and Xcode 11.2 (11B52) on macOS 10.15.1.
I’ve posted a “Nearby Messages API for iOS - Product feedback” report, but was wondering if anyone has found a workaround in the interim.
After some searching, I found a workaround that should help with this behavior. You can achieve this by changing Xcode settings to use the old build system.
Xcode / File / Workspace Settings / Build system / select "Legacy
Build System"
If you need further information, check out this link
- https://github.com/CocoaPods/CocoaPods/issues/8122
I'm using Cocoapods with my Xcode project, but it seems to be causing both "library not found" and header "file not found" errors when building with the Simulator but not when I have a device connected nor when using "Generic iOS Device".
My Podfile is simple. I have only one pod in there, for Microsoft's ADAL SDK, needed for single sign-on. When I use use_frameworks! in the Podfile I get:
fatal error: 'ADAL/ADAL.h' file not found
for the line
#import <ADAL/ADAL.h>
but if I use use_modular_headers! instead of use_frameworks! I get:
ld: warning: directory not found for option '-L/Users/memyself/Documents/iOS_Projects/ASSIST-main/ASSIST-main/DerivedData/MyApp/Build/Products/Debug-iphonesimulator/ADAL'
ld: library not found for -lADAL
Even if I disable both of those it builds fine for the device and for "Generic iOS Device", but fails with 'ADAL/ADAL.h' file not found error.
Yes, there are plenty of SO questions and answers for those kinds of errors (such as here) but no success trying them. To be specific, I'm using $(inherited) in the recommended search paths, setting enable bitcode to NO, making sure I'm opening the xcworkspace not the xcodeproj file, and have tried
$ pod deintegrate
$ pod clean
$ rm Podfile
Also, my app uses AWS and Firebase and I was getting the same problem with them, but was able to fix them by manually adding the necessary frameworks. However, I don't have a framework for ADAL, and frankly I need to fix this so I can use Cocoapods to install and manage my AWS and Firebase dependencies. It is very suspicious that it only fails when building for the Simulator, what project settings could cause this?
Update the deployment target and the Podfile 'platform' target. Update both from 9.0 to 11.0. Change this line in your Podfile
platform :ios, '11.0'
and this in both your Target and Project:
Try changing build active architecture only in build settings.
This appears to be an issue with CocoaPods, asking here first as per the guidelines.
Using Xcode 7.3.1, CocoaPods 1.0.1, 1.0.0-beta6 and 1.1.0-beta1
Create a new pod project using pod lib create SwiftTest
Language? Swift
Demo? Yes
Test frameworks? None
View based testing? No
Add a single class function to the auto-generated ReplaceMe.swift file to test the projects integration.
Calling the function from the example project works as expected.
Calling the function from the test project fails with the following error:
The bundle “SwiftTest_Tests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
(dlopen_preflight(/...): Library not loaded: #rpath/SwiftTest.framework/SwiftTest ... Reason: image not found)
Program ended with exit code: 82
Example project: https://github.com/NextFaze/SwiftTest
Issue can be fixed by changing the Podfile to:
use_frameworks!
def standard_pods
pod 'SwiftTest', :path => '../'
end
target 'SwiftTest_Example' do
standard_pods
end
target 'SwiftTest_Tests' do
standard_pods
end
I was developing a CocoaPod and had to change its name in Xcode 8 (rumours say, that there is going to be a better renaming refactor functionality in Xcode 9).
(This caused so many troubles BTW!!)
After I fixed all the renaming issues, I wanted my tests to run as well, but that error occurred. All I had to do is to set up the Host Application:
In Targets > Select the test target > General > you will find the Host Application under Testing. Mine was empty/grayed-out due to this renaming issue. I selected my host application and that's it!
In my case the test target didn't include .framework
It started to work, after following this step:
Select test target > Build Phases > Add the missing framework to both Link Binary With Libraries and Copy Frameworks
I realize that the same error was asked in other questions (like here), but their solutions are not working for me.
I keep getting a build failure in my app: "No such module 'Alamofire'". I followed the cocoadocs installation instructions (here) for installing Alamofire and it still is not working. I made sure everything has the same deployment target.
Embedded Binaries and Frameworks
Here's my podfile text.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, ‘9.2’
use_frameworks!
target 'MyApp' do
pod 'Alamofire', '~> 3.0'
end
target 'MyAppTests' do
end
target 'MyAppUITests' do
end
Also, I tried "$ pod install" again in Terminal and got this message:
[!] The `App [Debug]` target overrides the `EMBEDDED_CONTENT_CONTAINS_SWIFT` build setting defined in `Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
After following Sohil's suggestions, XCode now recognizes the Alamofire module, but 22 new issues have arisen.
Update #2: So I'm now on Xcode 7.3 and Swift 2.2, but I'm receiving a new error with the workspace Link: "ld: framework not found Alamofire. clang: error: linker command failed with exit code 1 (use -v to see invocation)."
Do the following things and you can import any swift file from "Pods"
1) Clean your project
2) Make sure that all your "Pods" > "Build Settings" > "Build Active
Architecture Only" is set to "NO".
3) Don't run, just build your project.
4) Now, import any file from "Pods" to any swift file
E.g.: import Alamofire
5) Again, build project and it will work as expected. Finally, you can
access it properties
Update:
For the updated question, I hope you are using Xcode 7.3 so please update the Alamofire to Swift 2.2
Hope this helps!
Please check this screenshot
and compare to your build setting
may this is helpful to you
For me the solution was to open the "App".xcworkspace as pointed by the cocoapods documentation
The steps was:
Close project
Close xcode
Go to terminal
type "open |App|.xcworkspace"
When I opened Xcode it was still pointing the error then I built the project (cmd+b) and everything is fine now.
The target overrides the OTHER_LDFLAGS build setting.
Use the $(inherited) flag in TARGENTS -> Build Settings -> Framework Search Paths
in my case, i couldn't run archive after change bundle name. I've cleaned build folder and run pod install then everything worked fine.
Xcode version: 7.0.1.
OS-X: Version 10.11 Release.
Project details: Built for iOS 7 or above, CocoaPods: AWSCore (Problematic one, other Pods build fine), other developers are on Xcode 7.0.1 as well but not on El Capitan.
When I try to build, I get "linker command failed with exit code 1 (use -v to see invocation)", along with a few warnings linked to the error.
Warning 1: "ld: warning: directory not found for option '-L/Users/sonny/{PROJECT_NAME}/build/Debug-iphoneos'"
Warning 2: "ld: warning: directory not found for option '-F/Users/sonny/{PROJECT_NAME}/Pods/HockeySDK/Vendor'"
Warning 3: "ld: library not found for -lAWSCore"
Solutions
I've tried: I've tried a complete pod remove master repo, pod setup, pod install. I've tried verifying that the architecture settings are the same for build on both my project target and pods target. I've tried deleting entries on Testing->Debug && Release in Build Settings along with putting $(inherited) in all the linker files and framework search entries.
Other issues that might be related: In the Project Navigator, all of my Frameworks Podfiles are red, indicating an incorrect folder reference. But wouldn't pod install correct this? I simply can't find the pods.a files anywhere in my project folder but I do not know if this is what's causing the build to fail.
Project builds for all other developers but not me or my supervisor. I'm on El Capitan but he isn't.
Solved:
This was my solution and keep in mind, the solution for everyone will be different -
In {Project Name} target, under your specific "General" if you scroll down you'll have a list of Frameworks. You want to delete ALL the Pod listings there "libPods-this or that.a". Those frameworks have been linked in a bash script and in other places during a Pod install, but Pod install didn't delete them from the project build listing.
Once you remove all those, it should build.