React-native & Xcode: Project builds but cannot create archive - ios

I'm using mobx & decorators.
The project runs fine in the simulator via "npm run ios" and it also builds in Xcode without errors.
When I try to create an archive it fails with:
"SyntaxError in /mobx-stores/UserStore.js: Method has decorators, put the decorator plugin before the classes one."
Here's my bable.rc:
{
"presets": [
"babel-preset-react-native-stage-0/decorator-support",
"react-native"],
"env": {
"development": {
"plugins": [
"transform-react-jsx-source",
"transform-decoratorslegacy"
]
}
}
}
Versions in package.json:
"react": "16.2.0",
"react-native": "0.52.0",
"mobx": "^4.0.1",
"babel-preset-react-native-stage-0": "^1.0.1",
"babel-preset-react-native-stage-0": "^1.0.1",
I've tried many work arounds without success.
Bottom line: Is it possible (or advisable) to use decorators in a react-native project used with Xcode?
Any info would be much appreciated!

Sigh,
I missed the fact that my bable.rc uses 'env' for plugins and I guess an archive build will not set the 'dev' environment variable.
Fixed up the bable.rc and it now creates an archive.

Related

RNAppAuth, iOS build failed, Unknown type name 'namespace', react-native-app-auth

I am trying to add react-native-app-auth to existing, but quite fresh project with Expo.
I'm following your setup guide, so doing following steps:
yarn add react-native-app-auth#2.2.0 --dev
Add pod 'AppAuth', '>= 0.91'
cd iso && pod install
react-native link (EDIT: from root path of the project)
And I get:
rnpm-install info Linking react-native-app-auth ios dependency
rnpm-install WARN ERRGROUP Group 'Libraries' does not exist in your Xcode project. We have created it automatically for you.
rnpm-install info Platform 'ios' module react-native-app-auth has been successfully linked
which looks fine.
Then when I build in XCode i get the following error:
After searching the web I found it may be connected with compilator I changed it use Objective-C++:
and now I get more errors:
I also tried:
Changing Target version to 9.0
Doing it again
Praying 🙏
Nothing helps :( Xcode Version 9.3 (9E145)
app.js
{
"expo": {
"sdkVersion": "26.0.0",
"ios": {
"bundleIdentifier": "com.xxx.xxx",
"publishBundlePath": "ios/mobile-xxx/Supporting/shell-app.bundle",
"publishManifestPath": "ios/mobile-xxx/Supporting/shell-app-manifest.json"
},
"android": {
"package": "com.xxx.xxx"
},
"name": "mobile-xxx",
"slug": "mobile-xxx",
"version": "0.1.0",
"isDetached": true,
"entryPoint": "./index.js",
"detach": {
"scheme": "exp997ce9c6b4fd43cfa14f4eede063ecf5",
"iosExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/ios-v2.4.4-sdk26.0.0-3bd935c7-cdd3-4002-8e44-4df857a675f2.tar.gz",
"androidExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/android-v2.4.0-sdk26.0.0-e63d9209-070c-4118-b06b-c60e82da0b66.tar.gz"
}
}
}
package.js
{
"name": "mobile-xxx",
"version": "0.1.0",
"private": true,
"devDependencies": {
"jest-expo": "26.0.0",
"react-native-app-auth": "2.2.0",
"react-test-renderer": "16.3.0-alpha.1"
},
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"test": "jest"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"expo": "^26.0.0",
"prop-types": "^15.6.1",
"react": "16.3.0-alpha.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-26.0.0.tar.gz",
"react-native-app-auth": "^2.2.0",
"react-native-router-flux": "^4.0.0-beta.28",
"react-redux": "^5.0.7",
"redux": "^3.7.2"
}
}
UPDATE: I have just setup a fresh Expo app following this guide and have exactly the same error. 😞
The problem is that there is an import in header search paths, which searches in the whole /ios folder:
$(SRCROOT)/../../../ios/**
If you happen to use Expo and CocoaPods, there will be boost-for-react-native as a dependency inside your Pods folder. In fact, any package depending on boost will cause this problem. XCode tries to build boost as well, but it has some non-ObjC files, so it will fail.
In order to fix the issue:
Open RNAppAuth.xcodeproj, switch to Build Settings tab and search for header search paths. Replace line $(SRCROOT)/../../../ios/** with
"$(SRCROOT)/../../../ios/YOUR_PROJECT_NAME",
"$(SRCROOT)/../../../ios/Pods/AppAuth/**",
Please note that these changes will disappear after using npm install (or yarn). To make these changes permanent, you can use patch-package.
Edit: this issue has been fixed, using the latest version of the package should work now.

Ionic/Cordova Plugins not included in Xcode project

I have a Ionic v1 project and I have an issue when building on ios. Almost all of my cordova plugins are not added in the Xcode project in the left column under the folder plugin.
Cordova version : 6.2.0
Xcode version : 8.3.3
I have done :
cordova platforms rm ios
cordova platforms add ios
cordova build ios
It compiles fine but the plugin files are not added in my Xcode project (when I run the app, I have a lot of XXXPlugin class CDVXXXX (pluginName: XXX) does not exist).
The plugin files are added in the platforms/ios/MyProject/Plugins (I can see the different folders and the files .h et .m).
But when I open the Xcode project, there are only the files of one of my plugins (Branch.io), all the others are not here (cordova-plugin-camera, cordova-plugin-geolocation, cordova-plugin-inappbrowser, etc.)
In my config.xml, seems ok (example : <plugin name="cordova-plugin-geolocation" spec="~2.4.3" />)
In platforms/ios/MyProject/config.xml, seems ok as well (example : <feature name="Geolocation"><param name="ios-package" value="CDVLocation" /></feature>)
I could add them manually but it takes time and every time I remove and re-add platform, I would have to do it again.
I don't know what to do, any ideas of what I'm doing wrong ? Why is XCode stopping importing plugin files after the first one (BranchSDK which appears to be the first one in alphabetical order by the way) ?
My package.json :
{
"name": "myapp",
"version": "1.1.1",
"description": "myapp: An Ionic project",
"dependencies": {
"grunt-contrib-compress": "^1.3.0",
"grunt-contrib-uglify": "^2.0.0",
"gulp": "^3.5.6",
"gulp-concat": "^2.2.0",
"gulp-minify-css": "^0.3.0",
"gulp-rename": "^1.2.0",
"gulp-sass": "^2.0.4",
"ionic-native-transitions": "^1.0.2",
"moment": "^2.14.1",
"ng2-translate": "^2.2.2",
"plist": "^2.0.1"
},
"devDependencies": {
"angular-translate": "^2.15.2",
"bower": "^1.3.3",
"coffee-script": "^1.10.0",
"grunt-contrib-compress": "^1.3.0",
"grunt-contrib-uglify": "^2.0.0",
"gulp-angular-templatecache": "^2.0.0",
"gulp-ng-annotate": "^2.0.0",
"gulp-useref": "^3.1.2",
"gulp-util": "^2.2.14",
"mv": "^2.1.1",
"shelljs": "^0.3.0"
},
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-console",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard",
"cordova-plugin-network-information",
"cordova-plugin-geolocation",
"cordova-plugin-badge"
],
"cordovaPlatforms": [
"android",
{
"platform": "ios",
"version": "4.1.1",
"locator": "ios#4.1.1"
}
]
}
Thanks
Cordova version : 6.2.0
cordova#6.2.0 was released over 1½ years ago. Try updating to the latest version cordova#7.1.0
Then install the latest iOS platform: cordova platform add ios#latest
Xcode version : 8.3.3
While you're at it, update to Xcode 9 so you can build for iOS 11 / iPhone X.
delete plugins folder, node_module folder and platform/ios folder. Then run "npm install in the project root. The add ios platform

Electron-builder release tries to publish to Github and complains about GH_Token

running the release script without publish option tries to publish the build to GitHub ( and fails while complaining about not being able to find GHToken! )
Error: GitHub Personal Access Token is not set, neither programmatically, nor using env "GH_TOKEN"
Setting "publish": "never" will fail also complaining about not being able to find module electron-publisher-never!
Error: Cannot find module 'electron-publisher-never'
It all happens while the project is built but build scripts exits non-zero!
I'm using the latest version of electron-builder.
my build script:
"build": {
"appId": "eu.armand.[****]",
"copyright": "Copyright © 2017 mim_Armand",
"productName": "[****]",
"mac": {
"publish": "never",
"category": "public.app-category.[****]",
"icon": "assets/icons/mac/icon.icns"
}
Any idea what's going on or if I'm doing it wrong?!
,m
try building with
"build": "electron-builder --publish never"
to never publish.
rename your script to something else.
if the script name is release → publish is set to always
the documentation states this:
CLI --publish option values:
...
If npm script named release, — always.
Add to scripts in the development package.json:
"release": "build"
and if you run yarn release, a release will be drafted (if doesn’t
already exist) and artifacts published.
I solved it this way, because I didn't need to put it in any repository
"build":{
"appId": "XXX",
"productName": "XXX",
"directories":{
"output": "build"
},
"win":{
"target": "nsis",
"publish" : []
}
}
https://www.electron.build/configuration/publish

How to create release channels with electron/electron-builder?

I have an Electron app where I want to introduce parallel release channels: stable, next (for early adopters) and dev (for testing the latest build).
These will have a branch each, with new features appearing first in dev, progressing to next for beta testing and finally moving into stable.
I'm using electron-builder to make these release packages, and I want each to have its own auto-updates - so when I publish a new next release all the users with it get the update.
I want the applications to be independent - a user can have two channels installed and run both at the same time. They'll have different names and different icons.
I can manually set these up in the branches, but really I want to automate this as much as possible - a publish from the next branch should use the right name, icons, IDs and updater without risk of it going to the wrong channel.
Is there a way to do this with electron or electron-builder?
It's possible with electron-builder. I would have several build configurations and tell electron-builder which to use when building.
For example, create file config/beta.json with the following setup:
{
"appId": "com.company.beta",
"productName": "App Beta",
"directories": {
"buildResources": "build/beta" // directory containing your build-specific assets (e.g., beta icons - icon.icns, icon.ico & background.png)
},
"mac": {
"category": "public.app-category.finance"
},
"win": {
"target": [
"nsis"
]
},
"nsis": {
"perMachine": false
},
"publish": [
{
"provider": "s3",
"bucket": "com-app-beta" // dedicated S3 bucket for each build
}
],
}
And duplicate config/beta.json for next.json and current.json (make sure to edit settings accordingly).
In package.json, add the following build scripts (note --em.name=app-beta to overwrite package.json's "name" value):
{
"scripts": {
"build": "build -owl --x64 --config ./config/current.json -p always --em.name=app",
"build-beta": "build -owl --x64 --config ./config/beta.json -p always --em.name=app-beta",
"build-next": "build -owl --x64 --config ./config/next.json -p always --em.name=app-next"
}
}
Run build script when ready to deploy:
npm run build-beta
Using electron-builder version 20.15.1 and MacOS, #Jon Saw's solution needs a minor change because em option is not valid:
"build-beta": "build -owl --x64 --config ./config/beta.json -p always -c.extraMetadata.name=app-beta"

How to resolve Bower dependency version conflicts?

I have a project that depends on both:
jquery ~1.9.1
another project which in turn depends on jquery >=1.7.2
But when I run bower install, it ends up installing jquery 2.0.2.
This seems broken.
How do I either (a) make it correctly solve the constraints or (b) explicitly force a final version to be installed (workaround)?
You can add resolutions to the object in your bower.json file and specify the component name & version to automatically resolve the conflict when running bower commands.
Like this:
{
"name": "project-x",
"private": true,
"dependencies": {
"bootstrap-sass": "~3.3.7",
"modernizr": "~2.8.3",
"jquery": "~1.11.3"
},
"devDependencies": {},
"resolutions": {
"jquery": "~1.11.3"
}
}
Also you can run bower install and when bower will ask for "suitable version" (if interactive mode is on), prefix choice with !, so bower will save your choice into bower.json file.
use --force-latest
enter link description here

Resources