Settings Bundle in xcode for iphone - ios

I'm trying to set my build version and build date in my app in settings bundle following this tutorial.
But I keep getting this error no matter what:
line 9: File Doesn't Exist, Will Create: /Volumes/Work Invalid
Arguments + 1: syntax error: invalid arithmetic operator (error token
is "'t Exist, Will Create: /Volumes/Work Invalid Arguments + 1")
Command /bin/sh failed with exit code 1
Could somebody please help me....
Thanks in advance.

Ok , I found the mistake : when we post, revers quotes are use to formate the message. So, please replace all  by a reverse quote `
echo "#define BUILD_DATE #\"date "+%d/%m/%Y %H:%M"\"" > build.h
build, and check your build.h

My solution is to create a build.h header with the build date (build version is related to build date), and use this from my app to display the App version + build date.
Of course, build.h need to be refresh each time you build your App.
So, here is how I do this :
Select your Targets (where you can set Bundle ID ...) / Build Phases. Go to menu Editor/Add Build Phase/Add Run Script Build Phase. Move the new created line (Run Script) up to the line "Compile sources" (use drag&drop).
open the line "Run script", and replace Type a script... with :
echo "#define BUILD_DATE #\"date "+%d/%m/%Y %H:%M"\"" > build.h
Now each time you will build, build.h will be re-create.
So, now you need to build => you will have your 1st build.h avail at root of your project.
Add it to your project.
Now, import build.h in the VC where you need the information.
Here is how I use it (I have a iboultet to a label)
- (void)viewDidLoad
{
[super viewDidLoad];
//cf http://stackoverflow.com/questions/3015796/how-to-programmatically-display-version-of-target-in-iphone-app-xcode
NSString * appVersionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:#"CFBundleShortVersionString"];
self.version.text = [NSString stringWithFormat:#"v %# %#", appVersionString,BUILD_DATE];
}

Related

How to fix meson generating an incorrect linker flag (--subsystem console)

I've created a simple project to get myself accustomed to meson, but the build keeps failing.
This is what I did (to set up the environment, and to build):
set CC=clang
set CC_LD=lld
set CFLAGS="--target x86_64-pc-windows-msvc"
meson build
cd build
ninja
My meson.build is as follows:
project('EtaClient', 'c')
src = ['src/main.c', 'src/linkedlist.c']
executable('EtaClient', src)
target = 'x86_64-pc-windows-msvc'
While building, I get the following errors (the obj files are built successfully, but they're not linked and thus the exe isn't built):
LINK : warning LNK4044: unrecognized option '/-subsystem'; ignored
LINK : fatal error LNK1181: cannot open input file 'console.obj'
clang: error: linker command failed with exit code 1181 (use -v to see invocation)
When I look in my build.ninja to see what's going on, I find:
build EtaClient.exe | EtaClient.pdb: c_LINKER EtaClient.exe.p/src_main.c.obj EtaClient.exe.p/src_linkedlist.c.obj
LINK_ARGS = "-Wl,/nologo" "-Wl,/release" "-Wl,/nologo" "-Wl,/DEBUG" "-Wl,/PDB:EtaClient.pdb" "-Wl,--subsystem,console" "-lkernel32" "-luser32" "-lgdi32" "-lwinspool" "-lshell32" "-lole32" "-loleaut32" "-luuid" "-lcomdlg32" "-ladvapi32"
I replace "-Wl,--subsystem,console" with "-Wl,/subsystem:console", and the build compiles successfully, but I have to manually make this edit each time I modify my meson.build.
Could someone tell me why this happens, and how to set up meson to generate the correct flag?
Thanks in advance.
use clang-cl instead of clang and leave out the defintion of the linker when you are on windows
set CC=clang-cl
set CFLAGS="--target x86_64-pc-windows-msvc"
meson build
cd build
ninja
see
https://github.com/mesonbuild/meson/issues/4232

Flutter Picking Wrong Keystore path and giving error key.jks not found

I followed all the steps on the Flutter official site and thought I'd done everything correctly but it is failing to locate the keystore file when I build it.
This is the error message I get showing it taking wrong path instead of
D:\flutterapps\testapp\key.jks:
PS D:\flutterapps\testapp> flutter build apk
Initializing gradle... 1.3s
Resolving dependencies... 4.3s
Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file 'D:\flutterapps\testapp\android\app\ D: lutterappspublishkey.jks' not found for signing config 'release'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
Gradle task 'assembleRelease'... Done 5.3s
Gradle task assembleRelease failed with exit code 1
PS D:\flutterapps\testapp>
On Windows you have to use 2 backslashes to indicate the path separation.
In your key.properties, you should have something like this:
storeFile=D:\\flutterapps\\testapp\\key.jks
You don't need to copy your key.jks file to your flutter project.
modified key.properties file with
storePassword=123456
keyPassword=123456
keyAlias=key
storeFile=key.jks
instead of this
storePassword=123456
keyPassword=123456
keyAlias=key
storeFile=D:\flutterapps\testapp\key.jks
and also moved key.jks to
D:\flutterapps\testapp\android\app\key.jks
as this path shown in error inside terminal
Thanks all.
it's wherever call it from in your build.gradle. insert this:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
and call this in above your android{}:
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
and that key.properties file (which should be in your root android folder) should have this:
storePassword=12345
keyPassword=12345
keyAlias=key
storeFile=/Users/me/somekey.jks
Yeah, for me... I forgot to change my signingConfig to singingConfigs.release in my build.gradle file.
buildTypes {
release {
//CHANGE THIS TO RELEASE
signingConfig signingConfigs.debug
}
}
In build.gradle
Replace
def keystorePropertiesFile = rootProject.file('key.properties')
to
def keystorePropertiesFile = rootProject.file('app/key.properties')
I was having the same issue, I ended up having quotes around my path.
In key.properties, change
storeFile="D:\\mypath\\tokeystore\\key.jks"
to
storeFile=D:\\mypath\\tokeystore\\key.jks

TFS 2018 - Building pre-release packages

I'm using "TFS 2018 Update 2" and trying to build a package marked as a pre-release according to the microsoft semantic
I tried using the .nuspec file inserting the (ex: 1.0.0-beta and changing the Build number format as: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)$(Suffix)
setting the $(Suffix) variable at queue time.
Every attempt failed: the package never contains the suffix, than is never marked as pre-release.
I see that the nuget pack command never contains the suffix (missing "-beta" after "2018.6.12.9"). In my test build $Suffix is set to "-beta":
nuget.exe pack
C:\agent_work\4\s\DotNetClassicLibrary\DotNetClassicLibrary.csproj
-NonInteractive -OutputDirectory C:\agent_work\4\a -Properties Configuration=debug -version 2018.6.12.9 -Verbosity Detailed
The Build task on TFS is:
"DotNetClassicLibrary / Build DotNetClassicLibrary_2018.6.12.9-beta /
Job / NuGet pack"
So I'm sure that the variable is assigned because of the presence of the suffix "-beta" in the path.
Here there is the configuration of the nuget pack task
This is the Build number format
I could reproduce your scenario on my side. In my opinion, Nuget pack task with build number doesn't support character or numbers. You may check this task and try to modify it.
case "byBuildNumber":
tl.debug("Getting version number from build number")
if(tl.getVariable("SYSTEM_HOSTTYPE") === "release")
{
tl.setResult(tl.TaskResult.Failed, tl.loc("Error_AutomaticallyVersionReleases"));
return;
}
let buildNumber: string = tl.getVariable("BUILD_BUILDNUMBER");
tl.debug(`Build number: ${buildNumber}`);
let versionRegex = /\d+\.\d+\.\d+(?:\.\d+)?/;
let versionMatches = buildNumber.match(versionRegex);
if (!versionMatches)
{
tl.setResult(tl.TaskResult.Failed, tl.loc("Error_NoVersionFoundInBuildNumber"));
return;
}
if (versionMatches.length > 1)
{
tl.warning(tl.loc("Warning_MoreThanOneVersionInBuildNumber"))
}
version = versionMatches[0];
break;
As an alternative, you could choose Nuget custom, and specify the
pack command there with parameter -version $(Build.BuildNumber),
I've tried on my side, this works.

Using compiler directive to warn if a file is missing

I have a file that is included on the bundle that has the following name:
databaseX.sqlite
where X is the app's version. If the version is 2.8, the file should be named database2.8.sqlite. I have to be sure to include this file when the app is submitted to Apple.
Is it possible to create a compiler directive to check if the file is in the bundle?
I have tried this, without success
#define fileInBundle [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:[NSString stringWithFormat:#"LoteriaMac%#.sqlite", [[NSBundle mainBundle] objectForInfoDictionaryKey: #"CFBundleShortVersionString"]]]
#if defined(fileInBundle)
#pragma message("file in bundle")
#else
#pragma message("file missing")
#endif
file in bundle is always shown even if the file is not in bundle.
This is not possible. You are trying to use a runtime check inside a compilation directive.
In general, when compiling you cannot know whether there is a file in a bundle or not because the files are usually added to the bundle independently on code, after compiling.
This is the same as checking whether there is a file present in the filesystem on another computer when compiling.
To check that during build time, you can create a custom build script (Build Phases => + button) in your target, something similar to:
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
// there is probably some easier way to get the version than from the Info.plist
INFO_FILE="${APP_PATH}/Info.plist"
VERSION=`/usr/libexec/plistbuddy -c Print:CFBundleShortVersionString "${INFO_FILE}"`
// the file we want to exist
DB_FILE="${APP_PATH}/database${VERSION}.sqlite"
// if the file does not exist
if [ ! -f "${DB_FILE}" ]; then
// emit an error
echo "error: File \"${DB_FILE}\" not found!" >&2;
// and stop the build
exit 1
fi

React Native: Bundle Identifier does not exist

I have a project in React Native that has two different build schemes and uses cocoapods. To compile it I run:
react-native run-ios --scheme="RNProject-(SCHEME_NAME)"
The resulting apps are for example:
./build/Build/Products/Debug/iphonesimulator/RNProject-customer1.app
./build/Build/Products/Debug/iphonesimulator/RNProject-customer2.app
Using the command it builds for one of the build schemes, but not for the other
Xcode always builds the project for both build schemes
Furthermore, build/Build/Products/Debug-iphonesimulator/RNProject-customer1.app/Info.plist exists in that path and the file contains valid CFBundleIdentifier (it matches General > Identity > Bundle Identifier for each of the two build schemes)
Project settings seem to be correct for both schemes (after checking ios/RNProject.xcodeproj/project.pbxproj)
Schema-specific settings are located in ios/Pods/Target Support Files/Pods-RNProject-customer1 and ios/Pods/Target Support Files/Pods-RNProject-customer2
I tried different ways to solve it:
Running sudo react-native
Restarting RN packager
Manually editing Info.plist
Changing build locations
Console:
** BUILD SUCCEEDED **
Installing build/Build/Products/Debug-iphonesimulator/RNProject.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
child_process.js:509
throw err;
^
Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/RNProject.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
at checkExecSyncError (child_process.js:486:13)
at Object.execFileSync (child_process.js:506:13)
at ChildProcess.xcodeBuildProcess.on.code (node_modules/react-native/local-cli/runIOS/runIOS.js:109:36)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:852:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
The problem was with how React Native names labels the executable files.
My Xcode project created two executable files with different names based on Xcode project settings.
React Native on the other hand forms the executable filename from .xcworkspace filename in this script (./node_modules/react-native/local-cli/runIOS/runIOS.js:57):
const inferredSchemeName = path.basename(xcodeProject.name, path.extname(xcodeProject.name));
The two approaches are different and lead to two different executable file names (e.g. Xcode build/Build/Products/Debug-iphonesimulator/RNProject-customer1.app vs React Native build/Build/Products/Debug-iphonesimulator/RNProject.app).
I had set custom value for inferredSchemeNameto match the filename created by Xcode.
My solution is similar:
open ./node_modules/react-native/local-cli/runIOS.js file
change the build path from:
const getBuildPath = function(configuration = 'Debug', appName, isDevice) {
return `build/Build/Products/${configuration}-${isDevice ? 'iphoneos' : 'iphonesimulator'}/${appName}.app`;
};
to
const getBuildPath = function(configuration = 'Debug', appName, isDevice) {
return `build/Build/Products/${configuration}-${isDevice ? 'iphoneos' : 'iphonesimulator'}/${appName}.app`;
};
remove "Build" in the path.
I'm using Xcode-beta 8.2

Resources