iOS build script fails on defaults read command - ios

I have an iOS app with a Build phase script that reads a plist file using the following command:
defaults read "/full/path/to/plist/file" CFBundleExecutable
...but it fails with the following error message:
The domain/default pair of (/full/path/to/plist/file.plist, CFBundleExecutable) does not exist
The full path of the file is correct and I double checked that the file indeed contains the key CFBundleExecutable. I also tried with other keys such as CFBundleName. Running the command both with and without .plist at the end of the full path fails.
I also ran the command in Terminal to see if it works generally, but the command fails there as well.

It turns out that macOS (or the defaults command line tool) seems to have a bug. Folders that are "special" such as Documents and Desktop act differently within the command line environment and as such I observed the following:
If Info.plist is located in a subfolder of Desktop or Documents the defaults read command will fail
As soon as you place Info.plist in any other folder (such as a Developer folder) the same defaults read command will succeed
I am not sure if this is due to the fact that both of these folders require special permissions (macOS asks if an app requests access to either of these) or if it is because they are part of iCloud Drive and perhaps there is some weird symlinking in the background.
Either way, if you run into a similar error, just try to place your project in a subfolder of ~/Developer (or any other non-default, non-special folder).

Related

How does AOSP build system produce .rsp files and how to get them?

According to How does AOSP 9.0 build system link the executable? and What does # mean in this clang command in AOSP build log? , when linking a module, AOSP seems to produce a .rsp file that contains all the obj files that the module need,and pass the file name as a parameter to the link command, for example:
prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++ /OpenSource/Build/Android/9.0.0_r30/soong/.intermediates/bionic/libc/crtbegin_so/android_x86_64_core/crtbegin_so.o #/OpenSource/Build/Android/9.0.0_r30/soong/.intermediates/frameworks/base/libs/hwui/libhwui/android_x86_64_core_shared/libhwui.so.rsp ......
But the .rsp files seems to be removed after build.
The question is, how are these file generated and how to get these files? This may require to learn and modify the build scripts which is out of reach for me.
There maybe the answer for you, read the ninja build manual , in that manual .rsp file mentioned.
https://ninja-build.org/manual.html
the following is info that I copy out.
rspfile, rspfile_content
if present (both), Ninja will use a response file for the given command, i.e. write the selected string (rspfile_content) to the given file (rspfile) before calling the command and delete the file after successful execution of the command.
This is particularly useful on Windows OS, where the maximal length of a command line is limited and response files must be used instead.

Firebase iOS multiple errors when uploading symbol files

I'm trying to setup Firebase Crash Reporting on a Swift project. I'm using Xcode 7.3. Firebase Crash Reporting version is 1.0.7.
After following all steps properly, this is the error I'm getting on Xcode, which isn't allowing my project to run:
http://imgur.com/a/DtHTH
I've also tried to manually upload it using batch-upload, but it gives me an error:
./batch-upload: line 121: FIREBASE_API_KEY: environment variable empty or unset
Explicitly add to environment or set GoogleService-Info.plist (-p)
and Info.plist (-i) flags to extract values from the files.
Try "./batch-upload -h" for details.
Am I missing anything?
To get the Xcode script to work, the invocation in your run script phase needs to look something like
# Replace this with the GOOGLE_APP_ID from your GoogleService-Info.plist file
GOOGLE_APP_ID=1:1234567890123:ios:1234abc567de89
# Replace the /Path/To/ServiceAccount.json with the path to the key you just downloaded
"${PODS_ROOT}"/FirebaseCrash/upload-sym "/Users/yourname/yourproject/Your Project Name-5632e387efda6.json"
The JSON file is a file you've downloaded after creating a service account in the Firebase Console. Here's instructions on how to do that.
To get batch-upload to work, the invocation of that script is more complicated and might look something like
batch-upload -p path/to/your/project/GoogleService-Info.plist -i path/to/your/project/Info.plist path/to/your/service/account/file/Your\ Project\ Name-abc123def456.json path/to/something.dSYM/DWARF/SomeBinaryName
I'm apologize for this process being a bit arduous and arcane--it's definitely something we're aware of and working on fixing!
Answer from: firebase-support#google.com
Can you go over the following items and see it will work:
reset your OAuth credentials, run below command:
rm $HOME/Library/Preferences/com.google.SymbolUpload*
create new service account and make sure it has editor permission
Revise your script into below format:
# Replace this with the GOOGLE_APP_ID from your GoogleService-Info.plist file
GOOGLE_APP_ID=1:my:app:id
# Replace the /Path/To/ServiceAccount.json with the path to the key you just downloaded
"${PODS_ROOT}"/FirebaseCrash/upload-sym "/Path/To/ServiceAccount.json"
Remember to follow the instructions on this link
Please make sure your app id and json file path are correct.
I hope this helps.

'rake' is not recognized as an internal or external command, operable program or batch file

Minutes ago, I downloaded the oscurrency code from github, and I'm installing oscurrency on heroku. Everything seemed to be going perfectly until this command:
rake heroku:install
on the command line, in the directory where I downloaded the source code. I get the error:
'rake' is not recognized as an internal or external command, operable program or batch file.
I'm following the installation instructions at heroku here:
https://github.com/oscurrency/oscurrency/wiki/Heroku-Deployment-Guide
The command "rake heroku:install" is in the third paragraph from the bottom.
The code I downloaded came in a top-level folder called oscurrency. I downloaded that onto my laptop in C:\me\oscurrency. I was issuing the command in that directory when I got the error. I tried issuing the command in the folder C:\me\oscurrency\oscurrency -- same error.
Maybe the command has changed for some reason. Anybody have an idea what's going wrong?
Your problem is most likely that the command prompt is looking for a file named rake.exe and not able to find it because your PATH environment variable is not set to include that directory. I suspect that the rails command won't work either. You should add the ruby install directory (probably C:\Program Files\Ruby on Rails\bin\ to your PATH environment variable.
To do this, open your Computer Properties by right-clicking My Computer and selecting Properties, then find the "Advanced System Settings" link. Click the "Environment Variables" button at the bottom, and paste the path to that directory into the PATH variable, separating it with a semicolon.

Get XCODE to Copy run script converted files to iOS resources bundle?

I have a script which converts wav files to caf files, and I'd like to get them copied to my iOS app automatically. The script looks like this:
Xcode doesn't copy it automatically, and i can't find a way to add it to my Copy Build Phase section. It appears that I need to add a line in the script to copy it directly to the app bundle, or to make the destination the app bundle itself.
What would that script/change be? I'm not sure what shell vars to use for the cp command.
Thanks - Henry
The environment variable you're looking for is "BUILT_PRODUCTS_DIR" and you can find the definition of this, and plenty of other useful Xcode-specific environment variables on this handy Apple documentation page.
And what you'd probably want to do is test for the existence of successfully converted files, and if they exist, then copy those files into the "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}" directory.

How to gain root privileges for iOS app?

I'm currently building an app for jailbroken device, and I need root privileges for my app so that I can perform some tasks ask root. I found a related question : Gaining root permissions on iOS for NSFileManager (Jailbreak). But I am really new to iOS, I don't understand and unable to complete task from step 4. Can anyone make it more detail please?
What step 4 is telling you:
Open the original executable file and delete its contents (the contents are now stored in the previously copied and renamed binary).
is simply that you have moved the executable file for your app to a new filename, and you should replace it with a script with the name of the original executable.
Example
If you build an app named HelloWorld, Xcode will create a HelloWorld.app directory, with a file named HelloWorld inside it, which is executable.
The answer you link to suggests basically renaming the executable to something like MobileHelloWorld.
Once you've done that, create a new file in the HelloWorld.app directory called HelloWorld, and edit it with a text editor to give it this content:
#!/bin/bash
dir=$(dirname "$0")
exec "${dir}"/MobileHelloWorld "$#"
That script will then be run when you tap the app's icon, because in the app's Info.plist file, the name of the executable is
<key>CFBundleExecutable</key>
<string>HelloWorld</string>
and HelloWorld is now a shell script, which invokes MobileHelloWorld, the renamed binary executable file.

Resources