How to use xcodebuild in Xcode 7 with a watch extension - xcodebuild

Our command used to be like this
xcodebuild -configuration Release -target "xxx" -sdk iphoneos9.0 -scheme "xxx" archive
Now in Xcode 7, we get this error:
Build settings from command line:
SDKROOT = iphoneos9.0
=== BUILD TARGET xxx WatchKit Extension OF PROJECT Mobile WITH CONFIGURATION Release ===
Check dependencies
target specifies product type 'com.apple.product-type.watchkit2-extension', but there's no such product type for the 'iphoneos' platform
How do we specify to use iOS 9.0 SDK and the watchos 2.0 SDK?

If you need a simulator build run this:
xcodebuild -workspace WorkspaceName.xcworkspace -scheme SchemeWithWatchOS2Target -destination 'name=iPhone 6' build
And if you need a device build run this:
xcodebuild -workspace WorkspaceName.xcworkspace -scheme SchemeWithWatchOS2Target build
The trick is that for any build you need to remove -sdk option. For simulator build you need to specify -destination which should be iPhone 6 or iPhone 6 Plus. And for devices builds you skip -destination.

There are several reasons that you're seeing this error, but it boils down to dependencies. If you select a scheme that builds an iOS target, then you don't have a problem using the following command. Note that I used iphoneos to automatically select the latest SDK.
xcodebuild -configuration Release -target "ios" -sdk iphoneos -scheme "ios" build
The problem you're running into is triggered because of a dependency on the watchOS extension. I've created a sample project and added a watchOS application. In the build phases tab, you see in the Dependencies section that the iOS target has a dependency on the WatchOS target.
This isn't a problem if you specify a destination in your build command. But it does give a problem if you tell xcodebuild to build with a specific SDK. Why? Because the WatchOS target cannot be built with the iOS SDK. If you specify iphoneos as the SDK, the build will fail.
Specifying a destination solves the problem, but know that you are using a specific simulator. If you use the same command on a different machine and that simulator isn't available, then the build will fail.
To be honest, I don't know if there's a middle road that lets you select the latest SDK and still use the correct SDK for each target, regardless of dependencies. If you remove the dependency of the iOS target, then the above build command shouldn't fail. You may also need to update the scheme you're using.

Related

iOS React Native app fails to install with Xcode 12 build tools when installed via Detox

I'm trying to run detox tests, on Android they run correctly.
When using Xcode 11 build tools, the app installs correctly and all tests run.
When using Xcode 12 the app fails to install. The app attempts to be installed 3 times, and eventually the simulator complains that it's unable to install and the app icon is darkened on the simulator.
I've tried debug and release configurations, and I am cleaning/building each time. Running the scheme directly in Xcode on v12, the application installs and works normally.
The build command:
xcodebuild -workspace ios/myapp.xcworkspace -configuration Debug -scheme myscheme -sdk iphonesimulator -derivedDataPath ios/build/datapath
What am I missing to get this working on Xcode 12?
It's hard to tell why this happens. Personally I didn't run into such issues with Xcode 12.
You can try the following:
Make sure to use the latest Detox version, sometimes specific Xcode versions require some adjustments (there's Xcode 12.4, 12.5, etc.)
Make sure your applesimutils is up to date (see instructions here).
RN apps sometimes have issues with the new build system, try adding -UseModernBuildSystem=NO to your xcodebuild command.
As per my knowledge, few previous versions of detox don't support Xcode 12. Upgrading detox might solve the issue.

Xcode 12 Problems: "Build input file cannot be found "- Building for release on a react native app

When I try to do an archive build for "any iOS device", I receive this error:
Build input file cannot be found: '/Users/.../Library/Developer/Xcode/DerivedData/[app]-czrkuohjfzuzxxfobfoyptxhyoyo/Build/Intermediates.noindex/ArchiveIntermediates/[app]/InstallationBuildProductsLocation/Applications/[Product Name].app/[Product Name]'
I received this same error when building for an iOS simulator, but this post fixed it - Problems after upgrading to Xcode 12:ld: building for iOS Simulator, but linking in dylib built for iOS, architecture arm64.
I am also receiving a warning concerning the architectures that may or may not be relatable to the error:
None of the architectures in ARCHS (arm64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, armv7s, armv7) which is not in EXCLUDED_ARCHS (arm64).
Build for "Any iOS Device" (for example, "Archive" because you want to upload to AppStore):
Delete arm64 from "Excluded Architectures"
Delete x86_64 from VALID_ARCHS
Add arm64 to VALID_ARCHS
All this changes on both "Build Settings", project and target. And if you want to build for simulator do the inverse path:
Add arm64 to "Excluded Architectures"
Delete arm64 from VALID_ARCHS
Add x86_64 to VALID_ARCHS
That works for me.
So I had the exact same issue. After updating to Xcode 12 I had originally set both my project and target 's 'Excluded Architecture' to arm64 in order to run on Simulator. But, as you mention, that blocks anything from working on Release / Real device. All I had to do was switch to 'Any iOS Simulator SDK = arm64' instead of all of them, see screen shot below:
link to screenshot
This error started happening for me with a SwiftUI app. I didn't need the file for my project, but the settings were set to generate a file anyways. What worked for me was to go into Project Navigator --> App Target --> Build Settings --> Packaging and delete the value (file name) for the Info.plist File key.
This problem wasted a lot of my time after upgrading to xcode 12, using React Native 0.63. Excluding architectures did not work for me.
Symptoms: "build input file could not be found..." when running on device in debug AND release. Simulator worked fine.
To Fix: Editor > Validate Settings... > Perform Changes
Now my app builds fine on device.
I know this question has been answered but this piece of information may help someone: This kind of error may also be produced if you have no node_modules folder e.g. you have deleted it and forgot to re-create it

CMake-generated Xcode project how to produce universal dSYM

I'm using CMake with Xcode generator to generate Xcode project to build framework for iOS and tvOS (and other platforms too).
I'm setting IOS_INSTALL_COMBINED to generate a framework that contains both device and simulator architectures automatically without need of calling lipo myself.
The problem is that generated .framework.dSYM is not universal, it has only x86_64 architecture slice. Should I call lipo manually anyway to merge it myself? I wanted to avoid it and have CMake/Xcode do all the work.

Compile VLCKit as static framework for iOS

I have a question. I cloned VLCKit from (http://code.videolan.org/videolan/VLCKit.git) and try to compile as static framework for tvOS (params -f -t). But I can't find compiled framework (expecting .framework file). Where is it?
The framework flag is not available for tvOS at the moment. For tvOS we only provide a universal static library (*.a) with headers (universal in the sense that it includes a slice for the simulator as well as the device).
It seems that the compile process is broken because tvOS and iOS versions don't match: after compiling using tvOS 9.1, it complains about missing 9.0 SDK:
[info] Building MobileVLCKit (MobileVLCKit, Release, iphoneos)
xcodebuild: error: SDK "iphoneos9.0" cannot be located.
I am not very confident in understanding the compilation prices but it appears that the last phase must hardcode the compilation directories and apparently set a bad target but also use this information as the base SDK so I added a new parameter like below:
buildxcodeproj MobileVLCKit "TVVLCKit" phones appletvos9.0
buildxcodeproj MobileVLCKit "TVVLCKit" iphonesimulator appletvsimulator9.0
that replace the value for --sdk of xcodebuild in buildxcodeproj
Further the paths in final lipo commands are wrong
hope that helps

Compilation of live555 library for iOS simulator

I've compiled live555 library with
./genMakefiles iphoneos
make
for iOS device, but I can't compile that for iOS simulator.
Is anybody has any ideas how to do that?
Thanks.
The problem is that when you compile for iphoneos you are compiling the library for an arm processor. When running the iOS simulator you are running it on an intel x86 processor so it will produce errors along the lines of "symbols not found for i386/x86_64"
If you want to run it on the simulator then try running "./genMakefiles macosx"
If you know how to then you can specify which versions of the generated library files to link depending on what you're building for. Namely that it will link to the .a files if running on an ios device, or it will link the .dylib files when running on simulator
I hope that helps