The Problem:
In order to switch between my test/prod APIs, I've been commenting out lines depending on what build I use. Additionally, I cannot find the best way to set custom items for signing of my applications on both platforms' stores (for example: I'd like to include ".dev" in Xcode's Bundle Identifier if I'm using my test build).
What I've Tried:
The Cordova documentation talks about using build.json to declare the necessary information for signing your application. Here for iOS, and here for Android. I tried using that (and even tried just using the flags without a file), but when I build the application, the flags dont seem to be utilized in the build folders for each platform. Here's the build.json
I used.
{
"android": {
"debug": {
"keystore": "../android.keystore",
"storePassword": "android",
"alias": "mykey1",
"password" : "password",
"keystoreType": ""
,
"release": {
"keystore": "../android.keystore",
"storePassword": "",
"alias": "mykey2",
"password" : "password",
"keystoreType": ""
}
},
"ios": {
"debug": {
"codeSignIdentity": "iPhone Developer",
"developmentTeam": "IDENTIFIER",
"packageType": "debug",
"buildFlag": [
"PRODUCT_BUNDLE_IDENTIFIER=org.name.dev.product_name",
"EMBEDDED_CONTENT_CONTAINS_SWIFT=YES",
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
"LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
]
},
"release": {
"codeSignIdentity": "iPhone Developer",
"developmentTeam": "IDENTIFIER",
"packageType": "app-store",
"buildFlag": [
"PRODUCT_BUNDLE_IDENTIFIER=org.name.product_name",
"EMBEDDED_CONTENT_CONTAINS_SWIFT=YES",
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
"LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
]
}
}
}
Here's some output from the CLI when I run cordova run ios --target="iPad-2" --debug
:
Reading build config file:
Building for iPad 2 Simulator
Building project: /path/product_name/platforms/ios/product_name.xcworkspace
Configuration: Debug
Platform: emulator
Adding xcodebuildArg: PRODUCT_BUNDLE_IDENTIFIER=org.name.dev.product_name
Build settings from command line:
CONFIGURATION_BUILD_DIR = /path/product_name/platforms/ios/build/emulator
PRODUCT_BUNDLE_IDENTIFIER = org.name.dev.product_name
SDKROOT = iphonesimulator10.3
SHARED_PRECOMPS_DIR = /path/product_name/platforms/ios/build/sharedpch
Build settings from configuration file '/path/product_name/platforms/ios/cordova/build-debug.xcconfig':
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES
CODE_SIGN_ENTITLEMENTS = $(PROJECT_DIR)/$(PROJECT_NAME)/Entitlements-$(CONFIGURATION).plist
CODE_SIGN_IDENTITY = iPhone Developer
ENABLE_BITCODE = NO
GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1
HEADER_SEARCH_PATHS = "$(TARGET_BUILD_DIR)/usr/local/lib/include" "$(OBJROOT)/UninstalledProducts/include" "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" "$(BUILT_PRODUCTS_DIR)"
OTHER_LDFLAGS = -ObjC
SWIFT_OBJC_BRIDGING_HEADER = $(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h
=== BUILD TARGET CordovaLib OF PROJECT CordovaLib WITH CONFIGURATION Debug ===
So... it LOOKS like build.json is working out, but I can't see where my xcode build arguments are being put!
Am I going about this the right way? Should I dive into hooks or cordova-custom-config
? I'm at a loss.
What I'd like to avoid...
If it's really a must, I can try to handle the different builds with a Gulpfile, but I feel like there's a correct way to do this with Cordova.
I ended up using https://github.com/dpa99c/cordova-custom-config to handle every aspect that build.json
wasn't properly handling.