Can't compile plcrashreporter in Xcode 4 - ios

I can use the prebuilt framework provided on the plcrashreporter project page when compiling for the device, but not for the simulator. I have the same problem described here.
I assume the prebuilt framework does not support the simulator's architecture, so I downloaded out the plcrashreporter source. I opened the Xcode project and selected the CrashReporter-iOS-Simulator > iPhone 4.3 Simulator target. When I try to build the project, I get this error:
libtool: unknown option character `D' in: -D__IPHONE_OS_VERSION_MIN_REQUIRED=30000
I get the same error when I try to build most of the other targets (such as for device).
My next step was to try adding the source files to my project. I no longer have the aforementioned problem; however, I get this error when I try to compile:
fatal error: 'crash_report.pb-c.h' file not found [2]
#import "crash_report.pb-c.h"
^
1 error generated.
Command clang failed with exit code 1
The crash_report.pb-c.h file which is mentioned in the error message simply does not exist; I've searched the plcrashreporter source tree and the internet. Therefore, I have to assume that this file is supposed to be generated somehow, but I cannot figure out how.
(Commenting out the line in PLCrashReport.m on which crash_report.pb-c.h is included results in numerous other compilation errors.)

You are correct in that the file does not exist normally, nor does crash_report.pb-c.c exist, which will be your next error after this one.
The crash_report.pb.h and crash_report.pb.c files are generated at compile time through a build rule. You need to add a custom script to your build process to make them.
First, make sure you have protoc-c in the plcrashreporter folder of your project (plcrashreporter-1.0/Dependencies/protobuf-2.0.3/bin/protoc-c). They buried it deep. This is what your script will be running.
Then find your crash_report.proto file. This is the main input that protoc-c will be using to create your missing files. You can take this directory and put it manually into your script, OR you can make a rule to run the script on every *.proto file. I do the latter.
Then edit your build rules to include a script that runs protoc-c with the flag --c_out="${DERIVED_FILES_DIR}" and your crash_report.proto file as two inputs, this will output crash_report.pb-c.h and crash_report.pb-c.c into the same directory as where your crash_report.proto file is, which should already be accessible in your project.
The build rules in Xcode 4 (and above) are under your project's target's build rules tab. You add a build rule before all your other build rules. Here's what mine looks like in Xcode:
You'll probably have to fiddle with the directory

Related

Firebase Crashlytics with Swift Package Manager - crash because of wrong path

I have installed Firebase through the Swift Package Manager for my iOS project, including Crashlytics. I have followed these instructions and added the required script to build phases:
https://firebase.google.com/docs/crashlytics/get-started?platform=ios
So the path for execution is:
"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"
On start up (iPhone simulator), the app crashes with the following error message:
/Users/[path-to-my-project]/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run: No such file or directory Command PhaseScriptExecution failed with a nonzero exit code
I don't understand why it tries to find the crashlytics script in my Xcode project folder and not in the derived data folder at runtime.
I checked the derived data folder and followed the path. Indeed, the Crashlytics run script is at the expected path.
thanks for any hints in the right direction
In the meantime I've found out that the path to the build folder is set globally in the Xcode preferences. For some reason I don't recall, my build folder has always been in my project folder for all projects I ever worked on in Xcode... I know this for sure because I always add the build folder to .gitignore.
To change the build folder to be a subfolder of your project's derived data folder, go to:
Xcode -> Preferences -> Locations -> Advanced and select the first option.
Firebase assumes that this option is selected by default (maybe it is and I'm the weirdo...).

Realm framework error with Strip: Stripping frameworks fatal error: lipo: -remove's specified would result in an empty fat file

I am having an ugly error since I've updated the Realm.framework.
The error is:
Stripping frameworks
fatal error: lipo: -remove's specified would result in an empty fat file
If I select the box for "Run script only when installing" in build phase for the corresponding Run Script, it compiles for testing. However it does not when I try to archive.
Does anyone have a thought on this ?
Thank you,
This error could happen if you didn't follow the installation instructions listed at https://realm.io/docs/objc/latest#installation exactly.
The strip-frameworks.sh build phase is only necessary when using fat frameworks, such as the ones provided by Realm's zip downloads or Carthage with binaries. This error would happen if you're building Realm from source (e.g. with CocoaPods or carthage update --no-use-binaries), because it'll just build the architecture you need.
An extra C++ library was causing the problem. Removing it solved it.

Xcode errors when using phonegap

So im getting a 2 errors when im using phonegap to create a native ios app and im not really sure how to resolve them. Xcode and Objective-C are beyond my knowledge right now so I'm not sure what to do. They state that there are multiple build commands.
Warning: Multiple build commands for output file /Users/gcollins/Library/Developer/Xcode/DerivedData/Hanna_Instruments_App-dcesxqrxziqltacadrozhxjujrgz/Build/Products/Debug-iphonesimulator/hanna-project.app/icon-72.png
Warning: Multiple build commands for output file /Users/gcollins/Library/Developer/Xcode/DerivedData/Hanna_Instruments_App-dcesxqrxziqltacadrozhxjujrgz/Build/Products/Debug-iphonesimulator/hanna-project.app/Default-Portrait~ipad.png
Xcode tells you that you are trying to add into the bundle the same files two/multiple times.
Select your Xcode project file in "Project Navigator". Look for "Copy Bundle Resources" Build Phase, it will show all files included into your project. Delete the duplicate reference.

xcodebuild failure clang:error no such file or directory:

Having a problem when building with xcodebuild. My project/app builds fine with the Xcode - gui. It simply isn't finding/building the libcryptopp library which is part of the build process.
The error is:
clang: error: no such file or directory: '/Users/builder/repo/ioskpay/xcode-cryptopp/cryptopp/build/Release-iphoneos/libcryptopp.a'
This particular file should be derived from another project inside the main app - xcodebuild simply isn't correctly pointing at the right file folder which should be:
~/Library/Developer/Xcode/DerivedData
Any ideas?
To fix this, go to your project settings, go to Targets and select your main project target. Then go to Build phases. Under Target dependencies add the static library project.
This way, when you compile the main project, the static library subproject gets compiled before the main project and your static library will be available.
I had the same problem, but for a resource file .m
I opened target -> build phases -> Compile sources
and I found the file the compiler was tell it can't find duplicated: one with strange icon and the other with a normal icon. I simply removed the one with strange icon and it worked. ( I added the file multiple times and I had a merge conflict before that which made something wrong in the project file)
For your case I think you need to remove the lib from target dependencies list and add it again. This may work for you.
In Xcode Version 9.2 (9C40b) this happened when I drug a bunch of files into the project, some of which were duplicate. Rather than simply not adding the duplicates, it added them again and only the name, not the path.
In Target > Build Phases > Compile Sources each of the duplicates showed with no "...in" after them. Each one caused the clang error.
After removing all of the duplicates that Xcode collected, the project compiled and ran.
It makes you use the Project Navigator instead of managing your source files in the Finder. Then the Project Navigator can't replace duplicates like any decent file management system (ahem Finder). 🤨
My xCode info is:
I faced similar errors during xcode building projects (native swift, flutter, react native, native script) in which I got error messages related to clang compilar. Errors like:
clang-4.0: error: no such file or directory: '/Users/xxxxxxxx/Library/Developer/Xcode/DerivedData/xxxxxxxxxxxxxxx/Index/Data Store'
clang-4.0: error: cannot specify -o when generating multiple output files
others
Despite of errors related with DerivedData for native apps can be fixed by deleting the directory and, eventually, restart xCode and even restart the machine... in this case, you will see that after deleting the directory and start building process again, the error comes back.
Then, is the moment of checking the clang installation by running clang --version. The normal output will be something like:
as you can see the InstalledDir is incorrect for xCode. In my case, some days ago I needed to install Anaconda app (R, Python, etc) and, now, I remember that I had to install some dependencies and one of them was clang and its installation was altered.
To fix this problem (in my case that I will not need anaconda any more): (edited)
1.- Delete anaconda and all its dependencies (I recommend to use App Cleaner).
2.- Re-install xCode
After reinstalling xCode, if you type again clang --version, you'll get this:
More info at: https://github.com/flutter/flutter/issues/32457#issuecomment-496161092
Hopefully, this info helps some else.
Best
Ok so by simply adding the correct -target -configuration and -scheme parameters I got this to run correctly. However due to my running this in Jenkins for autobuild purposes it still doesn't work as I'd like - getting stuck in exactly the same place. It's odd because I have the exact same code being built in another job that isn't having this problem. There is no rhyme or reason for it at this point. I will keep shooting rubber bands at it and update when I have an answer...
Sometimes Xcode performs weird.
You have to find that static library project e.g.. "filename.a" under 'Link Binary With Libraries' in Build Phase and then remove it and add it again.
I had the same problem while I was archiving my target. I removed the library and the build succeeded.
For me it was because I had removed a package or pod. I ran pod install and it fixed it
Look for the missing file in the Xcode project i.e the files may be deleted or miss placed.
add the missing files to the xcode, then everything will work fine.
Run this command :
$ conda deactivate

Unable to build iOS project using command line but fine via Xcode interface

I have an Xcode project. When in Xcode interactively, I am able to run/build/archive using the Ad_Hoc_Distribution configuration but when I run:
/usr/bin/xcodebuild -configuration Ad_Hoc_Distribution clean build
inside my project, I get an error:
/Users/esg/Documents/app-ios/testapp/testapp/AppDelegate.h:14:9: fatal error: 'RestKit/RestKit.h' file not found
#import <RestKit/RestKit.h>
^
1 error generated.
What would cause this to fail from the command line when it works via the interface?
My team has encountered this same issue. After upgrading from Xcode 4.3.2 to 4.4.1, files that used to be found correctly no longer do.
By comparing the output of xcodebuild vs. Xcode's own build logs, and then comparing vs. our Xcode 4.3.2 build logs, we discovered that xcodebuild and Xcode IDE do not build with the same header dependencies anymore. When xcodebuild runs a 4.4.1 build, it uses an incorrect base directory for include files, which does not include the entire current path leading to the .xcodeproj directory. The last two directory nodes in the folder path appear to be truncated.
But building from Xcode IDE worked fine.
We worked around this problem by adding the correct header paths, as Xcode reports it, as an additional header dependency:
$(SRCROOT) is what seems to be interpreted incorrectly when xcodebuild is employed. It should contain the two subdirectories I inserted in the second line.
I can only conclude that there is a ripe and spicy new bug in the xcode/xcodebuild interaction, but you can fix your header dependencies to at least get things compiling.
See my own issue regarding this.
xcodebuild header files not found in ReskIt
I resolved it by changing nothing, but by adding a workspace and a scheme and used it to build. All the header settings were the same as it is being set for Xcode GUI to build.

Resources