How to remove file reference from Runner.xcodeproj - ios

I have a ruby code that uses xcodeproject that adds my Google-Info.plist to Runner.xcodeproj as a reference. However I want to remove the older reference because I get following error:
Xcode's output:
↳
error: Multiple commands produce '/Users/figengungor/Documents/projects/app_gmo/base/build/ios/Release-iphoneos/Runner.app/GoogleService-Info.plist':
1) Target 'Runner' (project 'Runner') has copy command from '/Users/figengungor/Documents/Base Firebase Files/GoogleService-Info.plist' to
'/Users/figengungor/Documents/projects/app_gmo/base/build/ios/Release-iphoneos/Runner.app/GoogleService-Info.plist'
2) Target 'Runner' (project 'Runner') has copy command from '/Users/figengungor/Documents/projects/app_gmo/base/ios/GoogleService-Info.plist' to
'/Users/figengungor/Documents/projects/app_gmo/base/build/ios/Release-iphoneos/Runner.app/GoogleService-Info.plist'
Here’s how I add the Google-Info.plist reference:
require 'xcodeproj'
project = Xcodeproj::Project.open(ARGV[0])
main_target = project.targets.first
gsi_reference = project.main_group['Runner'].new_file(ARGV[1])
main_target.add_file_references([gsi_reference])
project.save
Here’s the me trying to delete but not being successful code(I’m not familiar with Ruby, tried to follow documentation):
old_gsi_reference = project.main_group['Runner'].find_file_by_path('/Users/figengungor/Documents/Base Firebase Files/GoogleService-Info.plist')
old_gsi_reference.remove_from_project()
Does anyone have experience with xcodeproject and can help me out?

Related

Flutter - Xcode can't see app packages while building for Simulator

Whenever I try running my app Xcode gives me this:
Launching lib/main.dart on iPhone 14 Pro Max in debug mode...
lib/main.dart:1
Xcode build done. 9.9s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
Writing result bundle at path:
/var/folders/4m/6ntf71vx17qfqdg9kr88s2s80000gn/T/flutter_tools.V6z5EC/flutter_ios_build_temp_dirX4Qj6c/temporary_xcresult_bundle
: Error: The getter 'payload' isn't defined for the class 'NotificationAppLaunchDetails'.
lib/main.dart:57
- 'NotificationAppLaunchDetails' is from 'package:flutter_local_notifications_platform_interface/src/types.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_local_notifications_platform_interface-6.0.0/lib/src/types.dart').
package:flutter_local_notifications_platform_interface/src/types.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'payload'.
_orderID = (notificationAppLaunchDetails.payload != null &&
^^^^^^^
: Error: The getter 'payload' isn't defined for the class 'NotificationAppLaunchDetails'.
lib/main.dart:58
- 'NotificationAppLaunchDetails' is from 'package:flutter_local_notifications_platform_interface/src/types.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_local_notifications_platform_interface-6.0.0/lib/src/types.dart').
package:flutter_local_notifications_platform_interface/src/types.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'payload'.
notificationAppLaunchDetails.payload.isNotEmpty)
^^^^^^^
: Error: The getter 'payload' isn't defined for the class 'NotificationAppLaunchDetails'.
lib/main.dart:59
- 'NotificationAppLaunchDetails' is from 'package:flutter_local_notifications_platform_interface/src/types.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_local_notifications_platform_interface-6.0.0/lib/src/types.dart').
package:flutter_local_notifications_platform_interface/src/types.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'payload'.
? int.parse(notificationAppLaunchDetails.payload)
^^^^^^^
: Error: The getter 'WebView' isn't defined for the class '_PaymentScreenState'.
package:flutter_sixvalley_ecommerce/…/payment/payment_screen.dart:46
- '_PaymentScreenState' is from 'package:flutter_sixvalley_ecommerce/view/screen/payment/payment_screen.dart' ('lib/view/screen/payment/payment_screen.dart').
package:flutter_sixvalley_ecommerce/…/payment/payment_screen.dart:1
.
. (goes on like this for the rest of the packages)
.
Failed to package /Users/abdelrahmanmohamed/development/FlutterProjects/valley_userapp.
Command PhaseScriptExecution failed with a nonzero exit code
note: Building targets in dependency order
warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner')
warning: Run script build phase 'Thin Binary' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Runner' from project 'Runner')
Result bundle written to path:
/var/folders/4m/6ntf71vx17qfqdg9kr88s2s80000gn/T/flutter_tools.V6z5EC/flutter_ios_build_temp_dirX4Qj6c/temporary_xcresult_bundle
Could not build the application for the simulator.
Error launching application on iPhone 14 Pro Max.
Exited
No matter how much I do flutter clean and arch -x86_64 pod install. It keeps doing this.
I am using a mac silicon machine. And this is a project I didn't run before on it. So its new.
I am using Flutter 3.3.10. And I am able to build and run other Flutter apps.
So running dat analyze as #Alaindeseine suggested revealed in the code editor that these were actually errors in code.
The assets were old and when I updated them it didn't reflect in the code editor.
You can use dart anayze command to display info, warnings, errors and deprecateds. It may help finding what is going wrong with you code.
You can alos use dart fix --dry-runcommand to list and dart fix --apply to fix problems.

iOS: How to build a static framework based on CocoaPods dependencies?

I am trying to build a framework that makes use of the geopackage-ios CocoaPods dependency. I would then like to statically embed this framework into one or more apps.
Similar questions have been asked before, but I couldn't find a solution to my problem. Here's what I've been trying so far:
First Approach: Building Manually
In this approach, I would create a static library using Xcode, add the CocoaPods dependencies to it and build it. The problem with this approach, however, is that the resulting framework will not have the CocoaPods dependencies embedded into it.
Create a new static library from Xcode (File > New > Project… > iOS: Static Library) named "MyLibrary" with language Swift.
Create a Podfile in the project root directory with the following content:
target 'MyLibrary' do
pod 'geopackage-ios', '~> 7.2.1'
end
Run pod install. (This will install the geopackage-ios pod and 10 depending pods.)
Open the newly created MyLibrary.xcworkspace and add a BridgingHeader.h to the "MyLibrary" group having the following content:
#ifndef BridgingHeader_h
#define BridgingHeader_h
#import "geopackage-ios-Bridging-Header.h"
#endif
Reference the bridging header by clicking on the "MyLibrary" project in the project navigator, selecting the "MyLibrary" target and, in the Build Settings, specifying MyLibrary/BridgingHeader.h as the "Objective-C Bridging Header".
Modify MyLibrary.swift to use the GeoPackage dependency:
public class MyLibrary {
public init() {}
public func test() {
let manager = GPKGGeoPackageFactory.manager()!
print("Manager:", manager)
}
}
Build the library for the iOS simulator by pressing Cmd + B.
Optionally, create a static framework using a shell script like the one in this article (which will compile the library once for the simulator and once for physical devices and then combine the two results to a universal framework using the lipo command).
When I embed either the static library (along with the MyLibrary.swiftmodule) or the universal framework into an app, linking will fail for this app:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GPKGGeoPackageManager", referenced from:
objc-class-ref in libMyLibrary.a(MyLibrary.o)
"_OBJC_CLASS_$_GPKGGeoPackageFactory", referenced from:
objc-class-ref in libMyLibrary.a(MyLibrary.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I could also add the geopackage_ios.framework (found in the build folder of "MyLibrary") to the app (making sure to choose the Embed & Sign embedding option), which will allow the app to be built successfully. Then, however, the app will crash upon launch:
dyld[79209]: Library not loaded: #rpath/ogc_api_features_json_ios.framework/ogc_api_features_json_ios
Referenced from: /Users/admin1/Library/Developer/CoreSimulator/Devices/C3D61224-CFE8-45CC-951B-7B6AB54BC8B3/data/Containers/Bundle/Application/D41A82D6-4E69-4BB6-AC59-6BC28AE58795/TestApp.app/Frameworks/geopackage_ios.framework/geopackage_ios
One might be able to fix this by adding all eleven pod frameworks to the app, which, however, is what I'm trying to avoid.
Second Approach: Using PodBuilder
A second approach would be to use PodBuilder, which aims at automating this particular kind of build task. This approach, however, fails with a build error, the cause of which I can't quite make out.
Again, I would start out with a new Xcode project. This time, I'd create an iOS Swift app named "MyApp".
I would create a Podfile with almost the same content as above:
use_frameworks!
target 'MyApp' do
pod 'geopackage-ios', '~> 7.2.1'
end
Then, I'd run pod install.
Next, I would install PodBuilder, create an empty Git repository (which PodBuilder requires for some reason), initialize PodBuilder, and start the build task:
sudo gem install pod-builder
git init
pod_builder init
pod_builder build geopackage-ios
The build will fail, however, with errors like these written to /tmp/pod_builder/pod_builder.err:
Undefined symbols for architecture arm64:
"_PROJ_WEB_MERCATOR_MAX_LAT_RANGE", referenced from:
+[GPKGTileBoundingBoxUtils toWebMercatorWithBoundingBox:] in GPKGTileBoundingBoxUtils.o
+[GPKGTileBoundingBoxUtils boundDegreesBoundingBoxWithWebMercatorLimits:] in GPKGTileBoundingBoxUtils.o
-[GPKGTileDao isXYZTiles] in GPKGTileDao.o
-[GPKGTileGenerator adjustXYZBounds] in GPKGTileGenerator.o
"_PROJ_UNDEFINED_CARTESIAN", referenced from:
-[GPKGSpatialReferenceSystemDao createIfNeededWithSrs:andOrganization:andCoordsysId:] in GPKGSpatialReferenceSystemDao.o
"_PROJ_AUTHORITY_NONE", referenced from:
-[GPKGSpatialReferenceSystemDao createIfNeededWithSrs:andOrganization:andCoordsysId:] in GPKGSpatialReferenceSystemDao.o
[…]
This seems to be a problem with the geopackage-ios pod itself, which can be fixed by cloning our own version of the repo …
cd ..
git clone --branch 7.2.1 https://github.com/ngageoint/geopackage-ios.git
…, installing the pods …
cd geopackage-ios
pod install
… manually copying the proj-ios source files …
cp -r Pods/proj-ios/proj-ios geopackage-ios
…, and opening the geopackage-ios.xcodeproj to reference the proj-ios files in the geopackage-ios group inside that project.
Then telling CocoaPods to use our local version of the pod …
use_frameworks!
target 'MyApp' do
pod 'geopackage-ios', :path => '../geopackage-ios'
end
…, reinitializing PodBuilder …
cd ../MyApp
pod_builder deintegrate
pod deintegrate
pod install
pod_builder init
… and allowing PodBuilder to use local pods by editing the ./PodBuilder/PodBuilder.json file:
{
…,
"allow_building_development_pods": true,
…
}
Then, one can try to rebuild:
pod_builder build geopackage-ios
This time, the build will fail with a different error:
The following build commands failed:
CompileC /tmp/pod_builder/build/Pods.build/Release-iphoneos/sf-proj-ios.build/Objects-normal/arm64/SFPGeometryTransform.o /tmp/pod_builder/Pods/sf-proj-ios/sf-proj-ios/SFPGeometryTransform.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'sf-proj-ios' from project 'Pods')
(1 failure)
The SFPGeometryTransform.m file, however, looks fine.
The full build log is available here.
Third Approach: Using Rome
The third approach would be to use cocoapods-rome.
To use it, one would install Rome …
sudo gem install cocoapods-rome
…, get rid of the PodBuilder stuff …
pod_builder deintegrate
pod deintegrate
…, quickly adjust the Podfile:
use_frameworks!
platform :ios, '13.0'
plugin 'cocoapods-rome', { :pre_compile => Proc.new { |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '5.0'
end
end
installer.pods_project.save
},
dsym: false,
configuration: 'Release'
}
target 'MyApp' do
pod 'geopackage-ios', :path => '../geopackage-ios'
end
… and install the pods:
pod install
This, however, will fail with the exact same error as PodBuilder.
Can anyone give me some advice on any of these approaches? Or does anyone perhaps have a whole different idea on how to build such a framework?
(EDIT: It seems like the PROJProjectionTransform.h file imported to SFPGeometryTransform.m cannot be found. Anyway, I don't think these approaches are expedient. So any help is highly appreciated.)
Solved the problem by simply feeding all the aggregated source files from the pod installation into a new static library, then using either the lipo command to make a fat binary out of it or creating an Xcode framework from it (as described here). The compiled framework could then be used to create another framework built on top of it.

Importing GoogleWebRTC pod fails: module 'GoogleWebRTC' not found

I am currently working on a Kotlin multiplatform and am trying to interface with the GoogleWebRTC pod.
The pod exists, I was able to import it in a separate project (without Kotlin multiplatform). I can see the .framework is created in my build directory, however when doing a gradle sync or building from Xcode, I get the following error:
Exception in thread "main" java.lang.Error: /var/folders/hv/9cx28nxx4gz9hj_m86bp5rx40000gn/T/tmp362966650322311128.m:1:9: fatal error: module 'GoogleWebRTC' not found
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:67)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:13)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:499)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:264)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:72)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:19)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:37)
Execution failed for task ':shared:cinteropGoogleWebRTCIosArm64'.
> Process 'command '/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
AFNetworking seems to work fine, but adding the WebRTC pod seems to break the project.
Am I missing a limitation of Kotlin multiplatform or something?
This is my build.gradle.kts:
cocoapods {
// Configure fields required by CocoaPods.
summary = "Some description for a Kotlin/Native module"
homepage = "Link to a Kotlin/Native module homepage"
// You can change the name of the produced framework.
// By default, it is the name of the Gradle project.
frameworkName = "shared"
ios.deploymentTarget = "10.0"
pod("GoogleWebRTC", "~> 1.1")
pod("AFNetworking", "~> 4.0.0")
}
I was able to reproduce this issue but I didn't figure out the reason why.
It seems a there's something wrong with GoogleWebRTC pod and the Kotlin-native/cocoapods integration.
I've opened an issue here.
We have an official help.
It seems that the frameworks name is different from the pod name. So a possible solution could be that:
kotlin {
cocoapods {
[...]
pod("GoogleWebRTC", moduleName = "WebRTC", version = "~> 1.1")
[...]
}
[...]
}
I tried it and it works.

Flutter IOS cant find ‘Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig’

I have a problem while building my flutter application for ios on bitrise it always says that it finds a specific folder in the project . I will share some of the messages I have . Can you guys help me fix that . Thank you!
[19:24:07] $ set -o pipefail && xcodebuild “-workspace” “/Users/vagrant/git/ios/Runner.xcworkspace” “-scheme” “Runner” “-configuration” “Debug” “COMPILER_INDEX_STORE_ENABLE=NO” “archive” “-archivePath” “/var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/__archive__385528033/Runner.xcarchive” “-destination” “generic/platform=iOS” | xcpretty
:x: error: /Users/vagrant/git/ios/Flutter/Debug.xcconfig:1: could not find included file ‘Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig’ in search paths (in target ‘Runner’ from project ‘Runner’)
:x: error: /Users/vagrant/git/ios/Flutter/Debug.xcconfig:1: could not find included file ‘Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig’ in search paths (in target ‘Runner’ from project ‘Runner’)
:x: error: /Users/vagrant/git/ios/Flutter/Debug.xcconfig:1: could not find included file ‘Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig’ in search paths (in target ‘Runner’ from project ‘Runner’)
:x: error: Unable to load contents of file list: ‘/Target Support Files/Pods-Runner/Pods-Runner-frameworks-Debug-input-files.xcfilelist’ (in target ‘Runner’ from project ‘Runner’)
:x: error: Unable to load contents of file list: ‘/Target Support Files/Pods-Runner/Pods-Runner-frameworks-Debug-output-files.xcfilelist’ (in target ‘Runner’ from project ‘Runner’)
:x: error: Unable to load contents of file list: ‘/Target Support Files/Pods-Runner/Pods-Runner-resources-Debug-input-files.xcfilelist’ (in target ‘Runner’ from project ‘Runner’)
:x: error: Unable to load contents of file list: ‘/Target Support Files/Pods-Runner/Pods-Runner-resources-Debug-output-files.xcfilelist’ (in target ‘Runner’ from project ‘Runner’)
Last lines of the Xcode’s build log:
User defaults from command line:
IDEArchivePathOverride = /var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/__archive__385528033/Runner.xcarchive
Build settings from command line:
COMPILER_INDEX_STORE_ENABLE = NO
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
error: /Users/vagrant/git/ios/Flutter/Debug.xcconfig:1: could not find included file ‘Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig’ in search paths (in target ‘Runner’ from project ‘Runner’)
error: /Users/vagrant/git/ios/Flutter/Debug.xcconfig:1: could not find included file ‘Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig’ in search paths (in target ‘Runner’ from project ‘Runner’)
error: /Users/vagrant/git/ios/Flutter/Debug.xcconfig:1: could not find included file ‘Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig’ in search paths (in target ‘Runner’ from project ‘Runner’)
error: Unable to load contents of file list: ‘/Target Support Files/Pods-Runner/Pods-Runner-frameworks-Debug-input-files.xcfilelist’ (in target ‘Runner’ from project ‘Runner’)
error: Unable to load contents of file list: ‘/Target Support Files/Pods-Runner/Pods-Runner-frameworks-Debug-output-files.xcfilelist’ (in target ‘Runner’ from project ‘Runner’)
error: Unable to load contents of file list: ‘/Target Support Files/Pods-Runner/Pods-Runner-resources-Debug-input-files.xcfilelist’ (in target ‘Runner’ from project ‘Runner’)
error: Unable to load contents of file list: ‘/Target Support Files/Pods-Runner/Pods-Runner-resources-Debug-output-files.xcfilelist’ (in target ‘Runner’ from project ‘Runner’)
** ARCHIVE FAILED **
You can find the last couple of lines of Xcode’s build log above, but the full log is also available in the raw-xcodebuild-output.log
The log file is stored in $BITRISE_DEPLOY_DIR, and its full path is available in the $BITRISE_XCODE_RAW_RESULT_TEXT_PATH environment variable
(value: /Users/vagrant/deploy/raw-xcodebuild-output.log)
Archive failed, error: exit status 65
| |
±–±--------------------------------------------------------------±---------+
| x | xcode-archive#2 (exit code: 1) | 21.44 sec|
Run 'pod install' on the ios folder in your flutter project.

Project stops building when adding a new test target

I want to create a test target for my app
Before adding the test target, the app builds and runs fine
When I add the test target this is what is displayed when i try to build
GenerateDSYMFile /Users/dev1/Library/Developer/Xcode/DerivedData/MyApp-apigviljomlmendsdvrgealzkevw/Build/Products/Debug-iphoneos/MyApp\
Tests.xctest.dSYM
/Users/dev1/Library/Developer/Xcode/DerivedData/MyApp-apigviljomlmendsdvrgealzkevw/Build/Products/Debug-iphoneos/MyApp\
Tests.xctest/MyApp\ Tests
cd /Users/dev1/Dev/IOSworkspace/MyApp
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil
/Users/dev1/Library/Developer/Xcode/DerivedData/MyApp-apigviljomlmendsdvrgealzkevw/Build/Products/Debug-iphoneos/MyApp\
Tests.xctest/MyApp\ Tests -o
/Users/dev1/Library/Developer/Xcode/DerivedData/MyApp-apigviljomlmendsdvrgealzkevw/Build/Products/Debug-iphoneos/MyApp\
Tests.xctest.dSYM
error: unable to open executable '/Users/dev1/Library/Developer/Xcode/DerivedData/MyApp-apigviljomlmendsdvrgealzkevw/Build/Products/Debug-iphoneos/MyApp
Tests.xctest/MyApp Tests'
How do I fix it ?
The answer is... :
The Mach-O Linker flag in the test target was set to "executable" instead of "bundle".
as found on this page: https://stackoverflow.com/a/19325817/2136812

Resources