I just installed from pkg the SDK 3.7 for Facebook.
I see that I need to put there a value for FacebookAppId. However I have 2 apps: one for testing and one for production.
Since I need to support variables for Debug and Release, I am using an Environment file which determines the value based on the configuration value. (Debug or Release)
How can I "tell" the SDK to use the relevant one for each release type, without changing it manually when building it?
I didn't check in the source code. Just the compiled one.
Is there a way to do it?
You can use the Preprocessor macros over here..
How to use it :
Go to Build settings of your project.
Search "Preprocessor macros". Here define your macros like for eg FBDebugAPPID for debug moed & FBReleaseAPPID for release mode.
FBSettings class used to override the default facebook AppId.
Then after add below code in your delegate method..
#if defined(FBDebugAPPID)
**Use your debug app id**
[FBSettings setDefaultAppID:#"DEBUGAPPId"]
#elif defined(FBReleaseAPPID)
**Use your release app id**
[FBSettings setDefaultAppID:#"RELEASEAPPId"]
#endif
Hope it resolve your problem..
You can change you enviornment.plist variables by adding a run script build phase
To add a Run Script Build Phase in Xcode
Select your application target in your project, then select "Build Phases".
In the menu bar, click "Editor", select "Add Build Phase", and then click on "Add Run Script Build Phase".
You should now see a Run Script section in the middle of your Build Phase options, as shown above.
Inside the body of the Run Script Build Phase, paste in the script.
#!/bin/bash
if [ "${CONFIGURATION}" = "Release" ]; then
/usr/libexec/PlistBuddy -c "Set :FacebookAppID 321" "$INFOPLIST_FILE"
else
/usr/libexec/PlistBuddy -c "Set :FacebookAppID 321" "$INFOPLIST_FILE"
fi
Here's a simpler approach,
Recent Xcode project templates already have a DEBUG=1 macro defined for the Debug build configuration.
You can use it in combination with #ifdef
#ifdef DEBUG
#define FACEBOOK_APP_ID #"FB_DEVELOPMENT_ID"
#else
#define FACEBOOK_APP_ID #"FB_PRODUCTION_ID"
#endif
Related
I am using this command to build my solution using x64 Native Tools Command Prompt for VS2022:
devenv D:\Dev\Projects\wscc.sln /build "Release|x86"
How do I disable / suppress warnings being output in the console?
I define Unused local variable in my vb project in VS 2022 for test and it outputs the warning 42024 in my console after building with devenv solution.sln /build Release as shown in the picture below.
From devenv doc, there’s no supported parameter like NoWarn to suppress warnings .But i find here’re 2 workarounds to disable / suppress warnings being output in the console.
1 The Compile tab of the Project Designer page allows you to turn warnings on and off. Select the Disable All Warnings check box to disable all warnings .Path:right click project and select Properties.
Or you can select specified waring type(e.g: Unused local variable) and set it to None that will disable Unused local variable warning being output in console. For more information, please refer to doc
Or In Solution Explorer, open the right-click or shortcut menu for the project, and then choose Edit .vbproj. add one or more warning numbers as the value of the element.
For example(with two compiler warnings suppressed)
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<NoWarn>42022,42024 </NoWarn>
</PropertyGroup>
2 use -nowarn For example: The following code compiles Program.vb and does not display any warnings.
I have one ESP-IDF application and two hardware boards. I use a preprocessor definition to control which hardware board version to build. For now, I'm modifying the config in the sdkconfig file via menuconfig. But I would like to build both versions at once from a script, or build only one specific config without the manual process of menuconfig.
I have a header that looks like this, and works when HW_VER is set correctly:
#if HW_VER == 2
#define BTN_GPIO 9
#elif HW_VER == 3
#define BTN_GPIO 10
#endif
And from the a script I would like to build each by selecting a value for HW_VER, for example:
idf.py build -DHW_VER=2
idf.py build -DHW_VER=3
The idf.py build command runs cmake and ninja. I'm new to cmake, so perhaps there is a natural way to do this?
I would also like to build release and debug builds, turn on/off memory debugging etc. from the command line.
I've tried idf.py build -DHW_VER=2 but I've learned that these vars are only sent to cmake and not to the preprocessor. The HW_VER macro remains undefined.
Using add_definitions() in my CMakeLists.txt can set HW_VER, but doesn't help me make different builds from the same files.
Using a config variable like CONFIG_HW_VER in the sdkconfig works to control builds using menuconfig but I don't see a way to automate this.
I've considered modifying the configuration variable, CONFIG_HW_VER in the sdkconfig file programmatically, but this file is under source control, and it is auto generated by menuconfig, so that doesn't seem wise.
Similarly I can modify the CMakeLists.txt file programmatically, but that file is also under source control, and isn't a trivial format.
I use two ways to feed custom configurations into an ESP IDF project.
Firstly, the light weight stuff like preprocessor definitions from the environment are quite simple. You have to configure CMakeLists.txt file (the one in project root) to pass variable values from environment into the build process. For example, to create something equivalent to preprocessor definitions -DMY_NUMBER=123 and -DMY_STRING="abc" add this somewhere before the "project" line:
add_compile_definitions(MY_NUMBER=$ENV{MY_NUMBER})
add_compile_definitions(MY_STRING=\"$ENV{MY_STRING}\")
...
project(myproject)
Assuming you're working in Bash, build with:
$ MY_NUMBER=123 MY_STRING="abc" idf.py build
or (for a slightly more "sticky" enviroment):
$ export MY_NUMBER=123 MY_STRING="abc"
$ idf.py build
You can use cmake to add more advanced logic, e.g. setting default values in case the environment doesn't set anything.
Secondly, the more powerful configuration tool for ESP IDF is the menuconfig target and sdkconfig file. As you've already noticed, playing with sdkconfig directly is not so easy. In my projects I consider this a generated temporary file and I never commit it to git. Instead I delete it. When sdkconfig is missing, idf.py will take file sdkconfig.defaults, copy it into sdkconfig and work with this. That is your best mechanism for supporting different hardware configurations - no sdkconfig and instead different variants of sdkconfig.defaults for each hardware you wish to support.
As an example, assume you have two different HW versions described in sdkconfig.defaults.hw_ver1 and sdkconfig.defaults.hw_ver2 and you wish to build for HW ver2 configuration:
$ rm sdkconfig && cp sdkconfig.defaults.hw_ver2 sdkconfig.defaults
$ idf.py reconfigure
Now you can build for this configuration like you usually would:
$ idf.py build
When you wish to build for the other FW configuration, re-execute the previous commands with sdkconfig.defaults.hw_ver1
All this is rather thoroughly documented in the Build System documentation, so feel free to dig in.
Simply i have two frameworks from a payment provider, they provide Debug and Release frameworks, to be used for different environments.
I was trying to configure/find out on the web of a way that i can configure the import of both of them in one scheme, and depending on the Build Configuration it will switch between Debug and Release framework.
I played with Framework Search path for example Debug to have debug url to framework, and the same for Release to link to release framework url to file.
Im looking for something more usable and easy such as run script, or stying away from manual import for each build configuration.
Note: Framework has the same name, as well as the framework is build with objective-c without single header import.
You can try below approach,
Create a new folder "Frameworks" in the project directory where .xcodeproj exists.
Place release framework in /Frameworks/Release/arm64/
Place debug framework in /Frameworks/Debug/x86_64/
Paste below script in Build Phases -> Run Script:
cp -r "$PROJECT_DIR/Frameworks/$CONFIGURATION/$ARCHS" "$PROJECT_DIR/"
rm -dfR <Name of the framework> && \
cp -pRP "$ARCHS" <Name of the frameowrk> && \
rm -rf "$ARCHS"
not sure if it suits your needs, but you can try
#if DEBUG
import debugFramework
#else
import releaseFramework
#endif
I have some code in a project which should never be used in the release build, but is useful when testing. I'd like to do something like this:
#ifdef DEBUG
// Run my debugging only code
#endif
Where do I add the DEBUG setting in Xcode 4? I tried putting it in the "Edit Scheme" under Run MyApp->Arguments Passed On Launch, but it didn't work. Alternatively, is there a flag already available for this?
In recent Xcode project templates there’s already a DEBUG=1 macro defined for the Debug build configuration (in the Preprocessor Macros section). You can test it using the #if preprocessor directive.
I usually add my -DDEBUG=1 to the OTHER_C_FLAGS section in my XCode 4 project's build settings.
And yes, they can even discriminate between Debug / Release / ADHOC / Store builds.
I have created a Command Line Utility C++ tool in XCode using Objective-C. I want the version number to be displayed in the Info of the created executable. So I have added the version number 1.0.0.0 in the Current Project Version field in the Build settings. However, when I build it, the version number does not get added to the created 'Unix Executable File'.
Am I missing something?
Thanks for the help.
Unfortunately, Xcode will not embed the current project version into the executable by itself, as of version 3. I'm not sure if this has changed in Xcode 4.
I ran into this problem a couple of years ago. It turns out that:
Version numbers displayed in the Finder come from applications’ Info.plists. In the case of an application bundle, Info.plist is a file. In the case of an executable, it must be embedded in a __TEXT section. The format of the Info.plist is the same either way.
Xcode does not have one-click support for embedding Info.plists into executables, but it is possible.
Xcode doesn’t preprocess Info.plist files unless they’re going into an application bundle (e.g. to insert the value of CURRENT_PROJECT_VERSION).
I hacked up a solution, but it’s unpolished and probably doesn’t represent best practices.
First, I created a new, stock Info.plist file called Info_template.plist. I set CFBundleVersion to ${CURRENT_PROJECT_VERSION}, and CFBundleShortVersionString to ${CURRENT_MARKETING_VERSION}.
Then, I added a Run Script phase called “Preprocess Info.plist” at the beginning of the build, using /bin/sh as the shell, with this script:
set -u
if ! [[ ${CURRENT_PROJECT_VERSION:-""} && ${CURRENT_MARKETING_VERSION:-""} ]]; then
echo "Version numbers are not set" >&2
exit 1
fi
# Ghetto environment variable expansion, since Xcode does not appear to have built-in expansion for arbitrary files
{ echo "cat <<EOF"
cat ${SRCROOT}/Info_template.plist
echo "EOF"
} | sh > ${DERIVED_FILES_DIR}/Info.plist
I added $(DERIVED_FILE_DIR)/Info.plist to its output files.
Then, I opened the target’s build settings, and added this to Other Linker Flags:
-sectcreate __TEXT __info_plist ${DERIVED_FILE_DIR}/Info.plist
This asks the linker to roll the generated Info.plist file into the executable.
Let me know how this works for you, or if I left anything out!