CocoaPods integration with CommandLineTool and Dylib targets - objective-c

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.

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.

(JS/react-native) How can I solve this error for building react-native app for iOS

Hey guys I'm so new to JS and react-native as well. I was trying to solve this error but I couldn't get it at all! meh
This is what I struggled :
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
- react-native-ble-plx (to unlink run: "react-native unlink react-native-ble-plx")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
error Could not find the following native modules: RNCAsyncStorage, react-native-ble-plx. Did you forget to run "pod install" ?
info Found Xcode workspace "Sat008.xcworkspace"
info Building (using "xcodebuild -workspace Sat008.xcworkspace -configuration Debug -scheme Sat008 -destination id=61F7DB8A-467A-4027-95C3-B030C17EAA17")
...............
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 Sat008.xcworkspace. Run CLI with --verbose flag for more details.
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace Sat008.xcworkspace -configuration Debug -scheme Sat008 -destination id=61F7DB8A-467A-4027-95C3-B030C17EAA17
Prepare build
note: Using legacy build system
=== BUILD TARGET Sat008 OF PROJECT Sat008 WITH CONFIGURATION Debug ===
Check dependencies
The file “Pods-Sat008.debug.xcconfig” couldn’t be opened because there is no such file. (/Users/hyunmincho/Documents/React-Native/SAT_008_DEV/Earthrise-Anders/app/ios/Pods/Target Support Files/Pods-Sat008/Pods-Sat008.debug.xcconfig)
PhaseScriptExecution [CP]\ Check\ Pods\ Manifest.lock /Users/hyunmincho/Library/Developer/Xcode/DerivedData/Sat008-fynygwtjzergqceioiaqjhnwrfbp/Build/Intermediates.noindex/Sat008.build/Debug-iphonesimulator/Sat008.build/Script-D12BA90C2EB97176F46BC0FF.sh
cd /Users/hyunmincho/Documents/React-Native/SAT_008_DEV/Earthrise-Anders/app/ios
/bin/sh -c /Users/hyunmincho/Library/Developer/Xcode/DerivedData/Sat008-fynygwtjzergqceioiaqjhnwrfbp/Build/Intermediates.noindex/Sat008.build/Debug-iphonesimulator/Sat008.build/Script-D12BA90C2EB97176F46BC0FF.sh
diff: /Podfile.lock: No such file or directory
diff: /Manifest.lock: No such file or directory
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution [CP]\ Check\ Pods\ Manifest.lock /Users/hyunmincho/Library/Developer/Xcode/DerivedData/Sat008-fynygwtjzergqceioiaqjhnwrfbp/Build/Intermediates.noindex/Sat008.build/Debug-iphonesimulator/Sat008.build/Script-D12BA90C2EB97176F46BC0FF.sh
(1 failure)

"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.

xctool tests fail when xcodebuild works - Travis CI

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

Linker error when launching tests after a Project Clean with cocoapods

I've recently adopted cocoapods in my project, and everything seems to work fine except for a small annoying thing.
Before cocoapods, hitting cmd+u would have compiled my entire project and run tests; after adding cocoapods if I hit cmd+u after a project clean (Product->clean or shift+cmd+k) I receive a linker error, precisely:
//{Path_To_My_app} is the path to my app's folder and {MyAppName} is my app's name
ld: file not found: /Users/my_name/{Path_To_My_app}/Build/Products/Debug- iphonesimulator/{MyAppName}.app/{MyAppName}
clang: error: linker command failed with exit code 1 (use -v to see invocation)
to make it work I have to build it first and than hit cmd+u.
To be precise I can't remember if this was so before, but I'm pretty sure it wasn't...I can't seem to understand why this happens, and why hitting "cmd+u" is not building the project and than running the tests.
EDIT
I have specified in my podfile to add some pods just to my test target, so it is like:
platform :ios, "7.0"
pod 'SVProgressHUD', :head
pod 'GoogleAnalytics-iOS-SDK', '~> 3.0.7'
pod 'TestFlightSDK', '~> 3.0.2'
target "MyTestTarget" do
pod 'OCMock', '~> 2.2.4'
end