xcodebuild fails to build SPM packages with catalyst support - xcode

I'm trying to build a mac catalyst project using the xcodebuild command line tool. The project was originally an iOS app that now supports mac catalyst. The project is using Cocoapods and Swift Package Manager as we have some libraries that don't support the latter. I'm using the following xcodebuild command
xcodebuild -workspace 'PROJECT.xcworkspace' -scheme 'MY_SCHEME' -configuration 'MY_CONFIG' CODE_SIGN_IDENTITY='MY_IDENTITY' ENABLE_BITCODE=YES ONLY_ACTIVE_ARCH=NO DEBUG_INFORMATION_FORMAT=dwarf-with-dsym
It fails with the following error
error: Signing for "RealmCore" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'RealmCore' from project 'RealmCore')
error: Signing for "Alamofire" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'Alamofire' from project 'Alamofire')
error: Signing for "Realm" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'Realm' from project 'Realm')
All the mentioned libraries were added using SPM. I don't understand why this fails. Do swift packages require a development team?
Also the problem only seems to be the addition of the mac catalyst target. I have a branch of the iOS app without catalyst support with the same SPM dependencies and xcodebuild works without problem.

Related

build and deploy iOS app to local device using CLI

In switching from Cordova to Capacitor we seem to have lost the ability to deploy our app to physical devices using the command line. This is helpful so that our automated build process can push it out to a set of devices we have connected to the server. All the docs for deploying with Capacitor say to open Xcode and select a device for deployment. I'm trying with instruments to get the device ID and then xcodebuild to install it
instruments -s devices | grep -v Simulator | grep -e iPhone -e iPad
xcodebuild install -workspace ios/App/App.xcworkspace -scheme App -destination 'platform=iOS,id=76a....781'
And even though this ends with ** install succeeded ** the app has not been installed on the device
You can consider bumping your Capacitor version to v3.0.0 rc3.. The team is building upon a new command to run the app on device without opening the native ide.
npx cap run ios
Source Discussion Capacitor v3
Alternative - Use Ionic Appflow for deployments.
For Appflow builds on the cloud.. You can do two things there..
Live Deploy - if you have just made any changes to the code, the js, HTML, css side, then use LiveDeploy, this will be much faster for deploying to all the app users.
Native Builds - incase you have added any new plugin or made native configuration changes, then make a native build that can deploy it to test flight and then your tester's can download the updated version from there..
You can also set auto triggers for these workflows as well when you commit your code to the repository.
If waiting for Capacitor 3 is not an option these three lines work
xcodebuild -workspace ios/App/App.xcworkspace/ -scheme App -archivePath ./ios/App.xcarchive archive
xcodebuild -exportArchive -archivePath ./ios/App.xcarchive -exportOptionsPlist ./ios/App/export-development.plist -exportPath ./iOS
ios-deploy --debug --bundle ios/App.ipa

Android Studio cannot run the Xcode Simulator

I am trying to simulate my Flutter app with the Xcode iPhone Simulator and I get this error. Before upgrading Android Studio and Xcode it was working fine.
Launching lib/main.dart on iPhone X in debug mode...
Starting Xcode build...
Xcode build done.
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
error: Multiple commands produce '/Users/User/AndroidStudioProjects/my_app/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework':
1) Target 'Runner' has copy command from '/Users/User/AndroidStudioProjects/my_app/ios/Flutter/Flutter.framework' to '/Users/User/AndroidStudioProjects/my_app/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework'
2) That command depends on command in Target 'Runner': script phase “[CP] Embed Pods Frameworks”
warning: ignoring duplicated output file: '/Users/User/AndroidStudioProjects/my_app/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework' (in target 'Runner')
note: Using new build systemnote: Planning buildnote: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone X.
Using:
macOS 10.13.6 (17G65)
Android Studio 3.2 Build #AI-181.5540.7.32.5014246, built on September 18, 2018
Xcode 10.0 (10A255)
Xcode Simulator 10.0 (SimulatorApp-869.5 CoreSimulator-572.2)
Should be fixed in master channel
https://github.com/flutter/flutter/issues/20685#issuecomment-421511890
Workarounds
There are two workarounds:
Option 1: Use the legacy build system . As noted by #gi097, open ios/Runner.xcworkspace, and change the build system to Legacy Build
System.
Option 2: Use the new Xcode 10 build system.
Open ios/Runner.xcworkspace
Select the Runner project in the project navigator sidebar.
In the main view, select the Runner target, then select the Build Phases tab.
Expand the Embed Frameworks phase and select Flutter.framework from the embedded frameworks list.
Click - to remove Flutter.framework from the list (be sure to keep App.framework).

Jenkins&Xcode : Build crashes in ipad frequently

I'm currently generating an ios app with distribution profile. When I generate an ipa file from Xcode it works fine without any crashes when installed on an ipad but it crashes in most fields when generated from jenkins as a part CI process. Till now its working fine but the issue started while adding developed frameworks to the project. In jenkins I'm using below command line script for xcodebuild.
. xcodebuild -workspace ~/.jenkins/jobs/workspace/repo/Source/App/App.xcodeproj/project.xcworkspace -scheme App -configuration "release" -sdk iphoneos VALID_ARCHS="armv64 armv7 armv7s i386" archive PROVISIONING_PROFILE="xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx" CODE_SIGN_IDENTITY="iPhone Distribution: company Limited" -archivePath ~/Desktop/../App.xcarchive
Unable to find out the exact issue for the crash.
I suggest you to check the environment variable of your jenkins node.. if they are overriding your build variables.
Before this can you provide more details.

Error ITMS-9000: Missing or invalid signature. AFTER updating from OS X 10.8 to 10.9

We have an automated build system that has been running on OSX 10.8 (Mac Mini - Xcode 5.1.1) perfectly until after we updated to 10.9 (Mac Pro - Xcode 5.1.1).
After updating to OSX 10.9 we started receiving the following error when we attempt to upload our IPA via Application Loader:
ERROR ITMS-9000: "Missing or invalid signature. The bundle 'com.my.bundle" at bundle path "Payload/bundle.app" is not signed using an Apple submission certificate."
The following statements are ran after Unity has built the Xcode project.
xcodebuild -target "Unity-iPhone" -sdk "iphoneos" -configuration Release CODE_SIGN_IDENTITY="iPhone Distribution: Company Name, Inc. (DDXX7YXXXX)" PROVISIONING_PROFILE=d5e4xxxx-xxxx-xxxx-xxxx-5fef0dbe3e50;
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "$IOS_RELEASE_SAVE_PATH/build/bundle.app" -o "IOS_IPA_PATH/bundle_RELEASE.ipa" --sign "Company Name, Inc. (DDXX7YXXXX)" --embed "/Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profiles/d5e4xxxx-xxxx-xxxx-xxxx-5fef0dbe3e50.mobileprovision";
As a side note, our ADHOC builds are signed using the same certificate, just a different provision, and work fine.
I double checked the following items:
Project and Provision bundle ids match. (Case sensitivity and potential character replacements.)
Certificates & Provisions are up to date.
Distribution Certs are marked as TRUSTED to all users.
I also built the IPA manually and attempted to submit, but resulted with the same error.
Other options I have tried:
Adding '--deep' to 'Other Code Signning Flags' in both Project and Targets.
Adding a codesign script to Build Phases (Code Signing and Mavircks: furbo.org)
Any help would be greatly appreciated.
Edit: Added - Distribution Certs are marked as TRUSTED to all users & Platform model/Xcode version.
It has been a long time, but I encountered this issue again when updating from OSX 10.9 Mavericks & Xcode 5.1.1 to OSX 10.10 & Xcode 6.1.1.
Solution (similar to TWilly's comment):
NOTE: BACKUP .p12 keys and certs as needed!
Reset Keychain to System Defaults and purge all Provision Profiles from iPhone Configuration Utility.
Retrieve your .p12 key and Provisions from the Developer Portal.
Apply your publishing and development certs to SYSTEM (not login).
Attempt to build from command line.
Additionally, building from CL on OSX 10.10 and XCODE6 may introduce an issue: “ResourceRules.plist: cannot read resources”
See this link for solutions.

OSX 10.7 Precompile Errors in new Xcode Projects

I'm trying to build a new Xcode project targeting the 10.7 Mac SDK (and using llvm 3.1) and am getting a lot of parse errors during the precompile phase.
All of the Cocoa Foundation files are causing parse errors e.g.
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h:525:174: error: expected function body after function declarator
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFError.h:68:43: error: expected ';' after top level declarator
CF_EXPORT const CFStringRef kCFErrorURLKey CF_AVAILABLE(10_7, 5_0); // Key to identify associated URL in userInfo. Typically one of this or kCFErrorFilePathKey is provided.
If I switch back to using 10.6 everything seems to compile and run fine.
I've attempted to remove and re-install dev tools using:
sudo /Developer/Library/uninstall-devtools -mode=all
... and then re-installing Xcode 4.3.1, but my 10.7 builds of any new project still fail.
Has anyone seen a similar issue with Xcode 4.3+ and the 10.7 SDK. And what other steps should I try and take to clean/install the dev tools/Xcode?
I've uploaded the build log to http://pastebin.com/ahYzhrww.
I ran into this not too long ago. These steps resolved it for me:
Remove Xcode.app from /Applications
Rename /Developer to /Devoper-old
Reinstall Xcode from the Mac App Store.
In XCode, open the Xcode menu and choose Open Developer Tools, More developer tools...
to download the rest of the developer tools.

Resources