React native - Codemagic ios build failed to publish - ios

Expected : I need to upload an ipa to app store in flightmode.
Facing :
Below is the response in build ios section(coademagic.yaml response) -
Successfully created archive at build/ios/xcarchive/Projname_6don6ptw.xcarchive
Export build/ios/xcarchive/Projname_6don6ptw.xcarchive to build/ios/ipa
Execute "xcodebuild -exportArchive -archivePath build/ios/xcarchive/Projname_6don6ptw.xcarchive -exportPath build/ios/ipa -exportOptionsPlist /Users/builder/export_options.plist COMPILER_INDEX_STORE_ENABLE=NO"
▸ Export Succeeded
Successfully exported ipa to build/ios/ipa/Projname.ipa
Raw xcodebuild logs stored in /tmp/xcodebuild_logs/Projname_4fqjb9bq.log
And in publishing block of(codemagic.yaml):
== Gathering artifacts ==
== Publishing artifacts ==
Publishing artifact AppReactNative_40_artifacts.zip
Skip publishing to App Store Connect: no IPAs found
Project ipa is created, but I don't understand why it's missing in artifact.zip file.

do you have the next lines in your codemagic.yaml file?
artifacts:
- build/ios/ipa/*.ipa
you can find a full example here
https://docs.codemagic.io/getting-started/building-a-react-native-app/#ios-workflow-example

Related

Unable to resolve module "empty-module.js" error

For building an iOS React Native app, I am able to successfully run the following command in a MacOS terminal:
xcodebuild archive -workspace MyProject.xcworkspace -derivedDataPath build -scheme MyProject -archivePath $PWD/build-artifacts/MyProject.xcarchive -configuration Release CODE_SIGN_STYLE='Automatic' BITCODE_GENERATION_MODE='bitcode'
However when invoking the same command via a Jenkins "Execute shell" step, it results in the following error:
error Unable to resolve module /Users/mike/git/my-project/node_modules/react-native/node_modules/metro-runtime/src/modules/empty-module.js from /Users/mike/git/my-project/_:
None of these files exist:
* ../my-project/node_modules/react-native/node_modules/metro-runtime/src/modules/empty-module.js(.native|.native.js|.js|.native.json|.json|.native.ts|.ts|.native.tsx|.tsx)
* ../my-project/node_modules/react-native/node_modules/metro-runtime/src/modules/empty-module.js/index(.native|.native.js|.js|.native.json|.json|.native.ts|.ts|.native.tsx|.tsx)
at ModuleResolver.resolveDependency (/Users/mike/git/my-project/node_modules/react-native/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:136:15)
at ModuleResolver._getEmptyModule (/Users/mike/git/my-project/node_modules/react-native/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:49:26)
at ModuleResolver._getFileResolvedModule (/Users/mike/git/my-project/node_modules/react-native/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:195:21)
at ModuleResolver.resolveDependency (/Users/mike/git/my-project/node_modules/react-native/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:132:19)
at DependencyGraph.resolveDependency (/Users/mike/git/my-project/node_modules/react-native/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)
at Object.resolve (/Users/mike/git/my-project/node_modules/react-native/node_modules/metro/src/lib/transformHelpers.js:129:24)
at resolve (/Users/mike/git/my-project/node_modules/react-native/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33)
at /Users/mike/git/my-project/node_modules/react-native/node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26
at Array.reduce (<anonymous>)
at resolveDependencies (/Users/mike/git/my-project/node_modules/react-native/node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33)
I have ensured that the PATH is set consistently between the system and Jenkins for build tools like node and npm. I would appreciate any input from anyone who has experienced
similar issues.

How to use Fastlane with a CMake generated XCode project with dependency on WebP?

I have a project written in C++ where CMake is used to generate the build system for various platforms including iOS. The project has a dependency on WebP. You can find an example project on GitHub here that can be used to reproduce things & I've included the relevant source files at the end of this post for completeness.
The Xcode build system for iOS is generated using CMake as follows:
cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=third_party/ios-cmake/ios.toolchain.cmake -DPLATFORM=OS64 -DDEPLOYMENT_TARGET=15.0 -DENABLE_BITCODE=0 -S . -B cmake-build-release
We can now attempt to build/archive the app using Fastlane with the command from within the generated cmake-build-release directory:
bundle exec fastlane ios beta
However this fails due to being unable to locate various webp object files (that based on console output it appears to have previously successfully compiled):
...
▸ Compiling buffer_dec.c
▸ Compiling alpha_dec.c
▸ Building library libwebpdsp.a
...
** ARCHIVE FAILED **
▸ The following build commands failed:
▸ Libtool /Users/dbotha/Library/Developer/Xcode/DerivedData/CMakeFastlaneWebpTest-dlwvukebfiwjqvaqiepshuxqklhh/ArchiveIntermediates/CMakeFastlaneWebpTest/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libwebpdecoder.a normal (in target 'webpdecoder' from project 'CMakeFastlaneWebpTest')
▸ (1 failure)
▸ ❌ error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't open file: /Users/dbotha/CLionProjects/CMakeFastlaneWebpTest/cmake-build-release/third_party/libwebp/CMakeFastlaneWebpTest.build/Release-iphoneos/webpdecode.build/Objects-normal/arm64/alpha_dec.o (No such file or directory)
▸ ❌ error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't open file: /Users/dbotha/CLionProjects/CMakeFastlaneWebpTest/cmake-build-release/third_party/libwebp/CMakeFastlaneWebpTest.build/Release-iphoneos/webpdecode.build/Objects-normal/arm64/buffer_dec.o (No such file or directory)
...
Internally Fastlane attempted to build/archive the project with the following command:
xcodebuild -scheme CMakeFastlaneWebpTest -project ./CMakeFastlaneWebpTest.xcodeproj -configuration Release -destination 'generic/platform=iOS' -archivePath ./out.xcarchive archive
Interestingly an archive can be successfully generated if I use the following xcodebuild command (note how -target flag is used instead of -scheme):
xcodebuild -project CMakeFastlaneWebpTest.xcodeproj archive -target CMakeFastlaneWebpTest -configuration Release
After this successful attempt bundle exec fastlane ios beta will now also succeed as the compiled object files are where it expected them to be.
Now I'd happily workaround this issue using my xcodebuild + -target flag approach and then use the fastlane command to push to Testflight, etc. but the real project (not this toy example) takes a very long time to build so building it twice is really wasteful from a cost point of view on CI platforms.
Does anyone have any idea what's going on here & how I can successfully build things in the first instance using fastlane without my own explicit call to xcodebuild first? Or alternatively how can I have Fastlane use the successfully built objects from my workaround so it doesn't need to rebuild the entire project from scratch?
CMakeLists.txt
cmake_minimum_required(VERSION 3.23)
project(CMakeFastlaneWebpTest)
set(CMAKE_CXX_STANDARD 14)
add_executable(CMakeFastlaneWebpTest src/main.cpp)
# Skip building of unused webp tools which fail for me under ios:
set(WEBP_BUILD_ANIM_UTILS OFF)
set(WEBP_BUILD_CWEBP OFF)
set(WEBP_BUILD_DWEBP OFF)
set(WEBP_BUILD_GIF2WEBP OFF)
set(WEBP_BUILD_IMG2WEBP OFF)
set(WEBP_BUILD_VWEBP OFF)
set(WEBP_BUILD_WEBPINFO OFF)
set(WEBP_BUILD_WEBPMUX OFF)
set(WEBP_BUILD_EXTRAS OFF)
set(WEBP_BUILD_WEBP_JS OFF)
add_subdirectory(third_party/libwebp EXCLUDE_FROM_ALL)
target_link_libraries(CMakeFastlaneWebpTest PRIVATE webpdecoder webpdemux)
include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/third_party/libwebp/src)
configure_file(${CMAKE_SOURCE_DIR}/fastlane/Appfile ${CMAKE_BINARY_DIR}/fastlane/Appfile COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/fastlane/Fastfile ${CMAKE_BINARY_DIR}/fastlane/Fastfile COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/Gemfile ${CMAKE_BINARY_DIR}/Gemfile COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/Gemfile.lock ${CMAKE_BINARY_DIR}/Gemfile.lock COPYONLY)
set_target_properties(CMakeFastlaneWebpTest PROPERTIES
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/src/iOS-Info.plist.in
MACOSX_BUNDLE_GUI_IDENTIFIER com.dbotha.CMakeFastlaneWebpTest
MACOSX_BUNDLE_BUNDLE_NAME CMakeFastlaneWebpTest
MACOSX_BUNDLE_BUNDLE_VERSION "0.1"
MACOSX_BUNDLE_SHORT_VERSION_STRING "0.1"
)
set_xcode_property(CMakeFastlaneWebpTest PRODUCT_BUNDLE_IDENTIFIER "com.dbotha.CMakeFastlaneWebpTest" All)
set_xcode_property(CMakeFastlaneWebpTest CODE_SIGN_IDENTITY "iPhone Developer" All)
set_xcode_property(CMakeFastlaneWebpTest DEVELOPMENT_TEAM "GFP63373B2" All)
fastlane/Appfile
app_identifier("com.dbotha.CMakeFastlaneWebpTest") # The bundle identifier of your app
apple_id("REPLACE_ME") # Your Apple Developer Portal username
itc_team_id("REPLACE_ME") # App Store Connect Team ID
team_id("REPLACE_ME") # Developer Portal Team ID
fastlane/Fastfile
default_platform(:ios)
platform :ios do
desc "Push a new beta build to TestFlight"
lane :beta do
build_app(scheme: "CMakeFastlaneWebpTest", configuration: "Release")
upload_to_testflight
end
end
src/main.cpp
#include <iostream>
#include <webp/demux.h>
int main() {
WebPAnimDecoderOptions decOptions;
(void)decOptions;
std::cout << "Hello, World!" << std::endl;
return 0;
}
I'm not an expert in this topic but according to the documentation you should provide workspace to build your scheme.
To build an Xcode workspace, you must pass both the -workspace and
-scheme options to define the build. The parameters of the scheme will
control which targets are built and how they are built, although you may
pass other options to xcodebuild to override some parameters of the
scheme.
Scheme controls what target will be build, and guessing by your example, since you do not provide a workspace, it gets lost in the process.
The scheme is not lost anymore if you build the target manually. Since it is already build the scheme does not have to do a thing.
My proposals:
Option 1: Try adding workspace to build_app parameters in Fastfile.
Option 2: Don't bother with building scheme just use target in the
build_app parameters in Fastfile like so: build_app(target: "CMakeFastlaneWebpTest", configuration: "Release")

Someone got convert coverage in new version xcode12 - SonarQube

I'm trying to perform the conversion for SonarQube to interpret coverage and I get this error:
Error: Error Domain=XCCovErrorDomain Code=0 "Failed to load result bundle" UserInfo={NSLocalizedDescription=Failed to load result bundle, NSUnderlyingError=0x7fdaa840a8d0 {Error Domain=IDEFoundation.ResultBundleError Code=0 "This version of Xcode does not support opening result bundles created with versions of Xcode and xcodebuild using the v1 API."}}
The operation couldn’t be completed. (cococoLibrary.Bash.Error error 0.)
The solution was to update slather to version 2.5 and also generate coverage in the sonarqube generic mode. Follow the steps for successful reproduction:
Build
xcodebuild -workspace 'YourProject.xcworkspace' -scheme DEV -derivedDataPath Build/ -enableCodeCoverage YES clean build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -destination 'platform=iOS Simulator,name=iPhone 8,OS=14.0'
Slather generate sonarqube generic xml
slather coverage --jenkins --sonarqube-xml --build-directory ./Build --output-directory ./sonar-reports --scheme DEV --workspace YourProject.xcworkspace
Run analise Sonarqube
sonar-scanner -Dsonar.sources=. -Dsonar.coverageReportPaths=./sonar-reports/sonarqube-generic-coverage.xml -Dproject.settings=sonar-project.properties -Dsonar.qualitygate.wait=true
This page gives steps to generate code coverage for various Xcode versions. there are primarily 3 steps as shown in the description.
Build project
Create code coverage report
Import code coverage report
https://github.com/SonarSource/sonar-scanning-examples/tree/master/swift-coverage
This is a popular page to integrate CI with Sonar as well, its from SonarSource.

Set CFBundleDisplayName app name for cordova app on iOS (using fastlane)

I have trouble setting the correct app name below the icon for a Cordova iOS app.
I use Cordova, Fastlane, match and gym to create the build.
To create a Cordova project I do:
cordova create cordova-dir cordova.app.id cordova-appName
In the generated Info.plist file it says:
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
gym command in Fastfile file is:
gym(
project: "./cordova-dir/platforms/ios/cordova-appName.xcodeproj",
scheme: "cordova-appName",
use_legacy_build_api: "true",
export_method: "enterprise",
codesigning_identity: "iPhone Distribution: My Company Limited"
)
The generated command is:
set -o pipefail && xcodebuild -scheme 'cordova-appName' -project './build-cordova/platforms/ios/cordova-appName.xcodeproj' -destination 'generic/platform=iOS' -archivePath '/private/var/user/Library/Developer/Xcode/Archives/2016-03-29/cordova-appName 2016-03-29 16.20.06.xcarchive' archive CODE_SIGN_IDENTITY='iPhone Distribution: My Company Limited' | tee /private/var/user/Library/Logs/gym/cordova-appName-cordova-appName.log | xcpretty
The ipa file is called cordova.app.id.ipa
The displayed name on the device below the icon later is cordova.app.id, not cordova-appName.
I'm confused what actually sets the name of an app. I don't want to involve opening xcode in this at all. I hope one of the involved settings/options is able to set the correct name.
HockeyApp is used to distribute the app.

On Travis CI how are iOS apps code signed and uploaded to Apple TestFlight?

I've been trying to setup Travis CI as a build server, but am running into problems both code signing the app, and uploading it to TestFlight.
The main issue is uploading to Apple TestFlight. I can find a lot guides online on how to upload to the old version of TestFlight at testflightapp.com, but I've not figured out how to upload to iTunes Connect.
I attempted to use the altool command:
altool --upload-app -f "$OUTPUTDIR/$APP_NAME.ipa" -u '$ITUNES_CONNECT_USERNAME' -p '$ITUNES_CONNECT_PASSWORD'
But on Travis CI it doesn't work:
altool: command not found
-
I've primarily used the following tutorials to get this far: http://www.raywenderlich.com/109418/travis-ci-tutorial and https://www.objc.io/issues/6-build-tools/travis-ci/#app-signing
This is a useful official page:
http://docs.travis-ci.com/user/languages/objective-c/
-
This is my project setup:
.travis.yml file:
language: objective-c
osx_image: xcode7.1
xcode_workspace: XXXXXXX.xcworkspace
xcode_scheme: XXXXXXX
env:
global:
- APP_NAME="XXXXXX"
- DEVELOPER_NAME="iPhone Distribution: XXXXXXX (XXXXXXX)"
- PROFILE_NAME="XXXXXXXXXXXXX"
- ITUNES_CONNECT_USERNAME="XXXXXX#XXXXXX.com"
- secure: XXXXXXXXXXXXXXXXXXXXXX
before_script:
- ./scripts/add-key.sh
- ./scripts/update-bundle.sh
script:
- xctool -workspace XXXXXXX.xcworkspace -scheme XXXXXXX -sdk iphoneos -configuration
Release OBJROOT=$PWD/build SYMROOT=$PWD/build ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY=""
CODE_SIGNING_REQUIRED=NO
after_success:
- ./scripts/sign-and-upload.sh
after_script:
- ./scripts/remove-key.sh
Note that the CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO on the end of the build command is there because otherwise the app fails to build (see https://github.com/travis-ci/travis-ci/issues/3047 for details, and https://stackoverflow.com/a/11647504/404409 for more info on it). This is probably a cause of the code signing issue described below.
The add-key.sh, sign-and-upload.sh and remove-key.sh scripts are basically just copied direct from https://www.objc.io/issues/6-build-tools/travis-ci/#add-scripts
With the exception of this line being added the end of sign-and-upload.sh:
altool --upload-app -f "$OUTPUTDIR/$APP_NAME.ipa" -u '$ITUNES_CONNECT_USERNAME' -p '$ITUNES_CONNECT_PASSWORD'
-
The app builds, but this is the output from the sign-and-upload.sh script at the end:
env SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication /Users/travis/build/XXXXXX/ios/build/Release-iphoneos/XXXXXXX.app -o /Users/travis/build/XXXXXX/ios/build/Release-iphoneos/XXXXXXX.ipa -sign iPhone\ Distribution\=XXXXXXXXXXXX -embed /Users/travis/Library/MobileDevice/Provisioning\ Profiles/XXXXXXXXXXX.mobileprovision
error: Failed to read entitlements from '/var/folders/my/XXXXXXXXXXXXXXXXXXX/X/XXXXXXXXX/Payload/Kimono.app'
./scripts/sign-and-upload.sh: line 20: altool: command not found
-
If you have any clues as to how iOS apps should be done on Travis CI, or how to submit builds to TestFlight over the command line I would be eternally grateful!
Thank you.
On my machine, there is no altool in my PATH, but xcrun altool works. Maybe try that?

Resources