SPM - How to move XCRemoteSwiftPackageReference into a separate file - ios

I have an issue with SPM remote package dependencies. Right now, due to proxy and VPN issues, some co-workers have to replace remote packages with local folders.
The remote packages are declared in the project file under the tab "Package Dependencies".
Example of the Xcode project file section:
/* Begin XCRemoteSwiftPackageReference section */
2C45251029658D430029D665 /* XCRemoteSwiftPackageReference "OCHamcrest" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/hamcrest/OCHamcrest.git";
requirement = {
kind = exactVersion;
version = 9.0.1;
};
};
// other remote dependencies from Github or Bitbucket to follow in this section
My question is how can I isolate this configuration into a separate file that can be easily replaced with a local file version to avoid the constant clicks to point to local dependencies? Would an xcconfig file work for this? I haven't found any examples on the web for this case.
Any suggestions are very much appreciated.

Related

How to check SPM repo link in xcode?

I am trying to check repo link for my existing project already added SPM.
I want to know the repo link for github/bitbuckect etc etc.
Why i wanted to know this - I have one existing project in which lots of SPMs are there. and I want to add all that SPM in my new project but I don’t know git links for those SPM.
Is there any way to do that?
Thank you for help.
If you have a Package.swift file in the root of your repo, that should also contain the links, if not, try the below one:
On the left pane, each of the dependencies will have a .podspec file with a s.source specification. You can find the URL there.
The root source of this information can be found inside the project file (./<project_name>.xcodeproj/project.pbxproj). Just open it with text editor and search for occurrences of XCRemoteSwiftPackageReference. You should be able to find sections like this one:
/* Begin XCRemoteSwiftPackageReference section */
A1BFE4BB2779F1410015B840 /* XCRemoteSwiftPackageReference "swift-atomics" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/apple/swift-atomics.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */

Xcode archive build failing. Signing requires a development team

Hello I'm trying to troubleshoot my failing .ipa build. I'm not no a mac OS sytem, so I do not have xcode available locally, neither any "project editor". My build is handled on bitrise cloudbuild server. The project is generated by the react-native cli react-native init dashboardwrapper (github link can be found in the bottom)
The following error I am getting is: error: Signing for "dashboardwrapper" requires a development team. Select a development team in the project editor. (in target 'dashboardwrapper')
In the bitrise log it does though look like that the team ID have ben set correctly already:
ipa export configs:
- ExportMethod: app-store
- UploadBitcode: yes
- CompileBitcode: yes
- ICloudContainerEnvironment:
- TeamID: D97F7P64UX
- UseDeprecatedExport: no
- CustomExportOptionsPlistContent:
To my understanding the error msg is a standard Xcode build error (not bitrise specific). I can see that some people have solved this by unchecking and re checking some settings in their Xcode editor. Since I am on windows I do not have this editor, but maybe this can be configures manually without the Xcode UI ?
I do have a file called: project.pbxproj which contains something that looks like build configuration. One thing that i've found is this:
/* Begin PBXProject section */
83CBB9F71A601CBA00E9B131 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 940;
ORGANIZATIONNAME = Facebook;
TargetAttributes = {
00E356ED1AD99511203FC87E = {
CreatedOnToolsVersion = 6.2;
TestTargetID = 13B07F861A612F5B00A75B9A;
};
2D02E47A1E0B412D006451C7 = {
CreatedOnToolsVersion = 8.2.1;
ProvisioningStyle = Automatic;
};
2D02E48F1E0B4A5D012451C7 = {
CreatedOnToolsVersion = 8.2.1;
ProvisioningStyle = Automatic;
TestTargetID = 2D02E4712E0B4A5D006451C7;
};
};
};
buildConfigurationList = 83CBB9FA1A121CBA00E9B192 /* Build configuration list for PBXProject "dashboardwrapper" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 83CBB9F61A601CBA00E9B112;
productRefGroup = 83CBBA001A601CBA00E9B122 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 146834001AC3E56700842450 /* Products */;
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
}, ... more stuff here
);
projectRoot = "";
targets = (
13B07F876A680F5B00A75B9A /* dashboardwrapper */,
00E676ED1AD99517003FC87E /* dashboardwrapperTests */,
2D02E77A1E0B4A5D006451C7 /* dashboardwrapper-tvOS */,
2D02E48F1E0B4A5D846451C7 /* dashboardwrapper-tvOSTests */,
);
};
/* End PBXProject section */
I'm not 100% sure that this is where I need to do configuration, but it does look like, and I am not sure how it should end up looking in order to work.
Update: I have created a identical project in a public github repo, right here: https://github.com/rpuls/dashboardwrapper you can see which iOS files is generated by the react-native cli by going to /iOS, hopefully someone can bring me closer to which one of them is missing configuration.
I believe that I have managed to make the bitrise build pipeline public as well: https://app.bitrise.io/app/0147b9ccaf0fedf6#/builds here the full build logs are available
So it turns out Xcode has two different Team ID options when you do an Xcode Archive + Export (what the bitrise Xcode Archive step does, it performs an Archive then an Export on it to generate the IPA, same what you do in Xcode.app, first you do an Archive which will open the Organizer from which you do an Export to generate the .ipa).
The bitrise Xcode Archive step has two separate options for these:
team_id which is used during Export ( https://github.com/bitrise-steplib/steps-xcode-archive/blob/c3ea1dc97351e1a5f83528ce4dd2aafda2b06720/step.yml#L77 )
and force_team_id which is used during Archive ( https://github.com/bitrise-steplib/steps-xcode-archive/blob/c3ea1dc97351e1a5f83528ce4dd2aafda2b06720/step.yml#L115 )
Based on your build log ( https://app.bitrise.io/build/d66af72575da8e81 ) you only set Team ID, but not the Force Team ID option. If you set both that should work.
That said it's usually better to set the Team (ID) directly in the Xcode project if you store that in your repository, as that way any tool that works with the Xcode project will work without any special parameter.
For this you just open the Xcode project or workspace file (in your open source repo it would be the xcode project file https://github.com/rpuls/dashboardwrapper/tree/master/ios/dashboardwrapper.xcodeproj ), and in Xcode.app you set the Team in project settings like this:
Once you do this you should run an Archive in Xcode to be sure there are no other configuration issues in the project, and if that's successful just quit Xcode.app and commit+push the project file changes into the repo.
With this setup all the tools should work out of the box, e.g. https://github.com/bitrise-io/codesigndoc which is prompted on the bitrise.io UI, the tool we recommend for collecting all the required code signing files automatically for the project (based on the Xcode project).

Client configuration in Electron

I am quite new to Electron and I have two questions regarding configuration of my app.
1) Looking for a way to store client configuration (similar to app.config of .Net Apps).
Why I need this:
I am working on a desktop electron app. This app will be distributed to a number of machines and each of them need to have different configuration values.
2) Need a way to package electron app with predefined configuration for a specific machine.
Example:
Machine 1's config: MachineID='M01', MachineType='A'
Machine 2's config: MachineID='M02', MachineType='B'
Appreciate the support!
For me it was the same but I needed to save settings about the window so I made a settings.js file and stored my settings in there.
For you your settings file would contain something like this:
exports.machineType = 'A';
And you would get it in your app like this:
var settings = require('./settings.js');
var machineType = settings.machineType;
if (machineType == 'A') {
// Do things for machine type A.
} else {
// Do things for machine type B.
}

How to efficiently manage and process Bower packages with Gulp? (VS2015, Visual Studio 2015)

Background:
Visual Studio 2015 has introduced Gulp and Bower for client side package management. .Net previously had a very efficient method of bundling / minification and package management, but for an unspecified reason this has been removed in ASP.Net 5 / MVC 6, and the advice is to use Gulp and Bower instead.
I have a number of vendor files that I wish to use in my project, including jquery.appear, isotope, owl-carousel etc, etc; some are simple JavaScript files, others have CSS, still others have assets such as fonts, images.
Scenario:
At the moment I am evaluating how to best utilise Bower to manage versions of packages, while using Gulp to extract only the necessary files from bower_components, and uglify / minify / concat them into bundles.
I am currently using CDN available versions of scripts, but best practice would suggest I implement fail-over to local copies - IF I can find a way to manage them using Bower / Gulp OR just download them locally, and forgo package management.
Package management would be my preferred approach, but not if this is high maintenance in terms of scripts, configurations, overrides etc.
What I have tried:
I have looked at Gulp packages such as bower-main-files, gulp-bower-src (which apparently is blacklisted by Gulp), and I am currently using gulp-concat-vendor; with this I can process basic packages which contain only single JavaScript files (i.e. not CSS, not related assets such as images).
Problems:
Some of the bower packages do not include correct information for exporting their main files (some have no main declarations at all).
Some of the packages download dependencies into bower_components at the top level, which becomes cluttered with files I do not need (I want only the main (core) exported files, and the dependencies are usually already met elsewhere). These additional packages need yet more configuration to exclude them from being processed as part of 'Bower Main Files'.
In general, Bower 'standards' are loose, and are not adhered to, even for popular packages.
During concatenation, sometimes a specific order needs to be achieved. I have been unable to find an elegant way to do this automatically - I have created an array of source files, but this is not ideal, as it requires manually checking and editing for each package, which mostly negates the whole concept of package management.
Questions:
Do experienced front-end developers attempt to follow the same approach as I am attempting (using bower_components as a source), or simply manually copy required files from GitHub?
If you do use bower-components, can you please outline the workflow with Gulp, and what plug-ins you use to filter out only the files you need.
Is it possible to prevent unneeded dependencies, tests, etc from being downloaded by Bower in the first place?
When processing files that include relative references (e.g. CSS containing a reference to an image), is it possible to correct the relative path, to be relative to the specified output directory for such assets?
Yes.
See below.
Well, bower package is package, you get whats included. For your build you either rely on components bower.json which specifies main files or do filtering yourself. It is simple enough.
You can use filter = require('gulp-filter') to filter files like that:
var gulp = require('gulp'),
bower = require('gulp-main-bower-files'),
filter = require('gulp-filter'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
srcmaps = require('gulp-sourcemaps'),
jsminify = require('gulp-uglify')
cssminify = require('gulp-csso'),
del = require('del');
var src = {
js: 'app/**/*.js',
css: 'app/**/*.css',
content: ['app/**/*.jpg', 'app/**/*.svg', 'app/**/*.png', 'app/**/*.ico', 'app/**/*.html']
}
var dst = {
pub: 'pub/',
lib: 'pub/lib/'
}
gulp.task('bower', ['start-build'], function () {
var jsfilter = filter('**/*.js')
var cssfilter = filter('**/*.css')
return gulp.src('bower.json')
.pipe(bower())
.pipe(jsfilter)
.pipe(concat('lib.min.js'))
.pipe(jsminify())
.pipe(gulp.dest(dst.lib))
.pipe(jsfilter.restore())
.pipe(cssfilter)
.pipe(concat('lib.min.css'))
.pipe(cssminify())
.pipe(gulp.dest(dst.lib))
.pipe(cssfilter.restore())
.pipe(rename(function (path) {
if (~path.dirname.indexOf('fonts')) {
path.dirname = '/fonts'
}
}))
.pipe(gulp.dest(dst.lib));
})
gulp.task('js', ['start-build'], function () {
return gulp.src([src.js])
.pipe(srcmaps.init())
.pipe(concat('app.min.js'))
.pipe(jsminify())
.pipe(srcmaps.write())
.pipe(gulp.dest(dst.pub));
})

Proper way to implement card.io SDK with Phonegap iOS?

I want to implement the card scanner from card.io SDK into Phonegap for iOS. I'm using Phonegap v2.9.0 and had went through this https://github.com/card-io/card.io-iOS-SDK-PhoneGap
I understand that it is a plugin, but I haven't created or implemented a plugin in Phonegap before. The code provided in the above link does not work for me. I don't know why, may be I am doing something wrong in the set up steps.
I want a clarification. Below are the steps given in gitHub
1) Add CardIOPGPlugin.[h|m] to your project (Plugins group).
2) Copy CardIOPGPlugin.js to your project's www folder. (If you don't have a www folder yet, run in the Simulator and follow the instructions in the build warnings.)
3) Add e.g. to your html.
See CardIOPGPlugin.js for detailed usage information.
4) Add the following to config.xml, for PhoneGap version 3.0+:
<feature name="CardIOPGPlugin"><param name="ios-package" value="CardIOPGPlugin" /></feature>
My doubts:
Which folder are they talking about in(1)? Plugins folder in Xcode? Or the Plugins folder in Project directory (directory that has config.xml). I have tried both but the sample code does not call the onCardIOCheck.
The gitHub for card.io SDK provides initial setup steps. (https://github.com/card-io/card.io-iOS-SDK)
There, in Step 2, they say "Add the CardIO directory (containing several .h files and libCardIO.a) to your Xcode project." How do I do this? Where do I copy the folder to?
And I have also done step 3 and 4 which are
3) In your project's Build Settings, add -lc++ to Other Linker Flags.
4) Add these frameworks to your project. Weak linking for iOS versions back to 5.0 is supported. (list of frameworks..)
I have done all, my onDeviceReady works, but window.plugins.card_io.canScan(onCardIOCheck); is not calling.
Please.. anyone who has done this before in PhoneGap and iOS, please provide a detailed explanation and steps to implement this in Phonegap iOS.
Providing my code: (app id is changed for question sake)
document.addEventListener("deviceready",onDeviceReady, false);
function onDeviceReady() {
alert('device ready');
var cardIOResponseFields = [
"card_type",
"redacted_card_number",
"card_number",
"expiry_month",
"expiry_year",
"cvv",
"zip"
];
var onCardIOComplete = function(response) {
alert("card.io scan complete");
for (var i = 0, len = cardIOResponseFields.length; i < len; i++) {
var field = cardIOResponseFields[i];
console.log(field + ": " + response[field]);
}
};
var onCardIOCancel = function() {
alert("card.io scan cancelled");
};
var onCardIOCheck = function (canScan) {
alert("card.io canScan? " + canScan);
var scanBtn = document.getElementById("scanBtn");
if (!canScan) {
scanBtn.innerHTML = "Manual entry";
}
scanBtn.onclick = function (e) {
window.plugins.card_io.scan(
"MYAPPIDCHANGEDFORQUESTION",
{
"collect_expiry": true,
"collect_cvv": false,
"collect_zip": false,
"shows_first_use_alert": true,
"disable_manual_entry_buttons": false
},
onCardIOComplete,
onCardIOCancel
);
}
};
window.plugins.card_io.canScan(onCardIOCheck);
}
Which folder are they talking about in(1)? Plugins folder in Xcode? Or the Plugins folder in Project directory (directory that has config.xml). I have tried both but the sample code does not call the onCardIOCheck.
the Plugins folder is the same, Xcode project just references the folder, when you copy files (depending on how you like to organize them) you would usually select copy and hence they will be places in the plugins folder, as long as the files compiled into the project it doesn't really matter.
There, in Step 2, they say "Add the CardIO directory (containing several .h files and libCardIO.a) to your Xcode project." How do I do this? Where do I copy the folder to?
It doesn't matter where you will copy the files as long as they are included in the Xcode project and compiled.
I have done all, my onDeviceReady works, but window.plugins.card_io.canScan(onCardIOCheck); is not calling.
Make sure the CardIOPGPlugin.js is loaded before the javascript files using it, it maybe undefined and hence fails.
Hope it helps.

Resources