xctool tests fail when xcodebuild works - Travis CI - xcodebuild

I'm trying to integrate my project into Travis CI, and my builds have failed with the following errors:
Undefined symbols for architecture i386 and Undefined symbols for architecture x86_64
I get these errors for basically every class in my project that hasn't been added to the test target under Target Membership. I could probably solve this by adding every single .m file as a member of the test target, but that doesn't really make much sense, and my
I've tried to replicate this issue locally by running both of the following commands:
xcodebuild -workspace myWorkspace.xcworkspace -scheme MyProjectTests -sdk iphonesimulator build test
xctool -workspace myWorkspace.xcworkspace -scheme MyProjectTests -sdk iphonesimulator build test
Using xcodebuild, it works, runs, and the tests pass. Using xctool the tests fail with the same errors that Travis is using, as Travis uses xctool.
Does anyone have any ideas if there's a best fix for this issue? I assume I missed something somewhere, but I followed the standard Travis 'Getting Started' walkthrough.

After fussing with this a bunch with no luck, it appears as though I'm able to set a custom script for Travis to use instead.. As mentioned, the xcodebuild worked, so I added the following to my travis.yml file and everything was all good:
script:
- xcodebuild -workspace myWorkspace.xcworkspace -scheme MyProjectTests -sdk iphonesimulator build test

Related

React Native 'yarn run ios' doesn't initialize the project on M1

I'm a new user to Mac OS and its system and M1. Whenever I try yarn run ios command it's open normal simulator but not the project that I'm building and it throws me that error and error code 65:
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening dealerApp.xcodeproj.
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project dealerApp.xcodeproj -configuration Debug -scheme dealerApp -destination id=0A358C3D-FE10-4872-9913-F927BCC93B29
User defaults from command line:
IDEPackageSupportUseBuiltinSCM = YES
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Analyzing workspace
note: Using build description from disk
note: Build preparation complete
PhaseScriptExecution Start\ Packager /Users/bigez/Library/Developer/Xcode/DerivedData/dealerApp-cixnurkshkczahhihjqgcgbblssu/Build/Intermediates.noindex/dealerApp.build/Debug-iphonesimulator/dealerApp.build/Script-FD10A7F022414F080027D42C.sh (in target 'dealerApp' from project 'dealerApp')
I usually run yarn ios.
Also, you might try running the project with Xcode. It should give you a more useful error log so you can find out what the real problem is. Look for the red X icons and see what they say.

Detox build with react-native is failing because of GoogleUserMessagingPlatform?

I cannot get a once-working React-Native Detox build to work. The error seems to start with this:
PhaseScriptExecution [CP]\ Copy\ XCFrameworks /my-project/ios/build/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/GoogleUserMessagingPlatform.build/Script-75B045B5FA23A64D503F12601136A594.sh (in target 'GoogleUserMessagingPlatform' from project 'Pods')
cd /my-project/ios/Pods
/bin/sh -c /my-project/ios/build/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/GoogleUserMessagingPlatform.build/Script-75B045B5FA23A64D503F12601136A594.sh
warning: [CP] Unable to find matching .xcframework slice in '/my-project/ios/Pods/GoogleUserMessagingPlatform/Frameworks/Release/UserMessagingPlatform.xcframework UserMessagingPlatform framework ios-armv7_arm64_arm64e ios-i386_x86_64-simulator' for the current build architectures (arm64 x86_64).
And then towards the end fails with:
ld: warning: directory not found for option '-F/my-project/ios/build/Build/Products/Release-iphonesimulator/XCFrameworkIntermediates/UserMessagingPlatform'
ld: framework not found UserMessagingPlatform
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm on latest of most things - 0.63.3 of RN, CocoaPods 1.10.0, XCode 12.1.
For me, modifying the .detoxrc.json build command to include
EXCLUDED_ARCHS=arm64
ala
"build": "xcodebuild -workspace ios/MyProject.xcworkspace -scheme MyProject -configuration Release -sdk iphonesimulator -derivedDataPath ios/build EXCLUDED_ARCHS=arm64 DETOX=1",

CocoaPods integration with CommandLineTool and Dylib targets

For test purposes, I created a new project in Xcode as a Command Line tool (Test), added a dylib target called Networking.
Ran the following commands
pod init
In the pod file, under the Networking Target, Removed use_frameworks!
added
pod 'AFNetworking', '~> 2.0'
pod install
After Installation, In BuildPhases of Test CLI, I added Networking dylib. Created a simple method to call AFHTTPRequestOperationManager to test out. Called this method from TestCLI by Importing Networking.h
From Xcode it builds just fine, even archive works just fine from Xcode but when I try to archive from the following command line
xcodebuild -scheme Test -configuration Production archive -archivePath Test.xcarchive
I get the following error
ld: library not found for -lAFNetworking
The following build commands failed: Ld
/Users/user/Library/Developer/Xcode/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Test/InstallationBuildProductsLocation/usr/local/lib/libNetwork.dylib
normal x86_64 (1 failure)
Any ideas why ?
Try making your build command:
xcodebuild -workspace Test.xcworkspace -scheme Test -configuration Production archive -archivePath Test.xcarchive
I think if you don't specify the workspace setting, xcodebuild would be trying to use your project, which would not contain any Pods or the paths needed for linking.

Alamofire on travis with Swift 5.1

I'm trying to run my project with Travis but I can't compile because of an issue with Alamofire. It is not clear to me why it is not working... I'm using alamofire version 4.8 and it should support Xcode 11 and Swift 5.1 without any issue (also, I can compile and run the app locally with Xcode 11.2, the only issue I have is trying to compile it with travis)
This is the error message I see on Travis
module compiled with Swift 5.0.1 cannot be imported by the Swift 5.1 compiler: /Users/travis/build/MyUser/app-ios/app-ios/Carthage/Build/iOS/Alamofire.framework/Modules/Alamofire.swiftmodule/x86_64.swiftmodule
This is my current configuration:
osx_image: xcode11
language: swift
branches:
only:
- master
script: xcodebuild test -workspace apps.xcworkspace -scheme Travis -sdk iphonesimulator ONLY_ACTIVE_ARCH=YES -destination 'platform=iOS Simulator,name=iPhone 8,OS=13.0' | xcpretty && exit ${PIPESTATUS[0]}
I've also tried to use Xcode 11.2 and a simulator with ios 13.2
You need to recompile your Carthage dependencies using something like carthage update --no-use-binaries --platform iOS.

"xcodebuild" command line is not working as expected in Xcode 7.2 with option "-arch"

The following command line will work perfectly with Xcode 7.1 and Xcode 7.1.1.
xcodebuild clean build -workspace MyProject.xcworkspace -scheme MyProject -sdk iphonesimulator9.2 -arch i386 -configuration Debug
But the above is not working in Xcode 7.2. Its always failed to link libraries with the following error. The issue is with the command line argument -arch.
** BUILD FAILED **
The following build commands failed:
CompileC /Users/<user>/Library/Developer/Xcode/DerivedData/MyProject-clwvgmuubptcujfaauznutwgzbbz/Build/Intermediates/Extensions.build/Debug/Extensions.build/Objects-normal/i386/NSString+Convenience.o /Users/<user>/Documents/workspace/depot/builds/<build_id>/Client/iOS/Platform/Text/Common/NSString/NSString+Convenience.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
If I am not using "-arch" and using "destination" it works. For example the following command line option will work in Xcode 7.2
xcodebuild clean build -workspace MyProject.xcworkspace -scheme MyProject -sdk iphonesimulator9.2 -destination 'platform=iOS Simulator,name=iPhone 6' -configuration Debug
Any idea why this issue in Xcode 7.2? Or its may be an issue in my project. Please help.